Major code cleanup

Cleanup of imports, whitespace, etc. across all of PAMGuard. No other changes to code apart from this automatic cleanup.
This commit is contained in:
Douglas Gillespie 2024-08-27 12:48:16 +01:00
parent b9c613ea1b
commit b420fd9f9d
964 changed files with 5890 additions and 5952 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.pamguard</groupId> <groupId>org.pamguard</groupId>
<artifactId>Pamguard</artifactId> <artifactId>Pamguard</artifactId>
<version>2.02.13</version> <version>2.02.13a</version>
<name>Pamguard</name> <name>Pamguard</name>
<description>Pamguard using Maven to control dependencies</description> <description>Pamguard using Maven to control dependencies</description>
<url>www.pamguard.org</url> <url>www.pamguard.org</url>

View File

@ -13,7 +13,6 @@ import binaryFileStorage.BinaryHeader;
import binaryFileStorage.BinaryObjectData; import binaryFileStorage.BinaryObjectData;
import binaryFileStorage.ModuleFooter; import binaryFileStorage.ModuleFooter;
import binaryFileStorage.ModuleHeader; import binaryFileStorage.ModuleHeader;
import binaryFileStorage.PackedBinaryObject;
public class AISBinaryDataSource extends BinaryDataSource { public class AISBinaryDataSource extends BinaryDataSource {

View File

@ -32,7 +32,7 @@ public class AISBugSearch {
// first comma separates date and NMEA data // first comma separates date and NMEA data
int chPos = line.indexOf(","); int chPos = line.indexOf(",");
String nmeaData = line.substring(chPos+1); String nmeaData = line.substring(chPos+1);
if (nmeaData.contains("AIVDM") == false) { if (!nmeaData.contains("AIVDM")) {
continue; continue;
} }
System.out.println(nmeaData); System.out.println(nmeaData);

View File

@ -44,6 +44,7 @@ public class AISControl extends PamControlledUnit implements PamSettings {
super(); super();
this.parentFrame = parentFrame; this.parentFrame = parentFrame;
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
AISStringsTable.show(aisControl); AISStringsTable.show(aisControl);
} }
@ -55,6 +56,7 @@ public class AISControl extends PamControlledUnit implements PamSettings {
super(); super();
this.parentFrame = parentFrame; this.parentFrame = parentFrame;
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
AISParameters newParams = AISDisplayDialog.showDialog(parentFrame, aisParameters); AISParameters newParams = AISDisplayDialog.showDialog(parentFrame, aisParameters);
@ -70,6 +72,7 @@ public class AISControl extends PamControlledUnit implements PamSettings {
super(); super();
this.parentFrame = parentFrame; this.parentFrame = parentFrame;
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
AISParameters newParams = AISSettingsDialog.showDialog(parentFrame, aisParameters); AISParameters newParams = AISSettingsDialog.showDialog(parentFrame, aisParameters);
if (newParams != null) { if (newParams != null) {
@ -115,14 +118,17 @@ public class AISControl extends PamControlledUnit implements PamSettings {
aisProcess.noteNewSettings(); aisProcess.noteNewSettings();
} }
@Override
public Serializable getSettingsReference() { public Serializable getSettingsReference() {
return aisParameters; return aisParameters;
} }
@Override
public long getSettingsVersion() { public long getSettingsVersion() {
return AISParameters.serialVersionUID; return AISParameters.serialVersionUID;
} }
@Override
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) { public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
this.aisParameters = ((AISParameters) pamControlledUnitSettings.getSettings()).clone(); this.aisParameters = ((AISParameters) pamControlledUnitSettings.getSettings()).clone();

View File

@ -1,18 +1,16 @@
package AIS; package AIS;
import generalDatabase.DBControlUnit;
import generalDatabase.SQLTypes;
import java.util.ListIterator; import java.util.ListIterator;
import pamScrollSystem.ViewLoadObserver;
import nmeaEmulator.EmulatedData;
import nmeaEmulator.NMEAEmulator;
import NMEA.AcquireNmeaData; import NMEA.AcquireNmeaData;
import PamController.masterReference.MasterReferencePoint; import PamController.masterReference.MasterReferencePoint;
import PamUtils.LatLong; import PamUtils.LatLong;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import PamguardMVC.PamProcess; import PamguardMVC.PamProcess;
import generalDatabase.DBControlUnit;
import generalDatabase.SQLTypes;
import nmeaEmulator.EmulatedData;
import nmeaEmulator.NMEAEmulator;
public class AISDataBlock extends PamDataBlock<AISDataUnit> implements NMEAEmulator { public class AISDataBlock extends PamDataBlock<AISDataUnit> implements NMEAEmulator {
@ -76,7 +74,7 @@ public class AISDataBlock extends PamDataBlock<AISDataUnit> implements NMEAEmula
} }
private boolean wantData(AISDataUnit existingUnit, AISDataUnit newUnit) { private boolean wantData(AISDataUnit existingUnit, AISDataUnit newUnit) {
if (aisControl.aisParameters.limitRange == false) { if (!aisControl.aisParameters.limitRange) {
return true; return true;
} }
double range = 0; double range = 0;
@ -133,7 +131,7 @@ public class AISDataBlock extends PamDataBlock<AISDataUnit> implements NMEAEmula
@Override @Override
public EmulatedData getNextData() { public EmulatedData getNextData() {
SQLTypes sqlTypes = DBControlUnit.findConnection().getSqlTypes(); SQLTypes sqlTypes = DBControlUnit.findConnection().getSqlTypes();
if (getLogging().readNextEmulation(sqlTypes) == false) { if (!getLogging().readNextEmulation(sqlTypes)) {
return null; return null;
} }
// now all data should be in the loggers table definition. // now all data should be in the loggers table definition.

View File

@ -5,7 +5,6 @@ import java.util.ArrayList;
import NMEA.NMEABitArray; import NMEA.NMEABitArray;
import NMEA.NMEADataBlock; import NMEA.NMEADataBlock;
import PamDetection.AbstractLocalisation;
import PamDetection.LocContents; import PamDetection.LocContents;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;

View File

@ -7,8 +7,6 @@ import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.util.ArrayList; import java.util.ArrayList;
import radardisplay.RadarProjector;
import GPS.GpsData; import GPS.GpsData;
import GPS.GpsDataUnit; import GPS.GpsDataUnit;
import Map.MapRectProjector; import Map.MapRectProjector;
@ -20,14 +18,14 @@ import PamUtils.Coordinate3d;
import PamUtils.LatLong; import PamUtils.LatLong;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
import PamView.GeneralProjector; import PamView.GeneralProjector;
import PamView.GeneralProjector.ParameterType;
import PamView.PamDetectionOverlayGraphics; import PamView.PamDetectionOverlayGraphics;
import PamView.PamKeyItem; import PamView.PamKeyItem;
import PamView.PamSymbol; import PamView.PamSymbol;
import PamView.PamSymbolType; import PamView.PamSymbolType;
import PamView.GeneralProjector.ParameterType;
import PamView.symbol.SymbolData; import PamView.symbol.SymbolData;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;
import PamguardMVC.debug.Debug; import radardisplay.RadarProjector;
public class AISGraphics extends PamDetectionOverlayGraphics { public class AISGraphics extends PamDetectionOverlayGraphics {
@ -73,12 +71,12 @@ public class AISGraphics extends PamDetectionOverlayGraphics {
AISStaticData staticData = aisDataUnit.getStaticData(); AISStaticData staticData = aisDataUnit.getStaticData();
AISPositionReport positionReport = aisDataUnit.getPositionReport(); AISPositionReport positionReport = aisDataUnit.getPositionReport();
if (aisDataUnit.isComplete() == false) { if (!aisDataUnit.isComplete()) {
return null; return null;
} }
AbstractLocalisation localisation = pamDataUnit.getLocalisation(); AbstractLocalisation localisation = pamDataUnit.getLocalisation();
if (localisation == null || localisation.hasLocContent(LocContents.HAS_BEARING | LocContents.HAS_RANGE) == false) return null; if (localisation == null || !localisation.hasLocContent(LocContents.HAS_BEARING | LocContents.HAS_RANGE)) return null;
double bearing = localisation.getBearing(0) * 180 / Math.PI; double bearing = localisation.getBearing(0) * 180 / Math.PI;
double range = localisation.getRange(0); double range = localisation.getRange(0);
Coordinate3d c3d = generalProjector.getCoord3d(bearing, range, 0); Coordinate3d c3d = generalProjector.getCoord3d(bearing, range, 0);

View File

@ -1,22 +1,19 @@
package AIS; package AIS;
import generalDatabase.DBProcess;
import generalDatabase.PamConnection;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLLogging;
import generalDatabase.SQLTypes;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.sql.Types; import java.sql.Types;
import javax.naming.ldap.HasControls;
import PamController.PamController; import PamController.PamController;
import PamView.dialog.warn.WarnOnce; import PamView.dialog.warn.WarnOnce;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;
import generalDatabase.DBProcess;
import generalDatabase.PamConnection;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLLogging;
import generalDatabase.SQLTypes;
public class AISLogger extends SQLLogging { public class AISLogger extends SQLLogging {
@ -167,7 +164,7 @@ public class AISLogger extends SQLLogging {
acallSign = (String) callSign.getValue(); acallSign = (String) callSign.getValue();
ashipName = (String) shipName.getValue(); ashipName = (String) shipName.getValue();
ashipType = (String) shipType.getValue(); ashipType = (String) shipType.getValue();
aetaMillis = sqlTypes.millisFromTimeStamp(eta.getValue()); aetaMillis = SQLTypes.millisFromTimeStamp(eta.getValue());
// aetaMillis = (Long) eta.getValue(); // aetaMillis = (Long) eta.getValue();
adraught = (Double) draft.getValue(); adraught = (Double) draft.getValue();
adestination = (String) destination.getValue(); adestination = (String) destination.getValue();

View File

@ -199,7 +199,7 @@ public class AISStaticData extends AISReport implements Serializable, ManagedPar
} }
switch(stationType) { switch(stationType) {
case BASESTATION: case BASESTATION:
return stationType.BASESTATION.toString(); return StationType.BASESTATION.toString();
case A: case A:
case B: case B:
return getVesselTypeAndCargo(type); return getVesselTypeAndCargo(type);

View File

@ -109,12 +109,13 @@ public class AISStringsTable {
class TimerListener implements ActionListener { class TimerListener implements ActionListener {
boolean doneLayout; boolean doneLayout;
@Override
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
// table. // table.
// nmeaTableData.fireTableRowsUpdated(0, 10); // nmeaTableData.fireTableRowsUpdated(0, 10);
aisTableData.fireTableDataChanged(); aisTableData.fireTableDataChanged();
if (doneLayout == false && aisTableData.getRowCount() > 0) { if (!doneLayout && aisTableData.getRowCount() > 0) {
doneLayout = true; doneLayout = true;
} }
} }
@ -134,6 +135,7 @@ public class AISStringsTable {
/* (non-Javadoc) /* (non-Javadoc)
* @see javax.swing.table.TableModel#getColumnCount() * @see javax.swing.table.TableModel#getColumnCount()
*/ */
@Override
public int getColumnCount() { public int getColumnCount() {
return tableColumns.length; return tableColumns.length;
} }
@ -141,6 +143,7 @@ public class AISStringsTable {
/* (non-Javadoc) /* (non-Javadoc)
* @see javax.swing.table.TableModel#getRowCount() * @see javax.swing.table.TableModel#getRowCount()
*/ */
@Override
public int getRowCount() { public int getRowCount() {
if (aisDataBlock == null) return 0; if (aisDataBlock == null) return 0;
//System.out.println(aisDataBlock.getUnitsCount() + " rows in AIS data"); //System.out.println(aisDataBlock.getUnitsCount() + " rows in AIS data");
@ -150,6 +153,7 @@ public class AISStringsTable {
/* (non-Javadoc) /* (non-Javadoc)
* @see javax.swing.table.TableModel#getValueAt(int, int) * @see javax.swing.table.TableModel#getValueAt(int, int)
*/ */
@Override
public Object getValueAt(int rowIndex, int columnIndex) { public Object getValueAt(int rowIndex, int columnIndex) {
AISDataUnit aisDataUnit = aisDataBlock.getDataUnit(rowIndex, PamDataBlock.REFERENCE_CURRENT); AISDataUnit aisDataUnit = aisDataBlock.getDataUnit(rowIndex, PamDataBlock.REFERENCE_CURRENT);

View File

@ -3,7 +3,6 @@ package AIS;
import NMEA.NMEADataBlock; import NMEA.NMEADataBlock;
import NMEA.NMEADataUnit; import NMEA.NMEADataUnit;
import PamController.PamController; import PamController.PamController;
import PamDetection.AbstractLocalisation;
import PamDetection.LocContents; import PamDetection.LocContents;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
import PamView.symbol.StandardSymbolManager; import PamView.symbol.StandardSymbolManager;
@ -11,7 +10,6 @@ import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;
import PamguardMVC.PamObservable; import PamguardMVC.PamObservable;
import PamguardMVC.PamProcess; import PamguardMVC.PamProcess;
import autecPhones.AutecGraphics;
/** /**
* Process NMEA data to extract AIS information * Process NMEA data to extract AIS information

View File

@ -2,7 +2,7 @@ package Acquisition;
/** /**
* Very simplified version of the Acquisition parameters * Very simplified version of the Acquisition parameters
* to be passed over the JNI to the C backend. * to be passed over the JNI to the C backend.
* @author Doug * @author Doug
* *
*/ */
@ -12,7 +12,7 @@ public class AcquisitionCParameters {
public static final int SOUNDCARD = 1; public static final int SOUNDCARD = 1;
public static final int WAVFILE = 2; public static final int WAVFILE = 2;
public static final int DAQCARD = 3; public static final int DAQCARD = 3;
public int deviceType; public int deviceType;
public int deviceNumber; public int deviceNumber;
public int sampleRate; public int sampleRate;
@ -23,7 +23,7 @@ public class AcquisitionCParameters {
public String spareString2 = null; public String spareString2 = null;
public int[] channelList = new int[MAXCHAN]; public int[] channelList = new int[MAXCHAN];
public String soundFile; public String soundFile;
public int setDaqType(String daqType) { public int setDaqType(String daqType) {
deviceType = -1; deviceType = -1;
if (daqType.equalsIgnoreCase("Sound Card")) { if (daqType.equalsIgnoreCase("Sound Card")) {
@ -37,5 +37,5 @@ public class AcquisitionCParameters {
} }
return deviceType; return deviceType;
} }
} }

View File

@ -1,19 +1,19 @@
/* PAMGUARD - Passive Acoustic Monitoring GUARDianship. /* PAMGUARD - Passive Acoustic Monitoring GUARDianship.
* To assist in the Detection Classification and Localisation * To assist in the Detection Classification and Localisation
* of marine mammals (cetaceans). * of marine mammals (cetaceans).
* *
* Copyright (C) 2006 * Copyright (C) 2006
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3 * as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@ -21,10 +21,6 @@
package Acquisition; package Acquisition;
import hfDaqCard.SmruDaqSystem;
//import mcc.mccacquisition.MCCDaqSystem;
import mcc.mccacquisition.MCCDaqSystem;
import java.awt.Component; import java.awt.Component;
import java.awt.Frame; import java.awt.Frame;
import java.awt.Window; import java.awt.Window;
@ -38,20 +34,6 @@ import javax.swing.JMenuItem;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import org.pamguard.x3.sud.Chunk;
import org.pamguard.x3.sud.SudFileListener;
import dataGram.DatagramManager;
import dataMap.OfflineDataMapPoint;
import dataMap.filemaps.OfflineFileServer;
import dataPlotsFX.data.TDDataProviderRegisterFX;
import dataPlotsFX.rawDataPlotFX.RawSoundProviderFX;
import pamScrollSystem.ViewLoadObserver;
import simulatedAcquisition.SimProcess;
//import xarraydaq.XArrayDaq;
import asiojni.ASIOSoundSystem;
import asiojni.NewAsioSoundSystem;
import nidaqdev.NIDAQProcess;
import Acquisition.filedate.FileDate; import Acquisition.filedate.FileDate;
import Acquisition.filedate.StandardFileDate; import Acquisition.filedate.StandardFileDate;
import Acquisition.filetypes.SoundFileTypes; import Acquisition.filetypes.SoundFileTypes;
@ -74,8 +56,6 @@ import PamController.PamGUIManager;
import PamController.PamSettingManager; import PamController.PamSettingManager;
import PamController.PamSettings; import PamController.PamSettings;
import PamController.RawInputControlledUnit; import PamController.RawInputControlledUnit;
import PamController.fileprocessing.StoreStatus;
import PamModel.PamModel;
import PamModel.SMRUEnable; import PamModel.SMRUEnable;
import PamUtils.FrequencyFormat; import PamUtils.FrequencyFormat;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
@ -91,6 +71,20 @@ import PamguardMVC.PamDataBlock;
import PamguardMVC.PamProcess; import PamguardMVC.PamProcess;
import PamguardMVC.PamRawDataBlock; import PamguardMVC.PamRawDataBlock;
import PamguardMVC.dataOffline.OfflineDataLoadInfo; import PamguardMVC.dataOffline.OfflineDataLoadInfo;
//import xarraydaq.XArrayDaq;
import asiojni.ASIOSoundSystem;
import asiojni.NewAsioSoundSystem;
import dataGram.DatagramManager;
import dataMap.OfflineDataMapPoint;
import dataMap.filemaps.OfflineFileServer;
import dataPlotsFX.data.TDDataProviderRegisterFX;
import dataPlotsFX.rawDataPlotFX.RawSoundProviderFX;
import hfDaqCard.SmruDaqSystem;
//import mcc.mccacquisition.MCCDaqSystem;
import mcc.mccacquisition.MCCDaqSystem;
import nidaqdev.NIDAQProcess;
import pamScrollSystem.ViewLoadObserver;
import simulatedAcquisition.SimProcess;
/** /**
* Main data acquisition control to get audio data from sound cards, * Main data acquisition control to get audio data from sound cards,
@ -98,9 +92,9 @@ import PamguardMVC.dataOffline.OfflineDataLoadInfo;
* <p> * <p>
* Uses a plug in architecture to allow new types to be added. This * Uses a plug in architecture to allow new types to be added. This
* is done through RegisterDaqType(). * is done through RegisterDaqType().
* *
* @author Doug Gillespie * @author Doug Gillespie
* *
* @see Acquisition.DaqSystem * @see Acquisition.DaqSystem
* *
*/ */
@ -133,26 +127,26 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
protected FolderInputSystem folderSystem; protected FolderInputSystem folderSystem;
private DCL5System dclSystem; private DCL5System dclSystem;
protected FileDate fileDate; protected FileDate fileDate;
/** /**
* The JavaFX GUI for the sound acquisition module. * The JavaFX GUI for the sound acquisition module.
*/ */
private AquisitionGUIFX aquisitionGUIFX; private AquisitionGUIFX aquisitionGUIFX;
private SUDNotificationManager sudNotificationManager; private SUDNotificationManager sudNotificationManager;
protected SoundFileTypes soundFileTypes; protected SoundFileTypes soundFileTypes;
/** /**
* Main control unit for audio data acquisition. * Main control unit for audio data acquisition.
* <p> * <p>
* It is possible to instantiate several instances of this, preferably * It is possible to instantiate several instances of this, preferably
* with different names to simultaneously acquire sound from a number of * with different names to simultaneously acquire sound from a number of
* sources such as multiple sound cards, fast ADC boards, etc. * sources such as multiple sound cards, fast ADC boards, etc.
* <p> * <p>
* Each different acquisition device must implement the DaqSystem interface * Each different acquisition device must implement the DaqSystem interface
* and register with each AcquisitionControl. * and register with each AcquisitionControl.
* @param name name of the Acquisition control that will appear in menus. These should be * @param name name of the Acquisition control that will appear in menus. These should be
* different for each instance of AcquistionControl since the names are used by PamProcesses * different for each instance of AcquistionControl since the names are used by PamProcesses
@ -164,13 +158,13 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
super(unitType, name); super(unitType, name);
acquisitionControl = this; acquisitionControl = this;
fileDate = new StandardFileDate(this); fileDate = new StandardFileDate(this);
pamController = PamController.getInstance(); pamController = PamController.getInstance();
soundFileTypes = new SoundFileTypes(this); soundFileTypes = new SoundFileTypes(this);
registerDaqSystem(new SoundCardSystem(this)); registerDaqSystem(new SoundCardSystem(this));
if (PlatformInfo.calculateOS() == OSType.WINDOWS) { if (PlatformInfo.calculateOS() == OSType.WINDOWS) {
long tic = System.currentTimeMillis(); long tic = System.currentTimeMillis();
@ -178,13 +172,13 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
registerDaqSystem(new ASIOSoundSystem(this)); registerDaqSystem(new ASIOSoundSystem(this));
toc = System.currentTimeMillis(); toc = System.currentTimeMillis();
if (toc-tic>1000) { if (toc-tic>1000) {
System.out.printf("Registering ASIOSoundSystem took %3.1fs\n", (double)(toc-tic)/1000.); System.out.printf("Registering ASIOSoundSystem took %3.1fs\n", (toc-tic)/1000.);
} }
tic = System.currentTimeMillis(); tic = System.currentTimeMillis();
registerDaqSystem(new NewAsioSoundSystem(this)); registerDaqSystem(new NewAsioSoundSystem(this));
toc = System.currentTimeMillis(); toc = System.currentTimeMillis();
if (toc-tic>1000) { if (toc-tic>1000) {
System.out.printf("Registering NewAsioSoundSystem took %3.1fs\n", (double)(toc-tic)/1000.); System.out.printf("Registering NewAsioSoundSystem took %3.1fs\n", (toc-tic)/1000.);
} }
} }
registerDaqSystem(new FileInputSystem(this)); registerDaqSystem(new FileInputSystem(this));
@ -200,7 +194,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
registerDaqSystem(new MCCDaqSystem(this)); registerDaqSystem(new MCCDaqSystem(this));
// registerDaqSystem(new RonaInputSystem(this)); // registerDaqSystem(new RonaInputSystem(this));
} }
// load the DAQ Systems found in the plugins folder // load the DAQ Systems found in the plugins folder
loadExternalDaqSystems(); loadExternalDaqSystems();
@ -231,7 +225,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
} }
} }
setSelectedSystem(); setSelectedSystem();
TDDataProviderRegisterFX.getInstance().registerDataInfo(new RawSoundProviderFX(this)); TDDataProviderRegisterFX.getInstance().registerDataInfo(new RawSoundProviderFX(this));
} }
@ -242,22 +236,22 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
acquisitionControl = this; acquisitionControl = this;
} }
/** /**
* Overloaded constructor - used by the STAcquisitionControl class as a way to call * Overloaded constructor - used by the STAcquisitionControl class as a way to call
* the PamController.PamControlledUnit constructor without all of the AcquisitionControl * the PamController.PamControlledUnit constructor without all of the AcquisitionControl
* code above * code above
* *
* @param type the type of unit * @param type the type of unit
* @param name the name of the unit * @param name the name of the unit
*/ */
public AcquisitionControl(String type, String name) { public AcquisitionControl(String type, String name) {
super(type, name); super(type, name);
} }
private PamPanel systemPanel; private PamPanel systemPanel;
protected Component getStatusBarComponent() { protected Component getStatusBarComponent() {
PamPanel p = new PamPanel(); PamPanel p = new PamPanel();
p.add(statusBarText = new PamLabel()); p.add(statusBarText = new PamLabel());
@ -275,7 +269,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
*/ */
public void registerDaqSystem(DaqSystem daqSystem){ public void registerDaqSystem(DaqSystem daqSystem){
if (systemList == null) { if (systemList == null) {
systemList = new ArrayList<DaqSystem>(); systemList = new ArrayList<>();
} }
systemList.add(daqSystem); systemList.add(daqSystem);
//daqSystem.getItemsList(); //daqSystem.getItemsList();
@ -283,7 +277,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
} }
public static ArrayList<AcquisitionControl> getControllers() { public static ArrayList<AcquisitionControl> getControllers() {
ArrayList<AcquisitionControl> daqControllers = new ArrayList<AcquisitionControl>(); ArrayList<AcquisitionControl> daqControllers = new ArrayList<>();
PamControlledUnit pcu; PamControlledUnit pcu;
for (int i = 0; i < PamController.getInstance().getNumControlledUnits(); i++) { for (int i = 0; i < PamController.getInstance().getNumControlledUnits(); i++) {
pcu = PamController.getInstance().getControlledUnit(i); pcu = PamController.getInstance().getControlledUnit(i);
@ -315,7 +309,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
/** /**
* Finds a reference to a given DAQ system based on it's type (e.g. sound card, file, etc. * Finds a reference to a given DAQ system based on it's type (e.g. sound card, file, etc.
* @param systemType * @param systemType
* @return reference to a DaqSystem object * @return reference to a DaqSystem object
*/ */
public DaqSystem findDaqSystem(String systemType) { public DaqSystem findDaqSystem(String systemType) {
@ -323,8 +317,8 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
if (systemType == null) systemType = acquisitionParameters.daqSystemType; if (systemType == null) systemType = acquisitionParameters.daqSystemType;
for (int i = 0; i < systemList.size(); i++) { for (DaqSystem element : systemList) {
if (systemList.get(i).getSystemType().equals(systemType)) return systemList.get(i); if (element.getSystemType().equals(systemType)) return element;
} }
return null; return null;
@ -347,6 +341,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
this.parentFrame = parentFrame; this.parentFrame = parentFrame;
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
AcquisitionParameters newParameters = AcquisitionDialog.showDialog(parentFrame, acquisitionControl, acquisitionParameters); AcquisitionParameters newParameters = AcquisitionDialog.showDialog(parentFrame, acquisitionControl, acquisitionParameters);
if (newParameters != null) { if (newParameters != null) {
@ -378,28 +373,28 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
} }
lastSelSystem = selSystem; lastSelSystem = selSystem;
} }
/** /**
* Check array channels have corresponding hydrophones in the array manager. Does * Check array channels have corresponding hydrophones in the array manager. Does
* not open a dialog to warn or fix. * not open a dialog to warn or fix.
* @return check array channel. False if array manager * @return check array channel. False if array manager
*/ */
public boolean checkArrayChannels() { public boolean checkArrayChannels() {
int error = arrayChannelsOK(); int error = arrayChannelsOK();
if (error == ARRAY_ERROR_OK) { if (error == ARRAY_ERROR_OK) {
return true; return true;
} }
else return false; else return false;
} }
/** /**
* Run a check to see that all read out channels are connected to * Run a check to see that all read out channels are connected to
* a hydrophone and if not, do something about it. * a hydrophone and if not, do something about it.
* @return true if OK, or problem resolved. * @return true if OK, or problem resolved.
*/ */
public boolean checkArrayChannels(Frame parentFrame) { public boolean checkArrayChannels(Frame parentFrame) {
int error = arrayChannelsOK(); int error = arrayChannelsOK();
if (error == ARRAY_ERROR_OK) { if (error == ARRAY_ERROR_OK) {
@ -526,14 +521,17 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
* (non-Javadoc) * (non-Javadoc)
* @see PamController.PamSettings#GetSettingsReference() * @see PamController.PamSettings#GetSettingsReference()
*/ */
@Override
public Serializable getSettingsReference() { public Serializable getSettingsReference() {
return acquisitionParameters; return acquisitionParameters;
} }
@Override
public long getSettingsVersion() { public long getSettingsVersion() {
return AcquisitionParameters.serialVersionUID; return AcquisitionParameters.serialVersionUID;
} }
@Override
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) { public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
// if (PamSettingManager.getInstance().isSettingsUnit(this, pamControlledUnitSettings)) { // if (PamSettingManager.getInstance().isSettingsUnit(this, pamControlledUnitSettings)) {
@ -568,11 +566,11 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
// converts a list of ADC channels to a list of hydrophones // converts a list of ADC channels to a list of hydrophones
public int ChannelsToHydrophones(int channels) { public int ChannelsToHydrophones(int channels) {
int[] hydrophoneList = getHydrophoneList(); int[] hydrophoneList = getHydrophoneList();
if (hydrophoneList == null) return channels; // they are the same by default // they are the same by default
//In viewer mode sometimes the number of channels in sound aquisition can be lost i.e. //In viewer mode sometimes the number of channels in sound aquisition can be lost i.e.
//there are 0 channels. This causes bugs so if occurs return standard list. //there are 0 channels. This causes bugs so if occurs return standard list.
if (acquisitionParameters.nChannels==0) return channels; if ((hydrophoneList == null) || (acquisitionParameters.nChannels==0)) return channels;
int hydrophones = 0; int hydrophones = 0;
int channelListIndex; int channelListIndex;
for (int i = 0; i < PamConstants.MAX_CHANNELS; i++) { for (int i = 0; i < PamConstants.MAX_CHANNELS; i++) {
@ -585,8 +583,8 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
} }
/** /**
* Return a list of which channels are connected to which hydrophones in * Return a list of which channels are connected to which hydrophones in
* the currentarray. * the currentarray.
* @return List of hydrophone numbers. * @return List of hydrophone numbers.
*/ */
public int[] getHydrophoneList() { public int[] getHydrophoneList() {
@ -601,15 +599,15 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
acquisitionParameters.setHydrophoneList(hydrophoneList); acquisitionParameters.setHydrophoneList(hydrophoneList);
} }
/** /**
* *
* finds the ADC channel for a given hydrophone. * finds the ADC channel for a given hydrophone.
* Will return -1 if no ADC channel uses this hydrophone * Will return -1 if no ADC channel uses this hydrophone
* *
* @param hydrophoneId Number of a hydrophone in a PamArray * @param hydrophoneId Number of a hydrophone in a PamArray
* @return the ADC channel for the given hydrophone * @return the ADC channel for the given hydrophone
*/ */
public int findHydrophoneChannel(int hydrophoneId) { public int findHydrophoneChannel(int hydrophoneId) {
// finds the ADC channel for a given hydrophone. // finds the ADC channel for a given hydrophone.
// will return -1 if no ADC channel uses this hydrophone // will return -1 if no ADC channel uses this hydrophone
// if no list, assume 1-1 mapping // if no list, assume 1-1 mapping
int channelList[] = acquisitionControl.acquisitionParameters.getHardwareChannelList(); int channelList[] = acquisitionControl.acquisitionParameters.getHardwareChannelList();
@ -664,7 +662,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
/** /**
* Getter for acquisition parameters. * Getter for acquisition parameters.
* @return data acquisition parameters. * @return data acquisition parameters.
*/ */
public AcquisitionParameters getAcquisitionParameters() { public AcquisitionParameters getAcquisitionParameters() {
return acquisitionParameters; return acquisitionParameters;
@ -679,6 +677,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
/** /**
* @return the offlineFileServer * @return the offlineFileServer
*/ */
@Override
public OfflineFileServer getOfflineFileServer() { public OfflineFileServer getOfflineFileServer() {
return offlineFileServer; return offlineFileServer;
} }
@ -759,15 +758,15 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
public FileDate getFileDate() { public FileDate getFileDate() {
return fileDate; return fileDate;
} }
/** /**
* Load any classes that were found in the plugins folder and implement the DaqSystemInterface interface * Load any classes that were found in the plugins folder and implement the DaqSystemInterface interface
*/ */
public void loadExternalDaqSystems() { public void loadExternalDaqSystems() {
// get a list of plugins // get a list of plugins
List<DaqSystemInterface> daqList = ((PamModel) PamController.getInstance().getModelInterface()).getDaqList(); List<DaqSystemInterface> daqList = PamController.getInstance().getModelInterface().getDaqList();
// if there are no plugins, return // if there are no plugins, return
if (daqList.isEmpty()) { if (daqList.isEmpty()) {
return; return;
@ -776,7 +775,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
registerDaqSystem(dsi.createDAQControl(this)); registerDaqSystem(dsi.createDAQControl(this));
} }
} }
/** /**
* Get the available DAQ systems * Get the available DAQ systems
* @return * @return
@ -784,16 +783,16 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
public ArrayList<DaqSystem> getSystemList() { public ArrayList<DaqSystem> getSystemList() {
return this.systemList; return this.systemList;
} }
/** /**
* Set the acquisition parameters. * Set the acquisition parameters.
* @param params - the acquisition params to set. * @param params - the acquisition params to set.
*/ */
public void setAquisitionParams(AcquisitionParameters params) { public void setAquisitionParams(AcquisitionParameters params) {
this.acquisitionParameters=params; this.acquisitionParameters=params;
} }
@Override @Override
public PamControlledUnitGUI getGUI(int flag) { public PamControlledUnitGUI getGUI(int flag) {
if (flag==PamGUIManager.FX) { if (flag==PamGUIManager.FX) {
@ -805,18 +804,18 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
//TODO swing //TODO swing
return null; return null;
} }
/** /**
* Get a summary of the daq settings for the QA module. * Get a summary of the daq settings for the QA module.
* @return summary of DAQ settings. * @return summary of DAQ settings.
*/ */
public String getDaqSummary() { public String getDaqSummary() {
DaqSystem daqSys = findDaqSystem(null); DaqSystem daqSys = findDaqSystem(null);
if (daqSys == null) { if (daqSys == null) {
return String.format("%s - currently unavailable", acquisitionParameters.daqSystemType); return String.format("%s - currently unavailable", acquisitionParameters.daqSystemType);
} }
String str = String.format("%s - %s, %3.1fVp-p", String str = String.format("%s - %s, %3.1fVp-p",
acquisitionParameters.daqSystemType, daqSys.getDeviceName(), acquisitionParameters.daqSystemType, daqSys.getDeviceName(),
acquisitionParameters.voltsPeak2Peak); acquisitionParameters.voltsPeak2Peak);
Preamplifier preamp = acquisitionParameters.getPreamplifier(); Preamplifier preamp = acquisitionParameters.getPreamplifier();
if (preamp != null) { if (preamp != null) {
@ -825,11 +824,11 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
str += ", Sample Rate " + FrequencyFormat.formatFrequency(acquisitionParameters.sampleRate, true); str += ", Sample Rate " + FrequencyFormat.formatFrequency(acquisitionParameters.sampleRate, true);
return str; return str;
} }
@Override @Override
public String tellModule(String command) { public String tellModule(String command) {
/** /**
* Get timing summary and return as a string. * Get timing summary and return as a string.
*/ */
switch (command) { switch (command) {
case "gettimeinfo": case "gettimeinfo":
@ -837,35 +836,35 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
} }
return super.tellModule(command); return super.tellModule(command);
} }
/** /**
* Get a summary of time information as to what's going on in the DAQ * Get a summary of time information as to what's going on in the DAQ
* @return time summary * @return time summary
*/ */
private String getTimeInfoString() { private String getTimeInfoString() {
/* /*
* *
sprintf(returned,"%s:%lld,%lld,%ld,%lld",getModuleName(),calendar->getRawStartTime(), sprintf(returned,"%s:%lld,%lld,%ld,%lld",getModuleName(),calendar->getRawStartTime(),
calendar->getMillisecondTime(),(int)daqProcess->getSampleRate(),acquiredSamples); calendar->getMillisecondTime(),(int)daqProcess->getSampleRate(),acquiredSamples);
*/ */
return String.format("%s:%d,%d,%d,%d", getUnitName(), PamCalendar.getSessionStartTime(), PamCalendar.getTimeInMillis(), return String.format("%s:%d,%d,%d,%d", getUnitName(), PamCalendar.getSessionStartTime(), PamCalendar.getTimeInMillis(),
(int) acquisitionProcess.getSampleRate(), acquisitionProcess.getTotalSamples(0)); (int) acquisitionProcess.getSampleRate(), acquisitionProcess.getTotalSamples(0));
} }
@Override @Override
public void pamHasStopped() { public void pamHasStopped() {
acquisitionProcess.pamHasStopped(); acquisitionProcess.pamHasStopped();
} }
@Override @Override
public String getModuleSummary(boolean clear) { public String getModuleSummary(boolean clear) {
return getDaqProcess().getRawDataBlock().getSummaryString(clear); return getDaqProcess().getRawDataBlock().getSummaryString(clear);
} }
/** /**
* Get the SUD processing notification manager. * Get the SUD processing notification manager.
* @return SUD processing notification manager. * @return SUD processing notification manager.
*/ */
public SUDNotificationManager getSUDNotificationManager() { public SUDNotificationManager getSUDNotificationManager() {
if (sudNotificationManager == null) { if (sudNotificationManager == null) {
@ -873,8 +872,8 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
} }
return sudNotificationManager; return sudNotificationManager;
} }
@Override @Override
public int getRawInputType() { public int getRawInputType() {
DaqSystem system = acquisitionProcess.getRunningSystem(); DaqSystem system = acquisitionProcess.getRunningSystem();
@ -889,17 +888,18 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
public InputStoreInfo getStoreInfo(boolean detail) { public InputStoreInfo getStoreInfo(boolean detail) {
return getDaqProcess().getStoreInfo(detail); return getDaqProcess().getStoreInfo(detail);
} }
@Override @Override
public boolean setAnalysisStartTime(long startTime) { public boolean setAnalysisStartTime(long startTime) {
return getDaqProcess().setAnalysisStartTime(startTime); return getDaqProcess().setAnalysisStartTime(startTime);
} }
/** /**
* Very specific command handler for batch status which will only work * Very specific command handler for batch status which will only work
* with the folderinputSystem. * with the folderinputSystem.
* @return * @return
*/ */
@Override
public String getBatchStatus() { public String getBatchStatus() {
DaqSystem runningSystem = getAcquisitionProcess().getRunningSystem(); DaqSystem runningSystem = getAcquisitionProcess().getRunningSystem();
if (runningSystem instanceof FolderInputSystem) { if (runningSystem instanceof FolderInputSystem) {
@ -909,5 +909,5 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
return null; return null;
} }
} }
} }

View File

@ -30,87 +30,87 @@ import dataMap.filemaps.OfflineFileDialogPanel;
import dataMap.filemaps.OfflineFileParameters; import dataMap.filemaps.OfflineFileParameters;
/** /**
* Main dialog for acquisition control. Takes plug in panels from * Main dialog for acquisition control. Takes plug in panels from
* the various sound systems to give more device specific controls where * the various sound systems to give more device specific controls where
* necessary. * necessary.
* *
* @author Doug Gillespie * @author Doug Gillespie
* *
*/ */
public class AcquisitionDialog extends PamDialog { public class AcquisitionDialog extends PamDialog {
private static AcquisitionParameters acquisitionParameters; private static AcquisitionParameters acquisitionParameters;
private static AcquisitionDialog singleInstance; private static AcquisitionDialog singleInstance;
private static AcquisitionControl acquisitionControl; private static AcquisitionControl acquisitionControl;
private OfflineFileDialogPanel offlineDAQDialogPanel; private OfflineFileDialogPanel offlineDAQDialogPanel;
private PPSDialogPanel ppsDialogPanel; private PPSDialogPanel ppsDialogPanel;
private DaqSystem currentDaqSystem; private DaqSystem currentDaqSystem;
private JComboBox deviceType; private JComboBox deviceType;
private JPanel mainPanel; private JPanel mainPanel;
private JComponent deviceSpecificPanel; private JComponent deviceSpecificPanel;
private JTextField sampleRate, nChannels, vPeak2Peak; private JTextField sampleRate, nChannels, vPeak2Peak;
private JTextField preampGain; private JTextField preampGain;
// bandwidth0, bandwidth1; // bandwidth0, bandwidth1;
private JCheckBox subtractDC; private JCheckBox subtractDC;
private JTextField dcTimeconstant; private JTextField dcTimeconstant;
// public int channelList[] = new int[PamConstants.MAX_CHANNELS]; // public int channelList[] = new int[PamConstants.MAX_CHANNELS];
// //
// private JLabel panelChannelLabel[] = new JLabel[PamConstants.MAX_CHANNELS]; // private JLabel panelChannelLabel[] = new JLabel[PamConstants.MAX_CHANNELS];
// private JComboBox panelChannelList[] = new JComboBox[PamConstants.MAX_CHANNELS]; // private JComboBox panelChannelList[] = new JComboBox[PamConstants.MAX_CHANNELS];
private ChannelListPanel standardChannelListPanel = new StandardChannelListPanel(); private ChannelListPanel standardChannelListPanel = new StandardChannelListPanel();
private ChannelListPanel currentChannelListPanel; private ChannelListPanel currentChannelListPanel;
private JPanel channelListPanelArea = new JPanel(); private JPanel channelListPanelArea = new JPanel();
//private static AcquisitionParameters acquisitionParameters; //Xiao Yan Deng //private static AcquisitionParameters acquisitionParameters; //Xiao Yan Deng
/** /**
* Main dialog for data acquisition control * Main dialog for data acquisition control
* <p> * <p>
* When shown, the dialog contains three main panels. * When shown, the dialog contains three main panels.
* <p>The top one shows * <p>The top one shows
* a list of available DaqSystems (e.g. sound cards, NI cards, etc. * a list of available DaqSystems (e.g. sound cards, NI cards, etc.
* >p> * >p>
* The middle panel selected based on the type of DaqSytem and is implemented differently * The middle panel selected based on the type of DaqSytem and is implemented differently
* within each DaqSystem. For instance, the sound card DaqSystem displays a list * within each DaqSystem. For instance, the sound card DaqSystem displays a list
* of available sound cards. The file system displays a list of recent files, * of available sound cards. The file system displays a list of recent files,
* systems for other ADC cards mght display a channel selector and gain settings * systems for other ADC cards mght display a channel selector and gain settings
* specific for a particular device. * specific for a particular device.
* <p> * <p>
* The bottom panel shows the number of channels, sample rate, and device sensitivity. * The bottom panel shows the number of channels, sample rate, and device sensitivity.
* The selected DaqSystem is queried to see if these are fixed, unknown or user entered * The selected DaqSystem is queried to see if these are fixed, unknown or user entered
* and enables the controls accordingly. If they are set by the DaqSystem, the * and enables the controls accordingly. If they are set by the DaqSystem, the
* DaqSystem should set them explicity using setSampleRate(), setChannels, and * DaqSystem should set them explicity using setSampleRate(), setChannels, and
* setVPeak2Peak * setVPeak2Peak
* *
*/ */
private AcquisitionDialog (Frame parentFrame) { private AcquisitionDialog (Frame parentFrame) {
super(parentFrame, "Audio Data Acquisition", false); super(parentFrame, "Audio Data Acquisition", false);
mainPanel = new JPanel(); mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
mainPanel.add(DeviceTypePanel()); mainPanel.add(DeviceTypePanel());
mainPanel.add(SamplingPanel()); mainPanel.add(SamplingPanel());
mainPanel.add(CalibrationPanel()); mainPanel.add(CalibrationPanel());
nChannels.addActionListener(new NumChannels()); nChannels.addActionListener(new NumChannels());
setHelpPoint("sound_processing.AcquisitionHelp.docs.AcquisitionConfiguration"); setHelpPoint("sound_processing.AcquisitionHelp.docs.AcquisitionConfiguration");
if (PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW) { if (PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW) {
JTabbedPane tabbedPane = new JTabbedPane(); JTabbedPane tabbedPane = new JTabbedPane();
offlineDAQDialogPanel = new OfflineFileDialogPanel(acquisitionControl, this); offlineDAQDialogPanel = new OfflineFileDialogPanel(acquisitionControl, this);
@ -131,45 +131,45 @@ public class AcquisitionDialog extends PamDialog {
setParams(); //Xiao Yan Deng setParams(); //Xiao Yan Deng
sortChannelLists(); // Xiao Yan Deng sortChannelLists(); // Xiao Yan Deng
} }
/** /**
* Clear the static instance so that the dialog is * Clear the static instance so that the dialog is
* totally rebuilt next time it's launched. * totally rebuilt next time it's launched.
*/ */
static public void clearInstance() { static public void clearInstance() {
singleInstance = null; singleInstance = null;
} }
/** /**
* Shows the data acquisition dialog. * Shows the data acquisition dialog.
* @param daqControl the calling AcquisitionControl * @param daqControl the calling AcquisitionControl
* @param oldParams current parameters from the AcquisitionControl * @param oldParams current parameters from the AcquisitionControl
* @return new parameters selected in the dialog * @return new parameters selected in the dialog
* @see AcquisitionControl * @see AcquisitionControl
*/ */
static public AcquisitionParameters showDialog(Frame parentFrame, AcquisitionControl daqControl, AcquisitionParameters oldParams) { static public AcquisitionParameters showDialog(Frame parentFrame, AcquisitionControl daqControl, AcquisitionParameters oldParams) {
acquisitionParameters = oldParams.clone(); acquisitionParameters = oldParams.clone();
acquisitionControl = daqControl; acquisitionControl = daqControl;
// singleInstance = null; // singleInstance = null;
if (singleInstance == null || singleInstance.getOwner() != parentFrame) { if (singleInstance == null || singleInstance.getOwner() != parentFrame) {
singleInstance = new AcquisitionDialog(parentFrame); singleInstance = new AcquisitionDialog(parentFrame);
} }
singleInstance.setParams(); singleInstance.setParams();
singleInstance.sortChannelLists(); singleInstance.sortChannelLists();
singleInstance.setVisible(true); singleInstance.setVisible(true);
singleInstance.sortChannelLists(); // Xiao Yan Deng singleInstance.sortChannelLists(); // Xiao Yan Deng
return acquisitionParameters; return acquisitionParameters;
} }
private void setParams() { private void setParams() {
// fill in the different device types. // fill in the different device types.
deviceType.removeAllItems(); deviceType.removeAllItems();
int ind = 0; int ind = 0;
@ -180,23 +180,23 @@ public class AcquisitionDialog extends PamDialog {
} }
} }
deviceType.setSelectedIndex(ind); deviceType.setSelectedIndex(ind);
newDeviceType(); newDeviceType();
setSampleRate(acquisitionParameters.sampleRate); setSampleRate(acquisitionParameters.sampleRate);
setChannels(acquisitionParameters.nChannels); setChannels(acquisitionParameters.nChannels);
setVPeak2Peak(acquisitionParameters.voltsPeak2Peak); setVPeak2Peak(acquisitionParameters.voltsPeak2Peak);
// preampGain.setText(String.format("%.1f", acquisitionParameters.preamplifier.getGain())); // preampGain.setText(String.format("%.1f", acquisitionParameters.preamplifier.getGain()));
setPreampGain(acquisitionParameters.preamplifier.getGain()); setPreampGain(acquisitionParameters.preamplifier.getGain());
// bandwidth0.setText(String.format("%.1f", acquisitionParameters.preamplifier.getBandwidth()[0])); // bandwidth0.setText(String.format("%.1f", acquisitionParameters.preamplifier.getBandwidth()[0]));
// bandwidth1.setText(String.format("%.1f", acquisitionParameters.preamplifier.getBandwidth()[1])); // bandwidth1.setText(String.format("%.1f", acquisitionParameters.preamplifier.getBandwidth()[1]));
subtractDC.setSelected(acquisitionParameters.subtractDC); subtractDC.setSelected(acquisitionParameters.subtractDC);
dcTimeconstant.setText(String.format("%3.1f", acquisitionParameters.dcTimeConstant)); dcTimeconstant.setText(String.format("%3.1f", acquisitionParameters.dcTimeConstant));
if (currentDaqSystem != null) currentDaqSystem.dialogSetParams(); if (currentDaqSystem != null) currentDaqSystem.dialogSetParams();
if (currentChannelListPanel != null) { if (currentChannelListPanel != null) {
@ -206,24 +206,24 @@ public class AcquisitionDialog extends PamDialog {
if (offlineDAQDialogPanel != null) { if (offlineDAQDialogPanel != null) {
offlineDAQDialogPanel.setParams(); offlineDAQDialogPanel.setParams();
} }
if (ppsDialogPanel != null) { if (ppsDialogPanel != null) {
ppsDialogPanel.setParams(acquisitionParameters.getPpsParameters()); ppsDialogPanel.setParams(acquisitionParameters.getPpsParameters());
} }
enableControls(); enableControls();
} }
/** /**
* Called by the specific DaqSystem to set sample rate when it is set by * Called by the specific DaqSystem to set sample rate when it is set by
* the DaqSystem (for instance FileInputSystem will set sample rate to the * the DaqSystem (for instance FileInputSystem will set sample rate to the
* sample rate of data in the current file. * sample rate of data in the current file.
* @param sampleRate Current sample rate * @param sampleRate Current sample rate
*/ */
public void setSampleRate(float sampleRate) { public void setSampleRate(float sampleRate) {
this.sampleRate.setText(String.format("%.0f", sampleRate)); this.sampleRate.setText(String.format("%.0f", sampleRate));
} }
/** /**
* Get the sample rate, or null if sample rate is not a valid number * Get the sample rate, or null if sample rate is not a valid number
* @return sample rate or null * @return sample rate or null
@ -239,15 +239,15 @@ public class AcquisitionDialog extends PamDialog {
/** /**
* Called by the specific DaqSystem to set the number of channels when it is set by * Called by the specific DaqSystem to set the number of channels when it is set by
* the DaqSystem (for instance FileInputSystem will set it to the * the DaqSystem (for instance FileInputSystem will set it to the
* number of channels in the current file. * number of channels in the current file.
* @param nChannels Number of channels * @param nChannels Number of channels
*/ */
public void setChannels(int nChannels) { public void setChannels(int nChannels) {
this.nChannels.setText(String.format("%d", nChannels)); this.nChannels.setText(String.format("%d", nChannels));
} }
/** /**
* @return the number of channels or null if invalid number * @return the number of channels or null if invalid number
*/ */
public Integer getChannels() { public Integer getChannels() {
@ -258,7 +258,7 @@ public class AcquisitionDialog extends PamDialog {
return null; return null;
} }
} }
public void setPreampGain(double gain) { public void setPreampGain(double gain) {
preampGain.setText(String.format("%.1f", gain)); preampGain.setText(String.format("%.1f", gain));
} }
@ -266,13 +266,13 @@ public class AcquisitionDialog extends PamDialog {
/** /**
* Called by the specific DaqSystem to set the peak to peak voltage range. * Called by the specific DaqSystem to set the peak to peak voltage range.
* This is used for calculating absolute SPL's in various detectors * This is used for calculating absolute SPL's in various detectors
* the DaqSystem * the DaqSystem
* @param vPeak2Peak Peak to Peak input voltage * @param vPeak2Peak Peak to Peak input voltage
*/ */
public void setVPeak2Peak(double vPeak2Peak) { public void setVPeak2Peak(double vPeak2Peak) {
this.vPeak2Peak.setText(String.format("%4.3f", vPeak2Peak)); this.vPeak2Peak.setText(String.format("%4.3f", vPeak2Peak));
} }
// read parameters back from the dialog // read parameters back from the dialog
@Override @Override
public boolean getParams() { public boolean getParams() {
@ -287,15 +287,15 @@ public class AcquisitionDialog extends PamDialog {
// bw[0] = Double.valueOf(bandwidth0.getText()); // bw[0] = Double.valueOf(bandwidth0.getText());
// bw[1] = Double.valueOf(bandwidth1.getText()); // bw[1] = Double.valueOf(bandwidth1.getText());
// acquisitionParameters.preamplifier.setBandwidth(bw); // acquisitionParameters.preamplifier.setBandwidth(bw);
if(!currentDaqSystem.areSampleSettingsOk(acquisitionParameters.nChannels, acquisitionParameters.sampleRate)){ if(!currentDaqSystem.areSampleSettingsOk(acquisitionParameters.nChannels, acquisitionParameters.sampleRate)){
currentDaqSystem.showSampleSettingsDialog(this); currentDaqSystem.showSampleSettingsDialog(this);
return false; return false;
} }
int nP = getNumChannels(); int nP = getNumChannels();
if (getCurrentDaqSystem().supportsChannelLists() && currentChannelListPanel != null) { if (getCurrentDaqSystem().supportsChannelLists() && currentChannelListPanel != null) {
if (currentChannelListPanel.isDataOk() == false) { if (!currentChannelListPanel.isDataOk()) {
return false; return false;
} }
int[] chL = currentChannelListPanel.getChannelList(); int[] chL = currentChannelListPanel.getChannelList();
@ -312,7 +312,7 @@ public class AcquisitionDialog extends PamDialog {
Ex.printStackTrace(); Ex.printStackTrace();
return false; return false;
} }
acquisitionParameters.subtractDC = subtractDC.isSelected(); acquisitionParameters.subtractDC = subtractDC.isSelected();
if (acquisitionParameters.subtractDC) { if (acquisitionParameters.subtractDC) {
try { try {
@ -325,8 +325,8 @@ public class AcquisitionDialog extends PamDialog {
return showWarning("The DC bacround subtractino time constant must be greater than zero"); return showWarning("The DC bacround subtractino time constant must be greater than zero");
} }
} }
if (offlineDAQDialogPanel != null) { if (offlineDAQDialogPanel != null) {
OfflineFileParameters ofp = offlineDAQDialogPanel.getParams(); OfflineFileParameters ofp = offlineDAQDialogPanel.getParams();
if (ofp == null) { if (ofp == null) {
@ -346,13 +346,13 @@ public class AcquisitionDialog extends PamDialog {
return false; return false;
} }
} }
return true; return true;
} }
/** /**
* Read the latest sample rate value. * Read the latest sample rate value.
* @return sample rate Hz. * @return sample rate Hz.
*/ */
public double readSampleRate() { public double readSampleRate() {
double sr = 0; double sr = 0;
@ -365,22 +365,24 @@ public class AcquisitionDialog extends PamDialog {
return sr; return sr;
} }
@Override @Override
public void cancelButtonPressed() { public void cancelButtonPressed() {
acquisitionParameters = null; acquisitionParameters = null;
} }
@Override @Override
public void restoreDefaultSettings() { public void restoreDefaultSettings() {
} }
private class NewDeviceType implements ActionListener { private class NewDeviceType implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
newDeviceType(); newDeviceType();
} }
} }
private class NumChannels implements ActionListener { private class NumChannels implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
sortChannelLists(); sortChannelLists();
} }
@ -395,7 +397,7 @@ public class AcquisitionDialog extends PamDialog {
deviceType.addActionListener(new NewDeviceType()); deviceType.addActionListener(new NewDeviceType());
return p; return p;
} }
/** /**
* Only need to show the channel panel for certain device types, * Only need to show the channel panel for certain device types,
* *
@ -415,20 +417,20 @@ public class AcquisitionDialog extends PamDialog {
channelListPanelArea.add(standardChannelListPanel.getComponent()); channelListPanelArea.add(standardChannelListPanel.getComponent());
// channelListPanel.setVisible(currentSystem.supportsChannelLists()); // channelListPanel.setVisible(currentSystem.supportsChannelLists());
} }
} }
private JPanel SamplingPanel () { private JPanel SamplingPanel () {
JPanel sP = new PamAlignmentPanel(new BorderLayout(), BorderLayout.WEST); JPanel sP = new PamAlignmentPanel(new BorderLayout(), BorderLayout.WEST);
JPanel p = new JPanel(); JPanel p = new JPanel();
sP.setBorder(new TitledBorder("Sampling")); sP.setBorder(new TitledBorder("Sampling"));
GridBagLayout layout; GridBagLayout layout;
p.setLayout(layout = new GridBagLayout()); p.setLayout(layout = new GridBagLayout());
GridBagConstraints constraints = new PamGridBagContraints(); GridBagConstraints constraints = new PamGridBagContraints();
constraints.anchor = GridBagConstraints.EAST; constraints.anchor = GridBagConstraints.EAST;
constraints.insets = new Insets(2,2,2,2); constraints.insets = new Insets(2,2,2,2);
constraints.fill = GridBagConstraints.NONE; constraints.fill = GridBagConstraints.NONE;
@ -450,31 +452,31 @@ public class AcquisitionDialog extends PamDialog {
constraints.gridx ++; constraints.gridx ++;
constraints.gridwidth = 2; constraints.gridwidth = 2;
addComponent(p, new JLabel(" (hit enter)"), constraints); addComponent(p, new JLabel(" (hit enter)"), constraints);
sP.add(BorderLayout.NORTH, p); sP.add(BorderLayout.NORTH, p);
// constraints.gridy++; // constraints.gridy++;
// constraints.gridx = 0; // constraints.gridx = 0;
// constraints.gridwidth = 4; // constraints.gridwidth = 4;
standardChannelListPanel = new StandardChannelListPanel(); standardChannelListPanel = new StandardChannelListPanel();
// addComponent(p, channelListPanel, constraints); // addComponent(p, channelListPanel, constraints);
constraints.insets = new Insets(2,2,2,2); constraints.insets = new Insets(2,2,2,2);
sP.add(BorderLayout.CENTER, channelListPanelArea); sP.add(BorderLayout.CENTER, channelListPanelArea);
return sP; return sP;
} }
// //
// private JPanel createStandardChannelListPanel() { // private JPanel createStandardChannelListPanel() {
// //
// /* code for select channel */ // /* code for select channel */
// /* // /*
// * put this in a separate panel so it can be hidden if // * put this in a separate panel so it can be hidden if
// * it's not possible to change these parameters. // * it's not possible to change these parameters.
// * // *
// * Text information updated DG & JG 12/8/08 // * Text information updated DG & JG 12/8/08
// */ // */
// JPanel cP; // JPanel cP;
@ -494,7 +496,7 @@ public class AcquisitionDialog extends PamDialog {
// s += "<br>So be aware. If you've put a plug into socket 1, <br>you probably want to select channel 0, etc.</html>"; // s += "<br>So be aware. If you've put a plug into socket 1, <br>you probably want to select channel 0, etc.</html>";
// for (int i = 0; i < PamConstants.MAX_CHANNELS; i++){ //Xiao Yan Deng // for (int i = 0; i < PamConstants.MAX_CHANNELS; i++){ //Xiao Yan Deng
// //for (int i = 0; i < getNumChannels(); i++){ // //for (int i = 0; i < getNumChannels(); i++){
// //
// if (i%2 ==0){ // if (i%2 ==0){
// c2.gridx = 0; // c2.gridx = 0;
// c2.gridy ++; // c2.gridy ++;
@ -509,28 +511,28 @@ public class AcquisitionDialog extends PamDialog {
// else { // else {
// spaceStr = ""; // spaceStr = "";
// } // }
// addComponent(cP, panelChannelLabel[i] = // addComponent(cP, panelChannelLabel[i] =
// new JLabel(spaceStr + " SW Ch " + i + " = HW Ch "), c2); // new JLabel(spaceStr + " SW Ch " + i + " = HW Ch "), c2);
// c2.gridx ++; // c2.gridx ++;
// //constraints.gridwidth = 2; // //constraints.gridwidth = 2;
// addComponent(cP, panelChannelList[i] = new JComboBox(), c2); // addComponent(cP, panelChannelList[i] = new JComboBox(), c2);
// panelChannelLabel[i].setToolTipText(s); // panelChannelLabel[i].setToolTipText(s);
// panelChannelList[i].setToolTipText(s); // panelChannelList[i].setToolTipText(s);
// //
// } // }
// return cP; // return cP;
// } // }
// //
private JPanel CalibrationPanel() { private JPanel CalibrationPanel() {
JPanel p = new PamAlignmentPanel(BorderLayout.WEST) ; JPanel p = new PamAlignmentPanel(BorderLayout.WEST) ;
p.setBorder(new TitledBorder("Calibration")); p.setBorder(new TitledBorder("Calibration"));
GridBagLayout layout; GridBagLayout layout;
p.setLayout(layout = new GridBagLayout()); p.setLayout(layout = new GridBagLayout());
GridBagConstraints constraints = new PamGridBagContraints(); GridBagConstraints constraints = new PamGridBagContraints();
constraints.anchor = GridBagConstraints.WEST; constraints.anchor = GridBagConstraints.WEST;
constraints.insets = new Insets(2,2,2,2); constraints.insets = new Insets(2,2,2,2);
constraints.gridx = 0; constraints.gridx = 0;
@ -588,13 +590,13 @@ public class AcquisitionDialog extends PamDialog {
enableControls(); enableControls();
} }
}); });
String t = "Some input devices have a fixed (DC) offset in their voltage measurement.\n" + String t = "Some input devices have a fixed (DC) offset in their voltage measurement.\n" +
"Subtracting this off can lead to improved PAMGuard performance."; "Subtracting this off can lead to improved PAMGuard performance.";
dcTimeconstant.setToolTipText(t); dcTimeconstant.setToolTipText(t);
subtractDC.setToolTipText(t); subtractDC.setToolTipText(t);
return p; return p;
} }
@ -604,10 +606,10 @@ public class AcquisitionDialog extends PamDialog {
/** /**
* *
* @return the number of channels * @return the number of channels
*/ */
int getNumChannels() { int getNumChannels() {
try { try {
return Integer.valueOf(nChannels.getText()); return Integer.valueOf(nChannels.getText());
} }
@ -616,7 +618,7 @@ public class AcquisitionDialog extends PamDialog {
} }
} }
private void sortChannelLists() { private void sortChannelLists() {
// first of all, only show the ones in range of nPanels // first of all, only show the ones in range of nPanels
if (currentChannelListPanel != null) { if (currentChannelListPanel != null) {
currentChannelListPanel.setNumChannels(getNumChannels()); currentChannelListPanel.setNumChannels(getNumChannels());
@ -624,64 +626,64 @@ public class AcquisitionDialog extends PamDialog {
pack(); pack();
} }
/** /**
* Called when the device type changes. Loads the appropriate panel for * Called when the device type changes. Loads the appropriate panel for
* the newly selected DaqSystem into the dialog * the newly selected DaqSystem into the dialog
* *
*/ */
private void newDeviceType() { private void newDeviceType() {
int devNumber = deviceType.getSelectedIndex(); int devNumber = deviceType.getSelectedIndex();
if (devNumber < 0) return; if (devNumber < 0) return;
// remove the old type specific panel and replace it with a new one. // remove the old type specific panel and replace it with a new one.
if (deviceSpecificPanel != null) { if (deviceSpecificPanel != null) {
mainPanel.remove(deviceSpecificPanel); mainPanel.remove(deviceSpecificPanel);
} }
currentDaqSystem = acquisitionControl.systemList.get(devNumber); currentDaqSystem = acquisitionControl.systemList.get(devNumber);
deviceSpecificPanel = currentDaqSystem.getDaqSpecificDialogComponent(this); deviceSpecificPanel = currentDaqSystem.getDaqSpecificDialogComponent(this);
if (deviceSpecificPanel != null) { if (deviceSpecificPanel != null) {
mainPanel.add(deviceSpecificPanel, 1); mainPanel.add(deviceSpecificPanel, 1);
currentDaqSystem.dialogSetParams(); currentDaqSystem.dialogSetParams();
} }
sampleRate.setEnabled(currentDaqSystem.getMaxSampleRate() != DaqSystem.PARAMETER_FIXED); sampleRate.setEnabled(currentDaqSystem.getMaxSampleRate() != DaqSystem.PARAMETER_FIXED);
nChannels.setEnabled(currentDaqSystem.getMaxChannels() != DaqSystem.PARAMETER_FIXED); nChannels.setEnabled(currentDaqSystem.getMaxChannels() != DaqSystem.PARAMETER_FIXED);
vPeak2Peak.setEnabled(currentDaqSystem.getPeak2PeakVoltage(0) == DaqSystem.PARAMETER_UNKNOWN); vPeak2Peak.setEnabled(currentDaqSystem.getPeak2PeakVoltage(0) == DaqSystem.PARAMETER_UNKNOWN);
showHideChannelPanel(); showHideChannelPanel();
if (currentChannelListPanel != null) { if (currentChannelListPanel != null) {
currentChannelListPanel.setNumChannels(getNumChannels()); currentChannelListPanel.setNumChannels(getNumChannels());
currentChannelListPanel.setParams(acquisitionParameters.getHardwareChannelList()); currentChannelListPanel.setParams(acquisitionParameters.getHardwareChannelList());
} }
pack(); pack();
} }
public DaqSystem getCurrentDaqSystem() { public DaqSystem getCurrentDaqSystem() {
return currentDaqSystem; return currentDaqSystem;
} }
/** /**
* *
* @return the sample rate component * @return the sample rate component
*/ */
public JTextField getSampleRateComponent() { public JTextField getSampleRateComponent() {
return sampleRate; return sampleRate;
} }
/** /**
* *
* @return the nChannels component. * @return the nChannels component.
*/ */
public JTextField getnChanComponent() { public JTextField getnChanComponent() {
return nChannels; return nChannels;
} }
} }

View File

@ -1,20 +1,16 @@
package Acquisition; package Acquisition;
import java.sql.Types;
import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit;
import generalDatabase.PamTableDefinition; import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem; import generalDatabase.PamTableItem;
import generalDatabase.SQLLogging; import generalDatabase.SQLLogging;
import generalDatabase.SQLTypes; import generalDatabase.SQLTypes;
import java.sql.Types;
import PamUtils.PamCalendar;
import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit;
import PamguardMVC.debug.Debug;
import clickTrainDetector.CTDataUnit;
/** /**
* Very simple concrete implementation of SQLLogging to log the starts * Very simple concrete implementation of SQLLogging to log the starts
* and stops of PAMGUARD in the database. * and stops of PAMGUARD in the database.
* @author Doug Gillespie * @author Doug Gillespie
* *
@ -22,16 +18,16 @@ import clickTrainDetector.CTDataUnit;
public class AcquisitionLogging extends SQLLogging { public class AcquisitionLogging extends SQLLogging {
AcquisitionControl acquisitionControl; AcquisitionControl acquisitionControl;
PamTableDefinition tableDef; PamTableDefinition tableDef;
PamTableItem adcClockTime, adcClockMillis, rawADCTime, status, reason, daqSystemType, sampleRate, nChannels, voltsPeak2Peak, PamTableItem adcClockTime, adcClockMillis, rawADCTime, status, reason, daqSystemType, sampleRate, nChannels, voltsPeak2Peak,
gain, duration, clockError, samples, gSamples, GPSPPSTime, serverTime, daqSystemName; gain, duration, clockError, samples, gSamples, GPSPPSTime, serverTime, daqSystemName;
public AcquisitionLogging(PamDataBlock pamDataBlock, AcquisitionControl acquisitionControl) { public AcquisitionLogging(PamDataBlock pamDataBlock, AcquisitionControl acquisitionControl) {
super(pamDataBlock); super(pamDataBlock);
this.acquisitionControl = acquisitionControl; this.acquisitionControl = acquisitionControl;
tableDef = new PamTableDefinition(pamDataBlock.getDataName(), UPDATE_POLICY_OVERWRITE); tableDef = new PamTableDefinition(pamDataBlock.getDataName(), UPDATE_POLICY_OVERWRITE);
tableDef.addTableItem(adcClockTime = new PamTableItem("ADC Clock", Types.TIMESTAMP, "Time based on PC clock and samples since last PC clock read")); tableDef.addTableItem(adcClockTime = new PamTableItem("ADC Clock", Types.TIMESTAMP, "Time based on PC clock and samples since last PC clock read"));
tableDef.addTableItem(adcClockMillis = new PamTableItem("ADC Clock millis", Types.INTEGER, "Millis for adcClockTime if not supported by database")); tableDef.addTableItem(adcClockMillis = new PamTableItem("ADC Clock millis", Types.INTEGER, "Millis for adcClockTime if not supported by database"));
@ -50,7 +46,7 @@ public class AcquisitionLogging extends SQLLogging {
tableDef.addTableItem(duration = new PamTableItem("duration", Types.DOUBLE, "Time since start in seconds")); tableDef.addTableItem(duration = new PamTableItem("duration", Types.DOUBLE, "Time since start in seconds"));
tableDef.addTableItem(clockError = new PamTableItem("clockError", Types.DOUBLE, "Clock error in milliseconds")); tableDef.addTableItem(clockError = new PamTableItem("clockError", Types.DOUBLE, "Clock error in milliseconds"));
tableDef.addTableItem(serverTime = new PamTableItem("Server Time", Types.TIMESTAMP, "Time taken from an Internet time server")); tableDef.addTableItem(serverTime = new PamTableItem("Server Time", Types.TIMESTAMP, "Time taken from an Internet time server"));
setTableDefinition(tableDef); setTableDefinition(tableDef);
} }
@ -68,8 +64,8 @@ public class AcquisitionLogging extends SQLLogging {
adcClockMillis.setValue((int)(ds.getAdcMilliseconds()%1000)); adcClockMillis.setValue((int)(ds.getAdcMilliseconds()%1000));
rawADCTime.setValue(sqlTypes.getTimeStamp(ds.getRawADCMillis())); rawADCTime.setValue(sqlTypes.getTimeStamp(ds.getRawADCMillis()));
long s = ds.getSamples(); long s = ds.getSamples();
gSamples.setValue((long)(s/1000000000)); gSamples.setValue(s/1000000000);
samples.setValue((long) (s%1000000000)); samples.setValue(s%1000000000);
Long gT = ds.getGpsPPSMilliseconds(); Long gT = ds.getGpsPPSMilliseconds();
if (gT == null) { if (gT == null) {
GPSPPSTime.setValue(null); GPSPPSTime.setValue(null);
@ -84,7 +80,7 @@ public class AcquisitionLogging extends SQLLogging {
sampleRate.setValue(ds.getSampleRate()); sampleRate.setValue(ds.getSampleRate());
nChannels.setValue(ds.getNChannels()); nChannels.setValue(ds.getNChannels());
voltsPeak2Peak.setValue(ds.getVoltsPeak2Peak()); voltsPeak2Peak.setValue(ds.getVoltsPeak2Peak());
gain.setValue((float) daqParameters.getPreamplifier().getGain()); gain.setValue((float) daqParameters.getPreamplifier().getGain());
duration.setValue(ds.getSampleDuration()); duration.setValue(ds.getSampleDuration());
clockError.setValue(ds.clockError); clockError.setValue(ds.clockError);
Long sTime = ds.getServerTime(); Long sTime = ds.getServerTime();
@ -95,55 +91,55 @@ public class AcquisitionLogging extends SQLLogging {
serverTime.setValue(sqlTypes.getTimeStamp(sTime)); serverTime.setValue(sqlTypes.getTimeStamp(sTime));
} }
} }
@Override @Override
protected DaqStatusDataUnit createDataUnit(SQLTypes sqlTypes, long timeMilliseconds, int databaseIndex) { protected DaqStatusDataUnit createDataUnit(SQLTypes sqlTypes, long timeMilliseconds, int databaseIndex) {
// Debug.out.println("DaqStatusDataUnit sql Logging: " + PamCalendar.formatDateTime(timeMilliseconds) + " ADC: " +adcClockTime.getDeblankedStringValue() + " Samples: " + samples.getLongValue()); // Debug.out.println("DaqStatusDataUnit sql Logging: " + PamCalendar.formatDateTime(timeMilliseconds) + " ADC: " +adcClockTime.getDeblankedStringValue() + " Samples: " + samples.getLongValue());
long adcClock ; long adcClock ;
if (adcClockTime.getDeblankedStringValue()!=null) { if (adcClockTime.getDeblankedStringValue()!=null) {
adcClock = SQLTypes.millisFromTimeStamp(adcClockTime.getValue()); adcClock = SQLTypes.millisFromTimeStamp(adcClockTime.getValue());
} }
else { else {
adcClock =-1; adcClock =-1;
} }
Long adcRawClock = SQLTypes.millisFromTimeStamp(rawADCTime.getValue()); Long adcRawClock = SQLTypes.millisFromTimeStamp(rawADCTime.getValue());
if (adcRawClock == null) { if (adcRawClock == null) {
adcRawClock = 0L; adcRawClock = 0L;
} }
//long adcClockMillisVal = adcClockMillis.getLongValue(); //long adcClockMillisVal = adcClockMillis.getLongValue();
long gpsPPSClock ; long gpsPPSClock ;
if (GPSPPSTime.getDeblankedStringValue()!=null) { if (GPSPPSTime.getDeblankedStringValue()!=null) {
gpsPPSClock = SQLTypes.millisFromTimeStamp(GPSPPSTime.getValue()); gpsPPSClock = SQLTypes.millisFromTimeStamp(GPSPPSTime.getValue());
} }
else { else {
gpsPPSClock=1; gpsPPSClock=1;
} }
Long samplesVal = samples.getLongValue(); Long samplesVal = samples.getLongValue();
String reasonVal = reason.getDeblankedStringValue();
String statusVal = status.getDeblankedStringValue();
double clockErrVal = clockError.getDoubleValue(); String reasonVal = reason.getDeblankedStringValue();
String statusVal = status.getDeblankedStringValue();
double clockErrVal = clockError.getDoubleValue();
double durationValue = duration.getDoubleValue(); double durationValue = duration.getDoubleValue();
String systemName = daqSystemName.getStringValue(); String systemName = daqSystemName.getStringValue();
// DaqStatusDataUnit(long timeMilliseconds, long adcMilliseconds, long samples, Long gpsPPSMillis, // DaqStatusDataUnit(long timeMilliseconds, long adcMilliseconds, long samples, Long gpsPPSMillis,
// String status, String reason, // String status, String reason,
// AcquisitionParameters daqParameters, double duration, double clockError) // AcquisitionParameters daqParameters, double duration, double clockError)
// Debug.out.println("DaqStatusDataUnit sql Logging: " + samplesVal); // Debug.out.println("DaqStatusDataUnit sql Logging: " + samplesVal);
DaqStatusDataUnit dataUnit = new DaqStatusDataUnit(timeMilliseconds, adcClock, adcRawClock, samplesVal, gpsPPSClock, DaqStatusDataUnit dataUnit = new DaqStatusDataUnit(timeMilliseconds, adcClock, adcRawClock, samplesVal, gpsPPSClock,
statusVal, reasonVal, null, systemName, durationValue, clockErrVal) ; statusVal, reasonVal, null, systemName, durationValue, clockErrVal) ;
return dataUnit; return dataUnit;
} }
} }

View File

@ -1,7 +1,5 @@
package Acquisition; package Acquisition;
import hfDaqCard.SmruDaqSystem;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -13,58 +11,59 @@ import PamModel.parametermanager.PamParameterSet;
import PamModel.parametermanager.PamParameterSet.ParameterSetType; import PamModel.parametermanager.PamParameterSet.ParameterSetType;
import PamModel.parametermanager.PrivatePamParameterData; import PamModel.parametermanager.PrivatePamParameterData;
import PamguardMVC.PamConstants; import PamguardMVC.PamConstants;
import hfDaqCard.SmruDaqSystem;
public class AcquisitionParameters implements Serializable, Cloneable, ManagedParameters { public class AcquisitionParameters implements Serializable, Cloneable, ManagedParameters {
static final long serialVersionUID = 2; static final long serialVersionUID = 2;
String daqSystemType = "Sound Card"; String daqSystemType = "Sound Card";
public float sampleRate = 48000; public float sampleRate = 48000;
public int nChannels = 2; public int nChannels = 2;
public double voltsPeak2Peak = 5; public double voltsPeak2Peak = 5;
private transient boolean isNetReceive; private transient boolean isNetReceive;
/** /**
* List of channels data are acquired from (not necessarily 0,1,2, etc.) * List of channels data are acquired from (not necessarily 0,1,2, etc.)
* With NI boards, this has become a pain since if multiple boards are * With NI boards, this has become a pain since if multiple boards are
* used, there may be repeats within this list. * used, there may be repeats within this list.
*/ */
private int channelList[];// = new int[PamConstants.MAX_CHANNELS]; //Xiao Yan Deng private int channelList[];// = new int[PamConstants.MAX_CHANNELS]; //Xiao Yan Deng
public Preamplifier preamplifier = new Preamplifier(0, new double[] {0, 20000}); public Preamplifier preamplifier = new Preamplifier(0, new double[] {0, 20000});
/** /**
* Hydrophone list is a short list of length equal to the number of channels, so if * Hydrophone list is a short list of length equal to the number of channels, so if
* your channel list does not start at zero, you have to first use the * your channel list does not start at zero, you have to first use the
* channelListIndexes before using this lookup table. * channelListIndexes before using this lookup table.
*/ */
private int[] hydrophoneList; private int[] hydrophoneList;
/** /**
* list of indexes for each hardware channel in channelList (i.e. opposite LUT) * list of indexes for each hardware channel in channelList (i.e. opposite LUT)
*/ */
transient int[] channelListIndexes; transient int[] channelListIndexes;
private PPSParameters ppsParameters; private PPSParameters ppsParameters;
public boolean subtractDC; public boolean subtractDC;
public double dcTimeConstant; // time constant for DC subtraction in seconds. public double dcTimeConstant; // time constant for DC subtraction in seconds.
public AcquisitionParameters() { public AcquisitionParameters() {
getHardwareChannelList(); // automatically create a channellist. getHardwareChannelList(); // automatically create a channellist.
/* /*
* this won't work since the constructor is only ever called for a new config, so if an old * this won't work since the constructor is only ever called for a new config, so if an old
* config is loaded, this will never be called. * config is loaded, this will never be called.
*/ */
isNetReceive = PamController.getInstance().getRunMode() == PamController.RUN_NETWORKRECEIVER; isNetReceive = PamController.getInstance().getRunMode() == PamController.RUN_NETWORKRECEIVER;
} }
@Override @Override
public AcquisitionParameters clone() { public AcquisitionParameters clone() {
try { try {
@ -106,7 +105,7 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
/** /**
* Gets a list of hydrophones from channel Indexes (not channel numbers) * Gets a list of hydrophones from channel Indexes (not channel numbers)
* @return list of hydrophones. * @return list of hydrophones.
*/ */
public int[] getHydrophoneList() { public int[] getHydrophoneList() {
if ((hydrophoneList == null || hydrophoneList.length < nChannels) && nChannels > 0) { if ((hydrophoneList == null || hydrophoneList.length < nChannels) && nChannels > 0) {
@ -119,15 +118,15 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
} }
/** /**
* Set a hydrophone list. * Set a hydrophone list.
* @param hydrophoneList * @param hydrophoneList
*/ */
public void setHydrophoneList(int[] hydrophoneList) { public void setHydrophoneList(int[] hydrophoneList) {
this.hydrophoneList = hydrophoneList; this.hydrophoneList = hydrophoneList;
} }
/** /**
* Gets a hydrophone number from a channel number (not channel index) * Gets a hydrophone number from a channel number (not channel index)
* @param channel software channel number * @param channel software channel number
* @return a specific hydrophone number from the selected array * @return a specific hydrophone number from the selected array
*/ */
@ -146,18 +145,15 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
if (channel < 0) { if (channel < 0) {
return channel; return channel;
} }
if (channelListIndexes.length <= channel) return -1;
// this line no longer needed now that software channels are alwasy 0,1,2,3 // this line no longer needed now that software channels are alwasy 0,1,2,3
// even if hardware channels are more random. // even if hardware channels are more random.
// channel = this.channelListIndexes[channel]; // channel = this.channelListIndexes[channel];
//channel = this.channelListIndexes[channel]; //channel = this.channelListIndexes[channel];
if (channel < 0) { if ((channelListIndexes.length <= channel) || (channel < 0) || (hydrophoneList.length <= channel)) return -1;
return -1;
}
if (hydrophoneList.length <= channel) return -1;
return hydrophoneList[channel]; return hydrophoneList[channel];
} }
public int getNChannels() { public int getNChannels() {
return nChannels; return nChannels;
} }
@ -165,7 +161,7 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
public void setNChannels(int channels) { public void setNChannels(int channels) {
nChannels = channels; nChannels = channels;
} }
public int[] getNChannelList(){ public int[] getNChannelList(){
return channelList; return channelList;
} }
@ -196,7 +192,7 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
/** /**
* Gets / creates a list of hardware channels used. <p> * Gets / creates a list of hardware channels used. <p>
* i.e. converts from channel indexes to channel numbers. * i.e. converts from channel indexes to channel numbers.
* @return List of channel numbers * @return List of channel numbers
*/ */
public int[] getHardwareChannelList() { public int[] getHardwareChannelList() {
@ -221,7 +217,7 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
this.channelList = channelList; this.channelList = channelList;
sortChannelListIndexes(); sortChannelListIndexes();
} }
public void setChannelList(int index, int channelNumber) { public void setChannelList(int index, int channelNumber) {
getHardwareChannelList(); getHardwareChannelList();
if (index >= channelList.length) { if (index >= channelList.length) {
@ -230,7 +226,7 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
channelList[index] = channelNumber; channelList[index] = channelNumber;
sortChannelListIndexes(); sortChannelListIndexes();
} }
/** /**
* Creates a default channel list 0,1,2,3,4 etc. * Creates a default channel list 0,1,2,3,4 etc.
*/ */
@ -241,19 +237,19 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
} }
sortChannelListIndexes(); sortChannelListIndexes();
} }
/** /**
* Gets the channel number for a particular channel index. * Gets the channel number for a particular channel index.
* @param index channel index * @param index channel index
* @return channel number * @return channel number
*/ */
public int getChannelList(int index) { public int getChannelList(int index) {
return getHardwareChannelList()[index]; return getHardwareChannelList()[index];
} }
/** /**
* Gets the complete list of channel indexes. * Gets the complete list of channel indexes.
* @return list of channel indexes. * @return list of channel indexes.
*/ */
public int[] getChannelListIndexes() { public int[] getChannelListIndexes() {
if (channelListIndexes == null) { if (channelListIndexes == null) {
@ -261,7 +257,7 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
} }
return channelListIndexes; return channelListIndexes;
} }
/** /**
* Sets the channel list indeces * Sets the channel list indeces
* @param channelListIndexes * @param channelListIndexes
@ -269,11 +265,11 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
public void setChannelListIndexes(int[] channelListIndexes) { public void setChannelListIndexes(int[] channelListIndexes) {
this.channelListIndexes = channelListIndexes; this.channelListIndexes = channelListIndexes;
} }
/** /**
* Gets the channel index for a particular hardware channel * Gets the channel index for a particular hardware channel
* @param channel * @param channel
* @return channel index or -1 if it doesn't exist. * @return channel index or -1 if it doesn't exist.
*/ */
public int getChannelListIndexes(int channel) { public int getChannelListIndexes(int channel) {
if (channelListIndexes == null) { if (channelListIndexes == null) {
@ -284,10 +280,10 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
} }
else return -1; else return -1;
} }
/** /**
* Creates a set of easily accessible channel indexes * Creates a set of easily accessible channel indexes
* which can be used to convert from channel numbers to * which can be used to convert from channel numbers to
* channel index e.g. used channel numbers might be 3 and 4 * channel index e.g. used channel numbers might be 3 and 4
* so the listIndexes will be {-1 -1 -1 0 1] * so the listIndexes will be {-1 -1 -1 0 1]
*/ */
@ -297,7 +293,7 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
for (int i = 0; i < nChannels; i++) { for (int i = 0; i < nChannels; i++) {
max = Math.max(max, channelList[i]); max = Math.max(max, channelList[i]);
} }
channelListIndexes = new int[max+1]; channelListIndexes = new int[max+1];
for (int i = 0; i < channelListIndexes.length; i++) { for (int i = 0; i < channelListIndexes.length; i++) {
channelListIndexes[i] = -1; channelListIndexes[i] = -1;

View File

@ -1,19 +1,13 @@
package Acquisition; package Acquisition;
import java.awt.Window;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import javax.swing.Timer; import javax.swing.Timer;
import Acquisition.gpstiming.PPSDetector; import Acquisition.gpstiming.PPSDetector;
import Acquisition.gpstiming.PPSParameters; import Acquisition.gpstiming.PPSParameters;
import Array.ArrayManager; import Array.ArrayManager;
import Array.Hydrophone;
import Array.PamArray; import Array.PamArray;
import Array.Preamplifier; import Array.Preamplifier;
import Filters.Filter; import Filters.Filter;
@ -23,40 +17,29 @@ import Filters.FilterType;
import Filters.IirfFilter; import Filters.IirfFilter;
import PamController.DataInputStore; import PamController.DataInputStore;
import PamController.InputStoreInfo; import PamController.InputStoreInfo;
import PamController.OfflineDataStore;
import PamController.PamControlledUnit;
import PamController.PamController; import PamController.PamController;
import PamController.fileprocessing.ReprocessManager;
import PamController.fileprocessing.StoreStatus;
import PamController.status.BaseProcessCheck; import PamController.status.BaseProcessCheck;
import PamController.status.ProcessCheck; import PamController.status.ProcessCheck;
import PamDetection.RawDataUnit; import PamDetection.RawDataUnit;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
import PamUtils.PamUtils; import PamUtils.PamUtils;
import PamUtils.time.ntp.PamNTPTime;
import PamUtils.time.ntp.PamNTPTimeException;
import PamguardMVC.PamConstants; import PamguardMVC.PamConstants;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;
import PamguardMVC.PamObservable; import PamguardMVC.PamObservable;
import PamguardMVC.PamObserver;
import PamguardMVC.PamProcess; import PamguardMVC.PamProcess;
import PamguardMVC.PamRawDataBlock; import PamguardMVC.PamRawDataBlock;
import PamguardMVC.RequestCancellationObject;
import PamguardMVC.dataOffline.OfflineDataLoadInfo; import PamguardMVC.dataOffline.OfflineDataLoadInfo;
import dataGram.DatagramManager;
import dataMap.OfflineDataMapPoint;
import pamScrollSystem.AbstractScrollManager; import pamScrollSystem.AbstractScrollManager;
import pamScrollSystem.ViewLoadObserver;
/** /**
* Data acquisition process for all types of input device. * Data acquisition process for all types of input device.
* This arranges the output data block and starts and stops the * This arranges the output data block and starts and stops the
* device in the detected DaqSystem. Each DaqSystem should * device in the detected DaqSystem. Each DaqSystem should
* operate a different thread to read the device / file and add its * operate a different thread to read the device / file and add its
* data to the volatile Vector newDataUnits. AcquisitonProcess will * data to the volatile Vector newDataUnits. AcquisitonProcess will
* poll newDataUnits on a timer and when new data is found, put that * poll newDataUnits on a timer and when new data is found, put that
* data into PamDataUnits and PamRawDataBlocks to be sent out for * data into PamDataUnits and PamRawDataBlocks to be sent out for
* processing. * processing.
* <p> * <p>
* @author Doug Gillespie * @author Doug Gillespie
@ -66,9 +49,9 @@ import pamScrollSystem.ViewLoadObserver;
* *
*/ */
public class AcquisitionProcess extends PamProcess { public class AcquisitionProcess extends PamProcess {
public static final int LASTDATA = 2; // don't use zero since need to see if no notification has been received. public static final int LASTDATA = 2; // don't use zero since need to see if no notification has been received.
public static final int FIRSTDATA = 1; public static final int FIRSTDATA = 1;
AcquisitionControl acquisitionControl; AcquisitionControl acquisitionControl;
@ -90,23 +73,23 @@ public class AcquisitionProcess extends PamProcess {
private volatile boolean bufferOverflow = false; private volatile boolean bufferOverflow = false;
private Timer restartTimer; private Timer restartTimer;
private Filter sampleRateErrorFilter; private Filter sampleRateErrorFilter;
private double totalExtraSamples; private double totalExtraSamples;
private DaqStatusDataUnit previousDaqStatus = null; private DaqStatusDataUnit previousDaqStatus = null;
private long millisecondSampleOffset; private long millisecondSampleOffset;
private AudioDataQueue newDataQueue = new AudioDataQueue(); private AudioDataQueue newDataQueue = new AudioDataQueue();
private final double sqrt2 = Math.sqrt(2.0); private final double sqrt2 = Math.sqrt(2.0);
private Object runingSynchObject = new Object(); private Object runingSynchObject = new Object();
private PPSDetector ppsDetector; private PPSDetector ppsDetector;
private DCFilter dcFilter; private DCFilter dcFilter;
protected AcquisitionProcess(AcquisitionControl acquisitionControl) { protected AcquisitionProcess(AcquisitionControl acquisitionControl) {
@ -116,16 +99,16 @@ public class AcquisitionProcess extends PamProcess {
acquisitionProcess = this; acquisitionProcess = this;
this.acquisitionControl = acquisitionControl; this.acquisitionControl = acquisitionControl;
ppsDetector = new PPSDetector(this); ppsDetector = new PPSDetector(this);
String name = String.format("Raw input data from %s", acquisitionControl.getUnitName()); String name = String.format("Raw input data from %s", acquisitionControl.getUnitName());
//addOutputDataBlock(rawDataBlock = new PamRawDataBlock(name, this, //addOutputDataBlock(rawDataBlock = new PamRawDataBlock(name, this,
// PamUtils.makeChannelMap(acquisitionControl.acquisitionParameters.nChannels), // PamUtils.makeChannelMap(acquisitionControl.acquisitionParameters.nChannels),
// acquisitionControl.acquisitionParameters.sampleRate)); // acquisitionControl.acquisitionParameters.sampleRate));
addOutputDataBlock(rawDataBlock = new PamRawDataBlock(name, this, addOutputDataBlock(rawDataBlock = new PamRawDataBlock(name, this,
PamUtils.makeChannelMap(acquisitionControl.acquisitionParameters.nChannels,acquisitionControl.acquisitionParameters.getHardwareChannelList()), PamUtils.makeChannelMap(acquisitionControl.acquisitionParameters.nChannels,acquisitionControl.acquisitionParameters.getHardwareChannelList()),
acquisitionControl.acquisitionParameters.sampleRate)); acquisitionControl.acquisitionParameters.sampleRate));
@ -134,11 +117,11 @@ public class AcquisitionProcess extends PamProcess {
// daqStatusDataBlock. // daqStatusDataBlock.
addOutputDataBlock(daqStatusDataBlock); addOutputDataBlock(daqStatusDataBlock);
daqStatusDataBlock.SetLogging(new AcquisitionLogging(daqStatusDataBlock, acquisitionControl)); daqStatusDataBlock.SetLogging(new AcquisitionLogging(daqStatusDataBlock, acquisitionControl));
/** /**
* We really don't wand the binary data source set for normal ops since it stops the data getting * We really don't wand the binary data source set for normal ops since it stops the data getting
* written to the database by default. When using certain Network receiver settings, they use binary * written to the database by default. When using certain Network receiver settings, they use binary
* type data, so do need it. this will therefore be configured from the network receiver when required. * type data, so do need it. this will therefore be configured from the network receiver when required.
*/ */
// daqStatusDataBlock.setBinaryDataSource(new DaqStatusBinaryStore(daqStatusDataBlock, acquisitionControl)); // daqStatusDataBlock.setBinaryDataSource(new DaqStatusBinaryStore(daqStatusDataBlock, acquisitionControl));
AbstractScrollManager.getScrollManager().addToSpecialDatablock(daqStatusDataBlock); AbstractScrollManager.getScrollManager().addToSpecialDatablock(daqStatusDataBlock);
@ -151,14 +134,14 @@ public class AcquisitionProcess extends PamProcess {
// stallCheckTimer = new Timer(60000, new StallCheckAction()); // stallCheckTimer = new Timer(60000, new StallCheckAction());
bufferTimer = new Timer(1000, new BufferTimerTest()); bufferTimer = new Timer(1000, new BufferTimerTest());
ProcessCheck pp = new BaseProcessCheck(this, null, 0, 10); ProcessCheck pp = new BaseProcessCheck(this, null, 0, 10);
setProcessCheck(pp); setProcessCheck(pp);
/** /**
* Make a filter to low pass filter the sample rate errors. these * Make a filter to low pass filter the sample rate errors. these
* will eventually get used to update / fix estimated RawDataunit milliseconds * will eventually get used to update / fix estimated RawDataunit milliseconds
* times based on the total sample offset compared to UTC. * times based on the total sample offset compared to UTC.
*/ */
FilterParams filterParams = new FilterParams(); FilterParams filterParams = new FilterParams();
filterParams.filterBand = FilterBand.LOWPASS; filterParams.filterBand = FilterBand.LOWPASS;
@ -205,27 +188,27 @@ public class AcquisitionProcess extends PamProcess {
// private long daqCheckInterval = 60 * 1000; // private long daqCheckInterval = 60 * 1000;
@Override @Override
public void pamStart() { public void pamStart() {
// called by PamController. Don't actually start if // called by PamController. Don't actually start if
// we're in network receive mode. // we're in network receive mode.
if (systemPrepared == false) return; if (!systemPrepared) return;
newDataQueue.clearList(); // clear this first to make sure nothing new comes in. newDataQueue.clearList(); // clear this first to make sure nothing new comes in.
// before starting, clear all old data // before starting, clear all old data
rawDataBlock.clearAll(); rawDataBlock.clearAll();
sampleRateErrorFilter.prepareFilter(); sampleRateErrorFilter.prepareFilter();
totalExtraSamples = 0; totalExtraSamples = 0;
millisecondSampleOffset = 0; millisecondSampleOffset = 0;
if (runningSystem == null) { if (runningSystem == null) {
return; return;
} }
boolean netRX = PamController.getInstance().getRunMode() == PamController.RUN_NETWORKRECEIVER; boolean netRX = PamController.getInstance().getRunMode() == PamController.RUN_NETWORKRECEIVER;
if (!netRX) { if (!netRX) {
if (runningSystem.startSystem(acquisitionControl) == false) return; if (!runningSystem.startSystem(acquisitionControl)) return;
} }
// Log a data unit asap to get the start time // Log a data unit asap to get the start time
long daqStartedTime = PamCalendar.getTimeInMillis(); long daqStartedTime = PamCalendar.getTimeInMillis();
@ -243,7 +226,7 @@ public class AcquisitionProcess extends PamProcess {
acquisitionControl.fillStatusBarText(); acquisitionControl.fillStatusBarText();
bufferTimer.start(); bufferTimer.start();
// stallCheckTimer.start(); // stallCheckTimer.start();
/** /**
@ -255,13 +238,13 @@ public class AcquisitionProcess extends PamProcess {
addServerTime(daqStatusDataUnit); addServerTime(daqStatusDataUnit);
daqStatusDataBlock.addPamData(daqStatusDataUnit); daqStatusDataBlock.addPamData(daqStatusDataUnit);
previousDaqStatus = daqStatusDataUnit; previousDaqStatus = daqStatusDataUnit;
/* /*
* All systems work in much the same way - set up a timer to look for new data which is * All systems work in much the same way - set up a timer to look for new data which is
* put there by a separate thread that gets the data from it's source. * put there by a separate thread that gets the data from it's source.
* *
*/ */
bufferOverflow = false; bufferOverflow = false;
// daqCheckTime = PamCalendar.getTimeInMillis(); // daqCheckTime = PamCalendar.getTimeInMillis();
if (!netRX) { if (!netRX) {
@ -270,9 +253,9 @@ public class AcquisitionProcess extends PamProcess {
t.start(); t.start();
} }
} }
private boolean addServerTime(DaqStatusDataUnit daqStatusDataUnit) { private boolean addServerTime(DaqStatusDataUnit daqStatusDataUnit) {
if (runningSystem.isRealTime() == false) { if (!runningSystem.isRealTime()) {
return false; return false;
} }
// PamNTPTime pamNTPTime = PamNTPTime.getInstance(); // PamNTPTime pamNTPTime = PamNTPTime.getInstance();
@ -301,7 +284,7 @@ public class AcquisitionProcess extends PamProcess {
// called by PamController. // called by PamController.
// stop the running system - not the selected system since // stop the running system - not the selected system since
// this may have changed // this may have changed
restartTimer.stop(); restartTimer.stop();
// stallCheckTimer.stop(); // stallCheckTimer.stop();
pamStop(""); pamStop("");
@ -316,15 +299,15 @@ public class AcquisitionProcess extends PamProcess {
// Boolean s = isStalled(); // Boolean s = isStalled();
//// System.out.printf("%s Stall state = %s\n", PamCalendar.formatDateTime(System.currentTimeMillis()), s.toString()); //// System.out.printf("%s Stall state = %s\n", PamCalendar.formatDateTime(System.currentTimeMillis()), s.toString());
// } // }
// //
// } // }
private long simpleSamplesToMilliseconds(long samples) { private long simpleSamplesToMilliseconds(long samples) {
return (long) (samples * 1000. / sampleRate) + PamCalendar.getSessionStartTime(); return (long) (samples * 1000. / sampleRate) + PamCalendar.getSessionStartTime();
} }
/** /**
* Periodic logging of ADC status into database. * Periodic logging of ADC status into database.
*/ */
private void logRunningStatus() { private void logRunningStatus() {
if (runningSystem == null) return; if (runningSystem == null) return;
@ -334,16 +317,16 @@ public class AcquisitionProcess extends PamProcess {
long adcMillis = this.absSamplesToMilliseconds(samplesRead); long adcMillis = this.absSamplesToMilliseconds(samplesRead);
long simpleTime= simpleSamplesToMilliseconds(samplesRead); long simpleTime= simpleSamplesToMilliseconds(samplesRead);
DaqStatusDataUnit ds = new DaqStatusDataUnit(PamCalendar.getTimeInMillis(), adcMillis, simpleTime, DaqStatusDataUnit ds = new DaqStatusDataUnit(PamCalendar.getTimeInMillis(), adcMillis, simpleTime,
samplesRead, null, "Continue", "", samplesRead, null, "Continue", "",
acquisitionControl.acquisitionParameters, runningSystem.getSystemName(), duration, clockError); acquisitionControl.acquisitionParameters, runningSystem.getSystemName(), duration, clockError);
addServerTime(ds); addServerTime(ds);
if (runningSystem.isRealTime()) { if (runningSystem.isRealTime()) {
long pcTime = PamCalendar.getTimeInMillis(); // time hopefully corrected from NTP or GPs. long pcTime = PamCalendar.getTimeInMillis(); // time hopefully corrected from NTP or GPs.
millisecondSampleOffset = (long) sampleRateErrorFilter.runFilter(pcTime-simpleTime); millisecondSampleOffset = (long) sampleRateErrorFilter.runFilter(pcTime-simpleTime);
} }
// System.out.printf("Current ADC clock correction at %s %d millis\n" , PamCalendar.formatDateTime(pcTime), millisecondSampleOffset); // System.out.printf("Current ADC clock correction at %s %d millis\n" , PamCalendar.formatDateTime(pcTime), millisecondSampleOffset);
// System.out.printf("Sample rate estimated at %s, %dMSamples = %7.2fHz, filtered err %3.1fHz, TotExtraSamples = %3.1f, offest %d mills\n", // System.out.printf("Sample rate estimated at %s, %dMSamples = %7.2fHz, filtered err %3.1fHz, TotExtraSamples = %3.1f, offest %d mills\n",
// PamCalendar.formatDateTime(ds.getTimeMilliseconds()), samplesRead/1000000, estSampleRate, filteredEstSampleRateError, totalExtraSamples, millisecondSampleOffset); // PamCalendar.formatDateTime(ds.getTimeMilliseconds()), samplesRead/1000000, estSampleRate, filteredEstSampleRateError, totalExtraSamples, millisecondSampleOffset);
// if (previousDaqStatus != null) { // if (previousDaqStatus != null) {
//// Double trueSampleRate = ds.calculateTrueSampleRate(previousDaqStatus); //// Double trueSampleRate = ds.calculateTrueSampleRate(previousDaqStatus);
@ -353,14 +336,14 @@ public class AcquisitionProcess extends PamProcess {
// totalExtraSamples += extExtraSamples; // totalExtraSamples += extExtraSamples;
// millisecondSampleOffset = (long) (totalExtraSamples / getSampleRate() * 1000.); // millisecondSampleOffset = (long) (totalExtraSamples / getSampleRate() * 1000.);
// /* // /*
// * Extra samples +ve means that more samples have arrived than we expected. Therefore the estimate of the // * Extra samples +ve means that more samples have arrived than we expected. Therefore the estimate of the
// * UTC of the next RawDataunit is going to be too high, so we'll need to subtract off the millisecondSampleOffset // * UTC of the next RawDataunit is going to be too high, so we'll need to subtract off the millisecondSampleOffset
// * when we create a raw data unit. // * when we create a raw data unit.
// */ // */
//// if (trueSampleRate != null) { //// if (trueSampleRate != null) {
// System.out.printf("Sample rate estimated at %s, %dMSamples = %7.2fHz, filtered err %3.1fHz, TotExtraSamples = %3.1f, offest %d mills\n", // System.out.printf("Sample rate estimated at %s, %dMSamples = %7.2fHz, filtered err %3.1fHz, TotExtraSamples = %3.1f, offest %d mills\n",
// PamCalendar.formatDateTime(ds.getTimeMilliseconds()), samplesRead/1000000, estSampleRate, filteredEstSampleRateError, totalExtraSamples, millisecondSampleOffset); // PamCalendar.formatDateTime(ds.getTimeMilliseconds()), samplesRead/1000000, estSampleRate, filteredEstSampleRateError, totalExtraSamples, millisecondSampleOffset);
// //
//// } //// }
// } // }
daqStatusDataBlock.addPamData(ds); daqStatusDataBlock.addPamData(ds);
@ -376,11 +359,11 @@ public class AcquisitionProcess extends PamProcess {
long adcMillis = this.absSamplesToMilliseconds(samplesRead); long adcMillis = this.absSamplesToMilliseconds(samplesRead);
long simpleMillis = this.simpleSamplesToMilliseconds(samplesRead); long simpleMillis = this.simpleSamplesToMilliseconds(samplesRead);
DaqStatusDataUnit ds = new DaqStatusDataUnit(PamCalendar.getTimeInMillis(), adcMillis, simpleMillis, DaqStatusDataUnit ds = new DaqStatusDataUnit(PamCalendar.getTimeInMillis(), adcMillis, simpleMillis,
samplesRead, null, "Stop", reason, samplesRead, null, "Stop", reason,
acquisitionControl.acquisitionParameters, runningSystem.getSystemName(), duration, clockError); acquisitionControl.acquisitionParameters, runningSystem.getSystemName(), duration, clockError);
addServerTime(ds); addServerTime(ds);
daqStatusDataBlock.addPamData(ds); daqStatusDataBlock.addPamData(ds);
runningSystem.stopSystem(acquisitionControl); runningSystem.stopSystem(acquisitionControl);
keepRunning = false; keepRunning = false;
@ -397,19 +380,19 @@ public class AcquisitionProcess extends PamProcess {
double duration = (double) edgeSample / getSampleRate(); double duration = (double) edgeSample / getSampleRate();
double clockError = checkClockSpeed(edgeSample, 0); double clockError = checkClockSpeed(edgeSample, 0);
DaqStatusDataUnit ds = new DaqStatusDataUnit(timeNow, adcMillis, simpleMillis, DaqStatusDataUnit ds = new DaqStatusDataUnit(timeNow, adcMillis, simpleMillis,
edgeSample, gpsUTC, "GPSPPS", "", edgeSample, gpsUTC, "GPSPPS", "",
acquisitionControl.acquisitionParameters, runningSystem.getSystemName(), duration, clockError); acquisitionControl.acquisitionParameters, runningSystem.getSystemName(), duration, clockError);
ds.setServerTime(serverTime); ds.setServerTime(serverTime);
daqStatusDataBlock.addPamData(ds); daqStatusDataBlock.addPamData(ds);
} }
public void acquisitionStopped() { public void acquisitionStopped() {
/* /*
* can get called by a DaqSystem thread just as it exits to * can get called by a DaqSystem thread just as it exits to
* say that DAQ has stopped. Only needs to be implemented for things * say that DAQ has stopped. Only needs to be implemented for things
* like files which will stop themselves. Can also be implemented for * like files which will stop themselves. Can also be implemented for
* other devices which might stop accidentally (e.g. UDP sources) * other devices which might stop accidentally (e.g. UDP sources)
*/ */
@ -427,9 +410,9 @@ public class AcquisitionProcess extends PamProcess {
} }
} }
// call acquireData one last time to make sure that // call acquireData one last time to make sure that
// all data have been flushed from the buffer. // all data have been flushed from the buffer.
if (bufferOverflow == false) { if (!bufferOverflow) {
acquireData(); acquireData();
} }
else { else {
@ -441,7 +424,7 @@ public class AcquisitionProcess extends PamProcess {
/* /*
* runningSystem needs to be set null here since the call to PamController.PamStop() * runningSystem needs to be set null here since the call to PamController.PamStop()
* will call back to pamStop and we'll get an infinite loop ! * will call back to pamStop and we'll get an infinite loop !
* Synch on runingSynchObject to stop crash during shut down of system. * Synch on runingSynchObject to stop crash during shut down of system.
*/ */
synchronized(runingSynchObject) { synchronized(runingSynchObject) {
runningSystem = null; runningSystem = null;
@ -459,21 +442,21 @@ public class AcquisitionProcess extends PamProcess {
// PamController.pamStop will wait for that to happen, so if we call pamStop // PamController.pamStop will wait for that to happen, so if we call pamStop
// first it will hang. // first it will hang.
sendSourceNotification(LASTDATA, null); sendSourceNotification(LASTDATA, null);
// stop all controlled units // stop all controlled units
// 2021-05-14 removed - not sure why this is here, and it's just causing PamController.pamStop to get called twice // 2021-05-14 removed - not sure why this is here, and it's just causing PamController.pamStop to get called twice
// acquisitionControl.pamController.pamStop(); // acquisitionControl.pamController.pamStop();
} }
/** /**
* Called from AcquisitionControl when all observer thread data queues * Called from AcquisitionControl when all observer thread data queues
* have been emptied and processing has stopped * have been emptied and processing has stopped
*/ */
protected void pamHasStopped() { protected void pamHasStopped() {
newDataQueue.clearList(); // clear this first to make sure nothing new comes in. newDataQueue.clearList(); // clear this first to make sure nothing new comes in.
if (runningSystem == null){ if (runningSystem == null){
runningSystem = acquisitionControl.findDaqSystem(null); runningSystem = acquisitionControl.findDaqSystem(null);
} }
@ -481,12 +464,12 @@ public class AcquisitionProcess extends PamProcess {
runningSystem.daqHasEnded(); runningSystem.daqHasEnded();
} }
} }
/** /**
* Let all observers of the raw data know that the daq status has changed. Right now, * Let all observers of the raw data know that the daq status has changed. Right now,
* this is intended to let everyone know that the Daq has started or stopped, so that * this is intended to let everyone know that the Daq has started or stopped, so that
* the various threads can clean themselves up. * the various threads can clean themselves up.
* *
* @param type the type of change (see global fields at the top of this class) * @param type the type of change (see global fields at the top of this class)
* @param object (null for now, but added in case we need to pass something later) * @param object (null for now, but added in case we need to pass something later)
*/ */
@ -496,7 +479,7 @@ public class AcquisitionProcess extends PamProcess {
rawDataBlock.getPamObserver(i).receiveSourceNotification(type, object); rawDataBlock.getPamObserver(i).receiveSourceNotification(type, object);
} }
} }
@Override @Override
public boolean prepareProcessOK() { public boolean prepareProcessOK() {
super.prepareProcessOK(); super.prepareProcessOK();
@ -512,9 +495,9 @@ public class AcquisitionProcess extends PamProcess {
lastStallCheckTime = 0; lastStallCheckTime = 0;
lastStallCheckSamples = 0; lastStallCheckSamples = 0;
lastStallState = false; lastStallState = false;
if (acquisitionControl.acquisitionParameters.subtractDC) { if (acquisitionControl.acquisitionParameters.subtractDC) {
dcFilter = new DCFilter(acquisitionControl.acquisitionParameters.sampleRate, dcFilter = new DCFilter(acquisitionControl.acquisitionParameters.sampleRate,
acquisitionControl.acquisitionParameters.dcTimeConstant, PamConstants.MAX_CHANNELS); acquisitionControl.acquisitionParameters.dcTimeConstant, PamConstants.MAX_CHANNELS);
} }
else { else {
@ -524,20 +507,20 @@ public class AcquisitionProcess extends PamProcess {
setSampleRate(acquisitionControl.acquisitionParameters.sampleRate, true); setSampleRate(acquisitionControl.acquisitionParameters.sampleRate, true);
super.prepareProcess(); super.prepareProcess();
ppsDetector.prepare(acquisitionControl.acquisitionParameters); ppsDetector.prepare(acquisitionControl.acquisitionParameters);
if (runningSystem != null) { if (runningSystem != null) {
pamStop(); pamStop();
} }
dataBlockLength = -1; dataBlockLength = -1;
runningSystem = acquisitionControl.findDaqSystem(null); runningSystem = acquisitionControl.findDaqSystem(null);
if (runningSystem == null) { if (runningSystem == null) {
System.out.printf("Unable to find daq system %s\n", acquisitionControl.acquisitionParameters.daqSystemType); System.out.printf("Unable to find daq system %s\n", acquisitionControl.acquisitionParameters.daqSystemType);
return; return;
} }
systemPrepared = runningSystem.prepareSystem(acquisitionControl); systemPrepared = runningSystem.prepareSystem(acquisitionControl);
} }
@ -559,7 +542,7 @@ public class AcquisitionProcess extends PamProcess {
/** /**
* Set up channels when using a channel list - note * Set up channels when using a channel list - note
* that hardware channels are no longer passed through the system * that hardware channels are no longer passed through the system
* so software channels are now used throughout. * so software channels are now used throughout.
* @param numChannels * @param numChannels
* @param channelList * @param channelList
*/ */
@ -567,7 +550,7 @@ public class AcquisitionProcess extends PamProcess {
acquisitionControl.acquisitionParameters.nChannels = numChannels; acquisitionControl.acquisitionParameters.nChannels = numChannels;
acquisitionControl.acquisitionParameters.setChannelList(channelList); acquisitionControl.acquisitionParameters.setChannelList(channelList);
rawDataBlock.setChannelMap(PamUtils.makeChannelMap(numChannels)); rawDataBlock.setChannelMap(PamUtils.makeChannelMap(numChannels));
// rawDataBlock.setChannelMap(PamUtils.makeChannelMap(numChannels, channelList)); // rawDataBlock.setChannelMap(PamUtils.makeChannelMap(numChannels, channelList));
} }
/* /*
@ -585,6 +568,7 @@ public class AcquisitionProcess extends PamProcess {
class BufferTimerTest implements ActionListener { class BufferTimerTest implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
acquisitionControl.fillStatusBarText(); acquisitionControl.fillStatusBarText();
@ -609,7 +593,7 @@ public class AcquisitionProcess extends PamProcess {
e.printStackTrace(); e.printStackTrace();
} }
if (acquireData() == false) { if (!acquireData()) {
break; break;
} }
} }
@ -641,12 +625,13 @@ public class AcquisitionProcess extends PamProcess {
/** /**
* Used to restart after a buffer overflow. * Used to restart after a buffer overflow.
* @author Doug Gillespie * @author Doug Gillespie
* *
*/ */
class RestartTimerFunction implements ActionListener { class RestartTimerFunction implements ActionListener {
@Override
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
System.out.println("PAMGUARD cannot process data at the required rate and is restarting"); System.out.println("PAMGUARD cannot process data at the required rate and is restarting");
@ -675,8 +660,8 @@ public class AcquisitionProcess extends PamProcess {
int channel = PamUtils.getSingleChannel(threadDataUnit.getChannelBitmap()); int channel = PamUtils.getSingleChannel(threadDataUnit.getChannelBitmap());
// long unitMillis = absSamplesToMilliseconds(threadDataUnit.getStartSample()) - millisecondSampleOffset; // long unitMillis = absSamplesToMilliseconds(threadDataUnit.getStartSample()) - millisecondSampleOffset;
long unitMillis = (long) simpleSamplesToMilliseconds(threadDataUnit.getStartSample()) + millisecondSampleOffset; long unitMillis = simpleSamplesToMilliseconds(threadDataUnit.getStartSample()) + millisecondSampleOffset;
newDataUnit = new RawDataUnit(unitMillis, newDataUnit = new RawDataUnit(unitMillis,
threadDataUnit.getChannelBitmap(), threadDataUnit.getStartSample(), threadDataUnit.getChannelBitmap(), threadDataUnit.getStartSample(),
threadDataUnit.getSampleDuration()); threadDataUnit.getSampleDuration());
if (dcFilter != null) { if (dcFilter != null) {
@ -688,23 +673,23 @@ public class AcquisitionProcess extends PamProcess {
// calculated in the call to setRawData, to dB. // calculated in the call to setRawData, to dB.
newDataUnit.setCalculatedAmlitudeDB(rawAmplitude2dB(newDataUnit.getMeasuredAmplitude(), newDataUnit.setCalculatedAmlitudeDB(rawAmplitude2dB(newDataUnit.getMeasuredAmplitude(),
PamUtils.getSingleChannel(threadDataUnit.getChannelBitmap()), false)); PamUtils.getSingleChannel(threadDataUnit.getChannelBitmap()), false));
PPSParameters ppsParams = acquisitionControl.acquisitionParameters.getPpsParameters(); PPSParameters ppsParams = acquisitionControl.acquisitionParameters.getPpsParameters();
if (ppsParams.useGpsPPS & newDataUnit.getChannelBitmap() == 1<<ppsParams.gpsPPSChannel){ if (ppsParams.useGpsPPS & newDataUnit.getChannelBitmap() == 1<<ppsParams.gpsPPSChannel){
ppsDetector.newData(newDataUnit); ppsDetector.newData(newDataUnit);
} }
addData(null, newDataUnit); addData(null, newDataUnit);
rawData = newDataUnit.getRawData(); rawData = newDataUnit.getRawData();
dataBlockLength = rawData.length; dataBlockLength = rawData.length;
for (int i = 0; i < rawData.length; i++) { for (double element : rawData) {
maxLevel = Math.max(maxLevel, Math.abs(rawData[i])); maxLevel = Math.max(maxLevel, Math.abs(element));
} }
levelSamples += rawData.length; levelSamples += rawData.length;
if (bufferOverflow) { if (bufferOverflow) {
break; break;
} }
if (threadDataUnit.getChannelBitmap() == 1<<(acquisitionControl.getAcquisitionParameters().nChannels-1) && if (threadDataUnit.getChannelBitmap() == 1<<(acquisitionControl.getAcquisitionParameters().nChannels-1) &&
threadDataUnit.getTimeMilliseconds() - lastStatusTime > statusInterval) { threadDataUnit.getTimeMilliseconds() - lastStatusTime > statusInterval) {
logRunningStatus(); logRunningStatus();
@ -726,39 +711,39 @@ public class AcquisitionProcess extends PamProcess {
// * buffer with a 10s maximum // * buffer with a 10s maximum
// */ // */
// if (needRestart() && finalFlush == false) { // if (needRestart() && finalFlush == false) {
// //
// System.out.println(PamCalendar.formatDateTime(System.currentTimeMillis()) + // System.out.println(PamCalendar.formatDateTime(System.currentTimeMillis()) +
// " : Emergency sound system restart due to buffer overflow"); // " : Emergency sound system restart due to buffer overflow");
// pamStop("Buffer overflow in sound system"); // pamStop("Buffer overflow in sound system");
// //
// newDataUnits.clear(); // newDataUnits.clear();
// //
// acquisitionStopped(); // acquisitionStopped();
// //
// restartTimer.start(); // restartTimer.start();
// //
// return; // return;
// } // }
// //
// long now = PamCalendar.getTimeInMillis(); // long now = PamCalendar.getTimeInMillis();
// if (now - daqCheckTime >= daqCheckInterval) { // if (now - daqCheckTime >= daqCheckInterval) {
// double duration = (double) totalSamples[0] / getSampleRate(); // double duration = (double) totalSamples[0] / getSampleRate();
// double clockError = checkClockSpeed(totalSamples[0], 1); // double clockError = checkClockSpeed(totalSamples[0], 1);
// DaqStatusDataUnit ds = new DaqStatusDataUnit(PamCalendar.getTimeInMillis(), "Continue", "Check", // DaqStatusDataUnit ds = new DaqStatusDataUnit(PamCalendar.getTimeInMillis(), "Continue", "Check",
// runningSystem.getSystemName(), getSampleRate(), acquisitionControl.acquisitionParameters.nChannels, // runningSystem.getSystemName(), getSampleRate(), acquisitionControl.acquisitionParameters.nChannels,
// acquisitionControl.acquisitionParameters.voltsPeak2Peak, duration, clockError); // acquisitionControl.acquisitionParameters.voltsPeak2Peak, duration, clockError);
// daqStatusDataBlock.addPamData(ds); // daqStatusDataBlock.addPamData(ds);
// daqCheckTime = now; // daqCheckTime = now;
// } // }
// //
// /* // /*
// * The blocks should be in pairs, so there should generally // * The blocks should be in pairs, so there should generally
// * be two blocks there every time this gets called. Adjust timing // * be two blocks there every time this gets called. Adjust timing
// * automatically to deal with just about any data rate. Start at a low // * automatically to deal with just about any data rate. Start at a low
// * value though since file reading only adds blocks if there are none // * value though since file reading only adds blocks if there are none
// * there - so would never reduce the delay ! // * there - so would never reduce the delay !
// * // *
// * Don't do this if it isn't a real time process since we want to // * Don't do this if it isn't a real time process since we want to
// * keep going as fast as possible // * keep going as fast as possible
// */ // */
//// trials++; //// trials++;
@ -766,25 +751,25 @@ public class AcquisitionProcess extends PamProcess {
//// if (trials == 15 || counts >= 40) { //// if (trials == 15 || counts >= 40) {
//// if (trials > counts * 3) { //// if (trials > counts * 3) {
//// daqTimer.setDelay(Math.max(10,daqTimer.getDelay() * 5 / 4)); //// daqTimer.setDelay(Math.max(10,daqTimer.getDelay() * 5 / 4));
//// System.out.println("Increasing timer delay to " + daqTimer.getDelay() + " ms"); //// System.out.println("Increasing timer delay to " + daqTimer.getDelay() + " ms");
//// } //// }
//// else if (counts > trials * 2) { //// else if (counts > trials * 2) {
//// daqTimer.setDelay(Math.max(1,daqTimer.getDelay() * 2 / 3)); //// daqTimer.setDelay(Math.max(1,daqTimer.getDelay() * 2 / 3));
//// System.out.println("Reducing timer delay to " + daqTimer.getDelay() + " ms"); //// System.out.println("Reducing timer delay to " + daqTimer.getDelay() + " ms");
//// } //// }
//// trials = counts = 0; //// trials = counts = 0;
//// } //// }
// } // }
// //
// RawDataUnit newDataUnit, threadDataUnit; // RawDataUnit newDataUnit, threadDataUnit;
// //
// int readCount = 0; // int readCount = 0;
// while (!newDataUnits.isEmpty()) { // while (!newDataUnits.isEmpty()) {
// //
// threadDataUnit = newDataUnits.remove(0); // threadDataUnit = newDataUnits.remove(0);
// //
// int channel = PamUtils.getSingleChannel(threadDataUnit.getChannelBitmap()); // int channel = PamUtils.getSingleChannel(threadDataUnit.getChannelBitmap());
// newDataUnit = new RawDataUnit(absSamplesToMilliseconds(threadDataUnit.getStartSample()), // newDataUnit = new RawDataUnit(absSamplesToMilliseconds(threadDataUnit.getStartSample()),
// threadDataUnit.getChannelBitmap(), threadDataUnit.getStartSample(), // threadDataUnit.getChannelBitmap(), threadDataUnit.getStartSample(),
// threadDataUnit.getDuration()); // threadDataUnit.getDuration());
// newDataUnit.setRawData(threadDataUnit.getRawData(), true); // newDataUnit.setRawData(threadDataUnit.getRawData(), true);
@ -800,13 +785,13 @@ public class AcquisitionProcess extends PamProcess {
// maxLevel = Math.max(maxLevel, Math.abs(rawData[i])); // maxLevel = Math.max(maxLevel, Math.abs(rawData[i]));
// } // }
// levelSamples += rawData.length; // levelSamples += rawData.length;
// //
// //
// // about every 5 seconds, check the buffer isn't filling // // about every 5 seconds, check the buffer isn't filling
// if (newDataUnit.getAbsBlockIndex() % (50 * acquisitionControl.acquisitionParameters.nChannels) == 0) { // if (newDataUnit.getAbsBlockIndex() % (50 * acquisitionControl.acquisitionParameters.nChannels) == 0) {
// double buffer = getBufferEstimate(newDataUnit.getStartSample() + newDataUnit.getDuration()); // double buffer = getBufferEstimate(newDataUnit.getStartSample() + newDataUnit.getDuration());
// if (buffer > 3) { // if (buffer > 3) {
// System.out.println(PamCalendar.formatDateTime(System.currentTimeMillis()) + // System.out.println(PamCalendar.formatDateTime(System.currentTimeMillis()) +
// " : Emergency sound system restart due to Buffer overflow type 2"); // " : Emergency sound system restart due to Buffer overflow type 2");
// pamStop("Type 2 Buffer overflow in sound system"); // pamStop("Type 2 Buffer overflow in sound system");
// //
@ -819,7 +804,7 @@ public class AcquisitionProcess extends PamProcess {
// return; // return;
// } // }
// } // }
// //
// // about every minute, or every 1200 blocks, check the timing // // about every minute, or every 1200 blocks, check the timing
// if ((newDataUnit.getAbsBlockIndex()+1) % (600 * acquisitionControl.acquisitionParameters.nChannels) == 0) { // if ((newDataUnit.getAbsBlockIndex()+1) % (600 * acquisitionControl.acquisitionParameters.nChannels) == 0) {
// checkClockSpeed(newDataUnit.getStartSample() + newDataUnit.getDuration(), 1); // checkClockSpeed(newDataUnit.getStartSample() + newDataUnit.getDuration(), 1);
@ -829,7 +814,7 @@ public class AcquisitionProcess extends PamProcess {
// if (++readCount >= acquisitionControl.acquisitionParameters.nChannels * 4 && finalFlush == false) { // if (++readCount >= acquisitionControl.acquisitionParameters.nChannels * 4 && finalFlush == false) {
// break; // break;
// } // }
// //
// } // }
// if (levelSamples >= sampleRate * acquisitionControl.acquisitionParameters.nChannels * 2) { // if (levelSamples >= sampleRate * acquisitionControl.acquisitionParameters.nChannels * 2) {
// acquisitionControl.setStatusBarLevel(maxLevel); // acquisitionControl.setStatusBarLevel(maxLevel);
@ -854,7 +839,7 @@ public class AcquisitionProcess extends PamProcess {
double soundCardError = (sampleSeconds - clockSeconds) / clockSeconds * 100; double soundCardError = (sampleSeconds - clockSeconds) / clockSeconds * 100;
int missingSamples = (int) ((sampleSeconds - clockSeconds) * getSampleRate()); int missingSamples = (int) ((sampleSeconds - clockSeconds) * getSampleRate());
// if (print >= 2 || (print >= 1 && shouldPrintSoundCardError(soundCardError))) { // if (print >= 2 || (print >= 1 && shouldPrintSoundCardError(soundCardError))) {
// System.out.println(String.format("%s at %3.2f%% PC clock speed after %d seconds (about %3.1f seconds or %d samples)", // System.out.println(String.format("%s at %3.2f%% PC clock speed after %d seconds (about %3.1f seconds or %d samples)",
// runningSystem.getSystemName(), soundCardError, (int)clockSeconds, (sampleSeconds - clockSeconds), missingSamples)); // runningSystem.getSystemName(), soundCardError, (int)clockSeconds, (sampleSeconds - clockSeconds), missingSamples));
// } // }
return soundCardError; return soundCardError;
@ -881,19 +866,19 @@ public class AcquisitionProcess extends PamProcess {
{ {
// if (newDataUnits == null) return 0; // if (newDataUnits == null) return 0;
// if (dataBlockLength <= 0) return 0; // if (dataBlockLength <= 0) return 0;
// double blocksPerSecond = getSampleRate() / dataBlockLength * // double blocksPerSecond = getSampleRate() / dataBlockLength *
// acquisitionControl.acquisitionParameters.nChannels; // acquisitionControl.acquisitionParameters.nChannels;
// return newDataUnits.size() / blocksPerSecond; // return newDataUnits.size() / blocksPerSecond;
return (double) newDataQueue.getQueuedSamples(0) / getSampleRate(); return (double) newDataQueue.getQueuedSamples(0) / getSampleRate();
} }
/** /**
* *
* @return the maximum number of seconds of data which can be buffered. * @return the maximum number of seconds of data which can be buffered.
* This used to be fixed at 3, but now that individual raw data blocks contain >> 1s * This used to be fixed at 3, but now that individual raw data blocks contain >> 1s
* of data for low frequency DAQ, this can be exceeded in a single * of data for low frequency DAQ, this can be exceeded in a single
* data unit, which causes continual resets. * data unit, which causes continual resets.
*/ */
public double getMaxBufferSeconds() { public double getMaxBufferSeconds() {
/** /**
@ -908,7 +893,7 @@ public class AcquisitionProcess extends PamProcess {
System.out.printf("Restart because %ss buffer > %ss maximum\n", getBufferSeconds(), getMaxBufferSeconds()); System.out.printf("Restart because %ss buffer > %ss maximum\n", getBufferSeconds(), getMaxBufferSeconds());
return true; return true;
} }
return false; return false;
} }
@Override @Override
@ -931,20 +916,20 @@ public class AcquisitionProcess extends PamProcess {
/** /**
* Convert a raw amplitude to dB re 1 micropascal based on * Convert a raw amplitude to dB re 1 micropascal based on
* calibration information held in the AcquisitionController * calibration information held in the AcquisitionController
* *
* @param rawAmplitude raw amplitude (should be -1 < rawAmplitude < 1) * @param rawAmplitude raw amplitude (should be -1 < rawAmplitude < 1)
* @return amplitude in dB re 1 uPa. * @return amplitude in dB re 1 uPa.
*/ */
public double rawAmplitude2dB(double rawAmplitude, int channel, boolean fast){ public double rawAmplitude2dB(double rawAmplitude, int channel, boolean fast){
channel = checkSingleChannel(channel); channel = checkSingleChannel(channel);
double constantTerm; double constantTerm;
if (fast && fixedAmplitudeConstantTerm[channel] != 0) { if (fast && fixedAmplitudeConstantTerm[channel] != 0) {
constantTerm = fixedAmplitudeConstantTerm[channel]; constantTerm = fixedAmplitudeConstantTerm[channel];
} }
else { else {
constantTerm = getAmplitudeConstantTerm(channel); constantTerm = getAmplitudeConstantTerm(channel);
} }
double vp2p = getPeak2PeakVoltage(channel); double vp2p = getPeak2PeakVoltage(channel);
@ -952,7 +937,7 @@ public class AcquisitionProcess extends PamProcess {
/* /*
* Need an extra divide by 2 in here since the standard scaling of PAMGUARD * Need an extra divide by 2 in here since the standard scaling of PAMGUARD
* data is -1 to +1, so data really needed to be scaled against half * data is -1 to +1, so data really needed to be scaled against half
* the peak to peak voltage. * the peak to peak voltage.
*/ */
double dB = 20 * Math.log10(rawAmplitude * vp2p / 2) - constantTerm; double dB = 20 * Math.log10(rawAmplitude * vp2p / 2) - constantTerm;
@ -964,15 +949,15 @@ public class AcquisitionProcess extends PamProcess {
} }
/** /**
* Check it's a single channel and not a channel map. * Check it's a single channel and not a channel map.
* This fundamentally messed up the amplitude calculations when the * This fundamentally messed up the amplitude calculations when the
* channels were > 2 since it was only taking the number of the lowest set * channels were > 2 since it was only taking the number of the lowest set
* bit. So if a genuine channel was sent, rather than a channel map with a * bit. So if a genuine channel was sent, rather than a channel map with a
* single set channel, it messed up. Have made this function redundant * single set channel, it messed up. Have made this function redundant
* and we need to be 100% sure that all amplitude calculations are sent a * and we need to be 100% sure that all amplitude calculations are sent a
* channel number not a bitmap with a single set channel. * channel number not a bitmap with a single set channel.
* @param channel * @param channel
* @return single channel if it seemed to be a bitmap. * @return single channel if it seemed to be a bitmap.
*/ */
private int checkSingleChannel(int channel) { private int checkSingleChannel(int channel) {
return channel; return channel;
@ -986,7 +971,7 @@ public class AcquisitionProcess extends PamProcess {
/** /**
* Some devices may be setting this per channel. * Some devices may be setting this per channel.
* @param swChannel software channel number * @param swChannel software channel number
* @return peak to peak voltage range. * @return peak to peak voltage range.
*/ */
public double getPeak2PeakVoltage(int swChannel) { public double getPeak2PeakVoltage(int swChannel) {
@ -1005,17 +990,17 @@ public class AcquisitionProcess extends PamProcess {
/** /**
* A Constant used for fast amplitude calculations when things * A Constant used for fast amplitude calculations when things
* like preamp gain will remain constant. Contains a constant * like preamp gain will remain constant. Contains a constant
* term in the SPL calculations bases on preamp gains and * term in the SPL calculations bases on preamp gains and
* hdrophone sensitivities. * hdrophone sensitivities.
* Changes to be channel specific since with multi threading it goes horribly * Changes to be channel specific since with multi threading it goes horribly
* wrong if different channels have different sensitivities. * wrong if different channels have different sensitivities.
*/ */
private double[] fixedAmplitudeConstantTerm = new double[PamConstants.MAX_CHANNELS]; private double[] fixedAmplitudeConstantTerm = new double[PamConstants.MAX_CHANNELS];
private DaqSystem ampSystem; private DaqSystem ampSystem;
/** /**
* Gets the fixedAmplitudeConstantTerm based on channel and hydrophone This is * Gets the fixedAmplitudeConstantTerm based on channel and hydrophone This is
* the hydrophone sensitivity + all gains + ADC sensitivity in counts / volt. * the hydrophone sensitivity + all gains + ADC sensitivity in counts / volt.
* @param channel = single software channel * @param channel = single software channel
* @return constant term for amplitude calculations * @return constant term for amplitude calculations
*/ */
@ -1027,7 +1012,7 @@ public class AcquisitionProcess extends PamProcess {
if (hydrophoneChannel < 0) hydrophoneChannel = 0; if (hydrophoneChannel < 0) hydrophoneChannel = 0;
// Hydrophone hydrophone = array.getHydrophone(hydrophoneChannel); // Hydrophone hydrophone = array.getHydrophone(hydrophoneChannel);
double hSens = array.getHydrophoneSensitivityAndGain(hydrophoneChannel); double hSens = array.getHydrophoneSensitivityAndGain(hydrophoneChannel);
Preamplifier preamp = acquisitionControl.acquisitionParameters.preamplifier; Preamplifier preamp = acquisitionControl.acquisitionParameters.preamplifier;
if (getRunningSystem() != null) { if (getRunningSystem() != null) {
ampSystem = getRunningSystem(); ampSystem = getRunningSystem();
@ -1037,14 +1022,14 @@ public class AcquisitionProcess extends PamProcess {
} }
double xtra = 0; double xtra = 0;
if (ampSystem != null) { if (ampSystem != null) {
xtra = ampSystem.getChannelGain(channel); xtra = ampSystem.getChannelGain(channel);
} }
return (hSens + preamp.getGain() + xtra); return (hSens + preamp.getGain() + xtra);
} }
/** /**
* Prepares for fast amplitude calculations * Prepares for fast amplitude calculations
* @param channel number i.e. 0 - 31, NOT a bitmap. * @param channel number i.e. 0 - 31, NOT a bitmap.
*/ */
public double prepareFastAmplitudeCalculation(int channel) { public double prepareFastAmplitudeCalculation(int channel) {
channel = checkSingleChannel(channel); channel = checkSingleChannel(channel);
@ -1055,7 +1040,7 @@ public class AcquisitionProcess extends PamProcess {
* Convert a raw amplitude to dB re 1 micropascal based on * Convert a raw amplitude to dB re 1 micropascal based on
* calibration information held in the AcquisitionController * calibration information held in the AcquisitionController
* for an array of double data * for an array of double data
* *
* @param rawAmplitude raw amplitude (should be -1 < rawAmplitude < 1) * @param rawAmplitude raw amplitude (should be -1 < rawAmplitude < 1)
* @param channel channel number (MUST be a channel 0 - 31, not a sequence number) * @param channel channel number (MUST be a channel 0 - 31, not a sequence number)
* @return amplitude in dB re 1 uPa. * @return amplitude in dB re 1 uPa.
@ -1073,10 +1058,10 @@ public class AcquisitionProcess extends PamProcess {
* dB re 1 micropacal / sqrt(Hz). * dB re 1 micropacal / sqrt(Hz).
* @param fftAmplitude magnitude of the fft data (not the magnitude squared !) * @param fftAmplitude magnitude of the fft data (not the magnitude squared !)
* @param channel channel number (MUST be a channel, and not a sequence number) * @param channel channel number (MUST be a channel, and not a sequence number)
* @param sampleRate sample rate - this needs to be sent, since this function is * @param sampleRate sample rate - this needs to be sent, since this function is
* often called from decimated data, in which case the sample rate will be different. * often called from decimated data, in which case the sample rate will be different.
* @param fftLength length of the FFT (needed for Parsevals correction) * @param fftLength length of the FFT (needed for Parsevals correction)
* @param isSquared is magnitude squared (in which case sqrt will be taken). * @param isSquared is magnitude squared (in which case sqrt will be taken).
* @param fast use fast calculation (after call to prepareFastAmplitudeCalculation(...). * @param fast use fast calculation (after call to prepareFastAmplitudeCalculation(...).
* @return spectrum level amplitude. * @return spectrum level amplitude.
*/ */
@ -1096,13 +1081,13 @@ public class AcquisitionProcess extends PamProcess {
double dB = rawAmplitude2dB(fftAmplitude, channel, fast); double dB = rawAmplitude2dB(fftAmplitude, channel, fast);
return dB; return dB;
} }
/** /**
* Convert the amplitude of fft data into a spectrum level measurement in * Convert the amplitude of fft data into a spectrum level measurement in
* dB re 1 micropacal / sqrt(Hz) for an array of double values. * dB re 1 micropacal / sqrt(Hz) for an array of double values.
* @param fftAmplitude magnitude of the fft data (not the magnitude squared !) * @param fftAmplitude magnitude of the fft data (not the magnitude squared !)
* @param channel the channel number (MUST be a channel, and not a sequence number) * @param channel the channel number (MUST be a channel, and not a sequence number)
* @param fftLength lengthof the fft (needed for Parsevals correction) * @param fftLength lengthof the fft (needed for Parsevals correction)
* @return spectrum level amplitude. * @return spectrum level amplitude.
*/ */
public double[] fftAmplitude2dB(double[] fftAmplitude, int channel, float sampleRate, int fftLength, boolean isSquared){ public double[] fftAmplitude2dB(double[] fftAmplitude, int channel, float sampleRate, int fftLength, boolean isSquared){
@ -1118,11 +1103,11 @@ public class AcquisitionProcess extends PamProcess {
* Convert the amplitude of fft data into a level measurement in * Convert the amplitude of fft data into a level measurement in
* dB re 1 micropacal / sqrt(Hz). * dB re 1 micropacal / sqrt(Hz).
* <p> * <p>
* Note that this function differs from fftAmplitude2dB in that this one used the * Note that this function differs from fftAmplitude2dB in that this one used the
* FFT length to correct for Parsevals theorum and integratin over the length of the * FFT length to correct for Parsevals theorum and integratin over the length of the
* FFT, but it does NOT convert the result to a spectrum level measurement. * FFT, but it does NOT convert the result to a spectrum level measurement.
* @param fftAmplitude magnitude of the fft data (not the magnitude squared !) * @param fftAmplitude magnitude of the fft data (not the magnitude squared !)
* @param fftLength lengthof the fft (needed for Parsevals correction) * @param fftLength lengthof the fft (needed for Parsevals correction)
* @return level amplitude in dB * @return level amplitude in dB
*/ */
public double fftBandAmplitude2dB(double fftAmplitude, int channel, int fftLength, boolean isSquared, boolean fast){ public double fftBandAmplitude2dB(double fftAmplitude, int channel, int fftLength, boolean isSquared, boolean fast){
@ -1143,10 +1128,10 @@ public class AcquisitionProcess extends PamProcess {
} }
/** /**
* Converts dB in micropascal to ADC counts on a 0 - 1 scale. * Converts dB in micropascal to ADC counts on a 0 - 1 scale.
* @param channel channel number, i.e. channel index 0 - 31 NOT a bitmap. * @param channel channel number, i.e. channel index 0 - 31 NOT a bitmap.
* @param dBMuPascal db in micropascal * @param dBMuPascal db in micropascal
* @return ADC counts on a 0-1 scale. * @return ADC counts on a 0-1 scale.
*/ */
public double dbMicropascalToSignal(int channel, double dBMuPascal) { public double dbMicropascalToSignal(int channel, double dBMuPascal) {
double db = dBMuPascal + getAmplitudeConstantTerm(channel); double db = dBMuPascal + getAmplitudeConstantTerm(channel);
@ -1171,9 +1156,9 @@ public class AcquisitionProcess extends PamProcess {
@Override @Override
public int getOfflineData(OfflineDataLoadInfo offlineLoadDataInfo) { public int getOfflineData(OfflineDataLoadInfo offlineLoadDataInfo) {
// System.out.println("AquisitionProcess: GetofflineData: " + offlineLoadDataInfo.getCurrentObserver().getObserverName()) // System.out.println("AquisitionProcess: GetofflineData: " + offlineLoadDataInfo.getCurrentObserver().getObserverName())
if (acquisitionControl.getOfflineFileServer() == null) { if (acquisitionControl.getOfflineFileServer() == null) {
return PamDataBlock.REQUEST_NO_DATA; return PamDataBlock.REQUEST_NO_DATA;
} }
@ -1184,11 +1169,11 @@ public class AcquisitionProcess extends PamProcess {
return PamDataBlock.REQUEST_NO_DATA; return PamDataBlock.REQUEST_NO_DATA;
} }
} }
/** /**
* Get the total number of samples acquired by a particular channel. * Get the total number of samples acquired by a particular channel.
* @param iChannel * @param iChannel
* @return number of samples. * @return number of samples.
*/ */
public long getTotalSamples(int iChannel) { public long getTotalSamples(int iChannel) {
return newDataQueue.getSamplesIn(iChannel); return newDataQueue.getSamplesIn(iChannel);
@ -1205,8 +1190,8 @@ public class AcquisitionProcess extends PamProcess {
long lastStallCheckSamples = 0; long lastStallCheckSamples = 0;
boolean lastStallState = false; boolean lastStallState = false;
/** /**
* *
* @return if the acquisition system seems to have stopped acquiring data. * @return if the acquisition system seems to have stopped acquiring data.
*/ */
public boolean isStalled() { public boolean isStalled() {
long samples = getTotalSamples(0); long samples = getTotalSamples(0);
@ -1214,13 +1199,13 @@ public class AcquisitionProcess extends PamProcess {
long stallCheckSecs = getStallCheckSeconds(); long stallCheckSecs = getStallCheckSeconds();
long runTime = now - PamCalendar.getSessionStartTime(); long runTime = now - PamCalendar.getSessionStartTime();
if (runTime < stallCheckSecs * 2000 && samples == 0) { if (runTime < stallCheckSecs * 2000 && samples == 0) {
return false; // give it plenty of time to get started. return false; // give it plenty of time to get started.
} }
if (now - lastStallCheckTime < (stallCheckSecs*1000) && lastStallState == false) { if (now - lastStallCheckTime < (stallCheckSecs*1000) && !lastStallState) {
return lastStallState; return lastStallState;
} }
double aveSR = (double) (samples - lastStallCheckSamples) / (double) (now-lastStallCheckTime) * 1000.; double aveSR = (double) (samples - lastStallCheckSamples) / (double) (now-lastStallCheckTime) * 1000.;
// check on lastStallCheckTime > 0 will stop this doing anything the first time through when it will always get a stupid small value. // check on lastStallCheckTime > 0 will stop this doing anything the first time through when it will always get a stupid small value.
boolean stalled = (aveSR < getSampleRate() * .7 && lastStallCheckTime > 0); boolean stalled = (aveSR < getSampleRate() * .7 && lastStallCheckTime > 0);
if (stalled) { if (stalled) {
System.out.println(String.format("System stalled samples %d, lastCallSamples %d, mean SR = %5.1f", samples, lastStallCheckSamples, aveSR)); System.out.println(String.format("System stalled samples %d, lastCallSamples %d, mean SR = %5.1f", samples, lastStallCheckSamples, aveSR));
@ -1232,7 +1217,7 @@ public class AcquisitionProcess extends PamProcess {
} }
/** /**
* Get the DAQ status data block. Contains data unit with info on sample numbers etc. * Get the DAQ status data block. Contains data unit with info on sample numbers etc.
* @return the daqStatusDataBlock * @return the daqStatusDataBlock
*/ */
public PamDataBlock<DaqStatusDataUnit> getDaqStatusDataBlock() { public PamDataBlock<DaqStatusDataUnit> getDaqStatusDataBlock() {
@ -1261,6 +1246,6 @@ public class AcquisitionProcess extends PamProcess {
} }
} }

View File

@ -9,40 +9,40 @@ import PamUtils.PamUtils;
import PamguardMVC.PamConstants; import PamguardMVC.PamConstants;
/** /**
* Better management of new data list. * Better management of new data list.
* <p> * <p>
* This is a queue that sits between individual acquisition systems and * This is a queue that sits between individual acquisition systems and
* the main Acquisition process. DAQ systems write data units into this list * the main Acquisition process. DAQ systems write data units into this list
* in their own thread and data are read out in a different thread. * in their own thread and data are read out in a different thread.
* @author Doug Gillespie. * @author Doug Gillespie.
* *
*/ */
public class AudioDataQueue { public class AudioDataQueue {
private volatile List<RawDataUnit> newDataUnits; private volatile List<RawDataUnit> newDataUnits;
private long samplesIn[] = new long[PamConstants.MAX_CHANNELS]; private long samplesIn[] = new long[PamConstants.MAX_CHANNELS];
private long samplesOut[] = new long[PamConstants.MAX_CHANNELS]; private long samplesOut[] = new long[PamConstants.MAX_CHANNELS];
public AudioDataQueue() { public AudioDataQueue() {
newDataUnits = Collections.synchronizedList(new LinkedList<RawDataUnit>()); newDataUnits = Collections.synchronizedList(new LinkedList<RawDataUnit>());
} }
public synchronized void clearList() { public synchronized void clearList() {
newDataUnits.clear(); newDataUnits.clear();
for (int i = 0; i < PamConstants.MAX_CHANNELS; i++) { for (int i = 0; i < PamConstants.MAX_CHANNELS; i++) {
samplesIn[i] = samplesOut[i] = 0; samplesIn[i] = samplesOut[i] = 0;
} }
} }
public synchronized boolean hasData() { public synchronized boolean hasData() {
return !newDataUnits.isEmpty(); return !newDataUnits.isEmpty();
} }
public synchronized int getQueueSize() { public synchronized int getQueueSize() {
return newDataUnits.size(); return newDataUnits.size();
} }
public synchronized RawDataUnit removeOldest() { public synchronized RawDataUnit removeOldest() {
RawDataUnit ru = newDataUnits.remove(0); RawDataUnit ru = newDataUnits.remove(0);
if (ru != null) { if (ru != null) {
@ -54,17 +54,17 @@ public class AudioDataQueue {
public void addNewData(RawDataUnit newDataUnit) { public void addNewData(RawDataUnit newDataUnit) {
addNewData(newDataUnit, PamUtils.getSingleChannel(newDataUnit.getChannelBitmap())); addNewData(newDataUnit, PamUtils.getSingleChannel(newDataUnit.getChannelBitmap()));
} }
public synchronized void addNewData(RawDataUnit newDataUnit, int channel) { public synchronized void addNewData(RawDataUnit newDataUnit, int channel) {
samplesIn[channel] += newDataUnit.getSampleDuration(); samplesIn[channel] += newDataUnit.getSampleDuration();
newDataUnits.add(newDataUnit); newDataUnits.add(newDataUnit);
} }
/** /**
* Get the total number of samples in the data queue based on the difference between * Get the total number of samples in the data queue based on the difference between
* the last sample put in and the last taken out. * the last sample put in and the last taken out.
* @param channel channel number * @param channel channel number
* @return number of stored samples in queue * @return number of stored samples in queue
*/ */

View File

@ -7,48 +7,48 @@ import javafx.scene.Node;
/** /**
* Interface allowing individual devices to provide their * Interface allowing individual devices to provide their
* own channel list panel. Some devices (such as sound cards) * own channel list panel. Some devices (such as sound cards)
* don't use this at all. ASIO cards use a standard concrete * don't use this at all. ASIO cards use a standard concrete
* implementation. NI cards use a more sophisticated one * implementation. NI cards use a more sophisticated one
* whereby multiple devices may be used. * whereby multiple devices may be used.
* @author Doug Gillespie * @author Doug Gillespie
* *
*/ */
public interface ChannelListPanel { public interface ChannelListPanel {
/** /**
* *
* @return the component for the dialog panel. * @return the component for the dialog panel.
*/ */
public Component getComponent(); public Component getComponent();
/** /**
* *
* @return the component for the dialog panel. * @return the component for the dialog panel.
*/ */
public Node getNode(); public Node getNode();
/** /**
* Set the channel list. * Set the channel list.
* @param channelList channel list * @param channelList channel list
*/ */
public void setParams(int[] channelList); public void setParams(int[] channelList);
/** /**
* *
* @return the channel list * @return the channel list
*/ */
public int[] getChannelList(); public int[] getChannelList();
/** /**
* *
* @return true if the configuration seems to be valid (i.e. no repeated channels, etc) * @return true if the configuration seems to be valid (i.e. no repeated channels, etc)
*/ */
public boolean isDataOk(); public boolean isDataOk();
/** /**
* Set the total number of channels to display. * Set the total number of channels to display.
* @param nChannels the total number of channels to display. * @param nChannels the total number of channels to display.
*/ */
public void setNumChannels(int nChannels); public void setNumChannels(int nChannels);
} }

View File

@ -42,7 +42,7 @@ public class CheckWavFileHeaders extends PamDialog {
private CheckFiles checkFilesWorker; private CheckFiles checkFilesWorker;
private ArrayList<File> allFiles = new ArrayList<File>(); private ArrayList<File> allFiles = new ArrayList<>();
private CheckWavFileHeaders(Window parentFrame) { private CheckWavFileHeaders(Window parentFrame) {
super(parentFrame, "Check File Headers", false); super(parentFrame, "Check File Headers", false);
@ -89,8 +89,8 @@ public class CheckWavFileHeaders extends PamDialog {
} }
private void enableControls() { private void enableControls() {
getOkButton().setEnabled(nFiles > 0 & running == false && ran == false); getOkButton().setEnabled(nFiles > 0 & !running && !ran);
getCancelButton().setEnabled(running == false); getCancelButton().setEnabled(!running);
} }
private int countFiles(File folder) { private int countFiles(File folder) {
@ -98,8 +98,8 @@ public class CheckWavFileHeaders extends PamDialog {
File[] files = folder.listFiles(new PamAudioFileFilter()); File[] files = folder.listFiles(new PamAudioFileFilter());
if (files == null) return 0; if (files == null) return 0;
File file; File file;
for (int i = 0; i < files.length; i++) { for (File file2 : files) {
file = files[i]; file = file2;
if (file.isDirectory() && subFolders) { if (file.isDirectory() && subFolders) {
System.out.println(file.getAbsoluteFile()); System.out.println(file.getAbsoluteFile());
nF += countFiles(file.getAbsoluteFile()); nF += countFiles(file.getAbsoluteFile());
@ -146,7 +146,7 @@ public class CheckWavFileHeaders extends PamDialog {
private void setProgressInfo(ProgressData progressData) { private void setProgressInfo(ProgressData progressData) {
progressBar.setValue(++doneFiles); progressBar.setValue(++doneFiles);
String msg = AudioFileFuncs.getMessage(progressData.headerError); String msg = AudioFileFuncs.getMessage(progressData.headerError);
textArea.append(String.format("\n%s - %s", progressData.file.getName(), msg)); textArea.append(String.format("\n%s - %s", progressData.file.getName(), msg));
boolean problem = progressData.headerError != AudioFileFuncs.FILE_OK; boolean problem = progressData.headerError != AudioFileFuncs.FILE_OK;
if (problem) { if (problem) {
nErrors++; nErrors++;
@ -164,7 +164,7 @@ public class CheckWavFileHeaders extends PamDialog {
* @return true if there is an error * @return true if there is an error
*/ */
private int checkFile(File aFile) { private int checkFile(File aFile) {
if (aFile.exists() == false || aFile.isDirectory() == true) { if (!aFile.exists() || aFile.isDirectory()) {
return AudioFileFuncs.FILE_DOESNTEXIST; return AudioFileFuncs.FILE_DOESNTEXIST;
} }
String fileName = aFile.getName(); String fileName = aFile.getName();
@ -179,7 +179,7 @@ public class CheckWavFileHeaders extends PamDialog {
} }
else if (fileEnd.equalsIgnoreCase("aif")) { else if (fileEnd.equalsIgnoreCase("aif")) {
return checkAifFile(aFile); return checkAifFile(aFile);
} }
return AudioFileFuncs.FILE_UNKNOWNTYPE; return AudioFileFuncs.FILE_UNKNOWNTYPE;
} }
@ -198,13 +198,13 @@ public class CheckWavFileHeaders extends PamDialog {
protected Integer doInBackground() throws Exception { protected Integer doInBackground() throws Exception {
/* /*
* need to loop over files again * need to loop over files again
* for each file, report on progress with it's name and * for each file, report on progress with it's name and
* whether or not it had an error * whether or not it had an error
*/ */
int error; int error;
File aFile; File aFile;
for (int i = 0; i < allFiles.size(); i++) { for (File file : allFiles) {
error = checkFile(aFile = allFiles.get(i)); error = checkFile(aFile = file);
publish(new ProgressData(aFile, error)); publish(new ProgressData(aFile, error));
} }
return null; return null;
@ -220,8 +220,8 @@ public class CheckWavFileHeaders extends PamDialog {
@Override @Override
protected void process(List<ProgressData> progressData) { protected void process(List<ProgressData> progressData) {
for (int i = 0; i < progressData.size(); i++) { for (ProgressData element : progressData) {
setProgressInfo(progressData.get(i)); setProgressInfo(element);
} }
} }

View File

@ -4,7 +4,7 @@ import PamguardMVC.ChannelListManager;
/** /**
* Class for converting channel indexes and numbers to hydrophones * Class for converting channel indexes and numbers to hydrophones
* for the main PAMGAURD DAQ. * for the main PAMGAURD DAQ.
* <p> * <p>
* All these functions are passed through to the AcquisitionParameters class * All these functions are passed through to the AcquisitionParameters class
* but these ones are better organised and therefore much easier to use than * but these ones are better organised and therefore much easier to use than
@ -16,7 +16,7 @@ import PamguardMVC.ChannelListManager;
public class DAQChannelListManager extends ChannelListManager { public class DAQChannelListManager extends ChannelListManager {
private AcquisitionControl acquisitionControl; private AcquisitionControl acquisitionControl;
public DAQChannelListManager(AcquisitionControl acquisitionControl) { public DAQChannelListManager(AcquisitionControl acquisitionControl) {
this.acquisitionControl = acquisitionControl; this.acquisitionControl = acquisitionControl;
} }
@ -25,7 +25,7 @@ public class DAQChannelListManager extends ChannelListManager {
// public int channelIndexToNumber(int channelIndex) { // public int channelIndexToNumber(int channelIndex) {
// //
// return acquisitionControl.acquisitionParameters.getChannelList(channelIndex); // return acquisitionControl.acquisitionParameters.getChannelList(channelIndex);
// //
// } // }
@Override @Override

View File

@ -1,7 +1,7 @@
package Acquisition; package Acquisition;
/** /**
* Class to remove DC offset from audio data. * Class to remove DC offset from audio data.
* @author Douglas Gillespie * @author Douglas Gillespie
* *
*/ */
@ -20,7 +20,7 @@ public class DCFilter {
background = new double[nChannels]; background = new double[nChannels];
alpha = 1-1./(sampleRate*timeConstant); alpha = 1-1./(sampleRate*timeConstant);
} }
public void filterData(int channel, double[] data) { public void filterData(int channel, double[] data) {
double x; double x;
double b = background[channel]; double b = background[channel];

View File

@ -21,7 +21,7 @@ public class DCL5System extends FolderInputSystem implements PamSettings {
// PamSettingManager.getInstance().registerSettings(this); // PamSettingManager.getInstance().registerSettings(this);
// } // }
String xmlDocName = "C:\\DCL_5_2011\\Matlab\\SpeciesFiletimes2.xml"; String xmlDocName = "C:\\DCL_5_2011\\Matlab\\SpeciesFiletimes2.xml";
Document doc; Document doc;
@ -84,9 +84,9 @@ public class DCL5System extends FolderInputSystem implements PamSettings {
String timeString = e.getAttribute("time"); String timeString = e.getAttribute("time");
return super.getFileStartTime(new File(timeString)); return super.getFileStartTime(new File(timeString));
/* /*
* Get the file time from the XML document. * Get the file time from the XML document.
*/ */
// return super.getFileStartTime(file); // return super.getFileStartTime(file);
} }
} }

View File

@ -13,7 +13,6 @@ import binaryFileStorage.BinaryHeader;
import binaryFileStorage.BinaryObjectData; import binaryFileStorage.BinaryObjectData;
import binaryFileStorage.ModuleFooter; import binaryFileStorage.ModuleFooter;
import binaryFileStorage.ModuleHeader; import binaryFileStorage.ModuleHeader;
import binaryFileStorage.PackedBinaryObject;
public class DaqStatusBinaryStore extends BinaryDataSource { public class DaqStatusBinaryStore extends BinaryDataSource {
@ -50,12 +49,12 @@ public class DaqStatusBinaryStore extends BinaryDataSource {
@Override @Override
public PamDataUnit sinkData(BinaryObjectData binaryObjectData, BinaryHeader bh, int moduleVersion) { public PamDataUnit sinkData(BinaryObjectData binaryObjectData, BinaryHeader bh, int moduleVersion) {
ByteArrayInputStream bis = new ByteArrayInputStream(binaryObjectData.getData(), ByteArrayInputStream bis = new ByteArrayInputStream(binaryObjectData.getData(),
0, binaryObjectData.getDataLength()); 0, binaryObjectData.getDataLength());
DataInputStream dis = new DataInputStream(bis); DataInputStream dis = new DataInputStream(bis);
long adcMilliseconds = 0; long adcMilliseconds = 0;
long samples = 0; long samples = 0;
Long gpsPPSMillis = null; Long gpsPPSMillis = null;
short status = 0; short status = 0;
short reason = 0; short reason = 0;
@ -68,7 +67,7 @@ public class DaqStatusBinaryStore extends BinaryDataSource {
gpsPPSMillis = dis.readLong(); gpsPPSMillis = dis.readLong();
if (gpsPPSMillis == 0) { if (gpsPPSMillis == 0) {
// zero must be intrpreted as null (no data) or it can screw up some time corrections in the // zero must be intrpreted as null (no data) or it can screw up some time corrections in the
// network receiver. // network receiver.
gpsPPSMillis = null; gpsPPSMillis = null;
} }
status = dis.readShort(); status = dis.readShort();
@ -97,24 +96,24 @@ public class DaqStatusBinaryStore extends BinaryDataSource {
channels = PamUtils.PamUtils.makeChannelMap(acquisitionControl.acquisitionParameters.nChannels); channels = PamUtils.PamUtils.makeChannelMap(acquisitionControl.acquisitionParameters.nChannels);
voltsPeak2Peak = acquisitionControl.acquisitionParameters.voltsPeak2Peak; voltsPeak2Peak = acquisitionControl.acquisitionParameters.voltsPeak2Peak;
} }
AcquisitionParameters daqParams = new AcquisitionParameters(); AcquisitionParameters daqParams = new AcquisitionParameters();
daqParams.setVoltsPeak2Peak(voltsPeak2Peak); daqParams.setVoltsPeak2Peak(voltsPeak2Peak);
daqParams.setPreamplifier(new Preamplifier(0, null)); daqParams.setPreamplifier(new Preamplifier(0, null));
daqParams.setSampleRate(sampleRate); daqParams.setSampleRate(sampleRate);
daqParams.setDaqSystemType(daqSystemType); daqParams.setDaqSystemType(daqSystemType);
/** /**
* Only used in netrx mode and doesn't handle corrected milliseconds. * Only used in netrx mode and doesn't handle corrected milliseconds.
*/ */
DaqStatusDataUnit dsdu = new DaqStatusDataUnit(binaryObjectData.getTimeMilliseconds(), DaqStatusDataUnit dsdu = new DaqStatusDataUnit(binaryObjectData.getTimeMilliseconds(),
adcMilliseconds, adcMilliseconds, samples, gpsPPSMillis, (new Short(status)).toString(), adcMilliseconds, adcMilliseconds, samples, gpsPPSMillis, (new Short(status)).toString(),
(new Short(reason)).toString(), daqParams, null, duration, clockError); (new Short(reason)).toString(), daqParams, null, duration, clockError);
return dsdu; return dsdu;
} }
@Override @Override
public ModuleHeader sinkModuleHeader(BinaryObjectData binaryObjectData, BinaryHeader bh) { public ModuleHeader sinkModuleHeader(BinaryObjectData binaryObjectData, BinaryHeader bh) {
ByteArrayInputStream bis = new ByteArrayInputStream(binaryObjectData.getData(), ByteArrayInputStream bis = new ByteArrayInputStream(binaryObjectData.getData(),
0, binaryObjectData.getDataLength()); 0, binaryObjectData.getDataLength());
DataInputStream dis = new DataInputStream(bis); DataInputStream dis = new DataInputStream(bis);
moduleHeader = new DaqStatusModuleHeader(bh.getHeaderFormat()); moduleHeader = new DaqStatusModuleHeader(bh.getHeaderFormat());
@ -127,7 +126,7 @@ public class DaqStatusBinaryStore extends BinaryDataSource {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return moduleHeader; return moduleHeader;
} }

View File

@ -2,7 +2,6 @@ package Acquisition;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import PamguardMVC.PamProcess; import PamguardMVC.PamProcess;
import dataMap.OfflineDataMap;
import effort.EffortProvider; import effort.EffortProvider;
import effort.binary.DataMapEffortProvider; import effort.binary.DataMapEffortProvider;
import generalDatabase.DBControlUnit; import generalDatabase.DBControlUnit;
@ -15,9 +14,9 @@ public class DaqStatusDataBlock extends PamDataBlock<DaqStatusDataUnit> {
@Override @Override
public EffortProvider autoEffortProvider() { public EffortProvider autoEffortProvider() {
// make a provider which will pick up on the database data. // make a provider which will pick up on the database data.
// db data are written every 60s, so put 62s as max gap. // db data are written every 60s, so put 62s as max gap.
return new DataMapEffortProvider(this, DBControlUnit.class, 62000L); return new DataMapEffortProvider(this, DBControlUnit.class, 62000L);
} }
} }

View File

@ -1,42 +1,41 @@
package Acquisition; package Acquisition;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
import PamUtils.PamUtils;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;
/** /**
* Data unit containing information on run starts and stops. * Data unit containing information on run starts and stops.
* <p> * <p>
* The main purpose of producing these is so that they get picked up * The main purpose of producing these is so that they get picked up
* by the database and logged * by the database and logged
* *
* @author Doug Gillespie * @author Doug Gillespie
* *
*/ */
public class DaqStatusDataUnit extends PamDataUnit { public class DaqStatusDataUnit extends PamDataUnit {
private String status = "Stop"; private String status = "Stop";
private String reason = ""; private String reason = "";
private String daqSystemType = ""; private String daqSystemType = "";
public int sampleRate; public int sampleRate;
public Double trueSampleRate; public Double trueSampleRate;
public int nChannels = 2; public int nChannels = 2;
public double voltsPeak2Peak = 5; public double voltsPeak2Peak = 5;
public double duration = 0; public double duration = 0;
public double clockError; public double clockError;
private long adcMilliseconds; private long adcMilliseconds;
private long samples; private long samples;
private Long gpsPPSMilliseconds; private Long gpsPPSMilliseconds;
private Long serverTime; private Long serverTime;
@ -44,13 +43,13 @@ public class DaqStatusDataUnit extends PamDataUnit {
private AcquisitionParameters daqParameters; private AcquisitionParameters daqParameters;
private long rawADCMillis; private long rawADCMillis;
private String systemName; private String systemName;
// private static DaqStatusDataUnit previousDaqStatusUnit = null; // private static DaqStatusDataUnit previousDaqStatusUnit = null;
public DaqStatusDataUnit(long timeMilliseconds, long adcMilliseconds, long rawADCMillis, public DaqStatusDataUnit(long timeMilliseconds, long adcMilliseconds, long rawADCMillis,
long samples, Long gpsPPSMillis, long samples, Long gpsPPSMillis,
String status, String reason, String status, String reason,
AcquisitionParameters daqParameters, String systemName, double duration, double clockError) { AcquisitionParameters daqParameters, String systemName, double duration, double clockError) {
super(timeMilliseconds); super(timeMilliseconds);
this.adcMilliseconds = adcMilliseconds; this.adcMilliseconds = adcMilliseconds;
@ -60,7 +59,7 @@ public class DaqStatusDataUnit extends PamDataUnit {
this.status = status; this.status = status;
this.reason = reason; this.reason = reason;
if (daqParameters!=null) { if (daqParameters!=null) {
//null if statement only used in viewer mode were DAQ params are not loaded from database. //null if statement only used in viewer mode were DAQ params are not loaded from database.
this.daqSystemType = daqParameters.daqSystemType; this.daqSystemType = daqParameters.daqSystemType;
this.daqParameters = daqParameters; this.daqParameters = daqParameters;
this.sampleRate = (int) daqParameters.getSampleRate(); this.sampleRate = (int) daqParameters.getSampleRate();
@ -70,17 +69,17 @@ public class DaqStatusDataUnit extends PamDataUnit {
this.systemName = systemName; this.systemName = systemName;
this.duration = duration; this.duration = duration;
this.clockError = clockError; this.clockError = clockError;
// set the DataUnitBaseData duration (in samples) to this duration // set the DataUnitBaseData duration (in samples) to this duration
this.setSampleDuration((long) (duration*sampleRate)); this.setSampleDuration((long) (duration*sampleRate));
// /* // /*
// * This won't work if data are being sent from multiple receivers ! // * This won't work if data are being sent from multiple receivers !
// */ // */
// calculateTrueSampleRate(previousDaqStatusUnit); // calculateTrueSampleRate(previousDaqStatusUnit);
// previousDaqStatusUnit = this; // previousDaqStatusUnit = this;
} }
/** /**
* @return the systemName * @return the systemName
*/ */
@ -99,9 +98,9 @@ public class DaqStatusDataUnit extends PamDataUnit {
if (previousUnit == null || gpsPPSMilliseconds == null || previousUnit.getGpsPPSMilliseconds() == null) { if (previousUnit == null || gpsPPSMilliseconds == null || previousUnit.getGpsPPSMilliseconds() == null) {
trueSampleRate = null; trueSampleRate = null;
return null; return null;
} }
double samples = (double) (this.samples - previousUnit.getSamples()); double samples = this.samples - previousUnit.getSamples();
double tDiff = (double) (this.gpsPPSMilliseconds - previousUnit.getGpsPPSMilliseconds()) / 1000.; double tDiff = (this.gpsPPSMilliseconds - previousUnit.getGpsPPSMilliseconds()) / 1000.;
if (tDiff > 0 && tDiff < 900 && samples > 0) { if (tDiff > 0 && tDiff < 900 && samples > 0) {
trueSampleRate = samples/tDiff; trueSampleRate = samples/tDiff;
} }

View File

@ -14,7 +14,7 @@ import binaryFileStorage.ModuleHeader;
class DaqStatusModuleHeader extends ModuleHeader implements Serializable, ManagedParameters { class DaqStatusModuleHeader extends ModuleHeader implements Serializable, ManagedParameters {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public DaqStatusModuleHeader(int moduleVersion) { public DaqStatusModuleHeader(int moduleVersion) {
super(moduleVersion); super(moduleVersion);
} }

View File

@ -6,86 +6,84 @@ import javax.swing.JComponent;
import Acquisition.layoutFX.AcquisitionPaneFX; import Acquisition.layoutFX.AcquisitionPaneFX;
import Acquisition.layoutFX.DAQSettingsPane; import Acquisition.layoutFX.DAQSettingsPane;
import PamController.SettingsPane;
import PamUtils.PamUtils; import PamUtils.PamUtils;
import javafx.scene.Node;
import soundPlayback.FilePlayback; import soundPlayback.FilePlayback;
import soundPlayback.PlaybackControl; import soundPlayback.PlaybackControl;
import soundPlayback.PlaybackSystem; import soundPlayback.PlaybackSystem;
/** /**
* *
* Abstraction to multiple data acquisition devices. This interface performs * Abstraction to multiple data acquisition devices. This interface performs
* the following tasks: * the following tasks:
* <p> * <p>
* 1. Provides information about the device such as min and max sample rates, number of channelse, etc. * 1. Provides information about the device such as min and max sample rates, number of channelse, etc.
* 2. Provides a dialog panel with specific options. This automatically gets incorporated into a more * 2. Provides a dialog panel with specific options. This automatically gets incorporated into a more
* general data acquisition panel * general data acquisition panel
* 3. Provides threads and any other functions necessary to create packets of raw audio data in * 3. Provides threads and any other functions necessary to create packets of raw audio data in
* PamDataUnit's. * PamDataUnit's.
* 4. Each concrete class should, if needed, save it's own setting using the PamSettings package. * 4. Each concrete class should, if needed, save it's own setting using the PamSettings package.
* <p> * <p>
* Current examples are in SoundCardSystem and FileInputSystem * Current examples are in SoundCardSystem and FileInputSystem
* *
* @author Doug Gillespie * @author Doug Gillespie
* *
*/ */
// is sampleRate ok? set true - return false from getparams... // is sampleRate ok? set true - return false from getparams...
// is numChannels ok? set true /override these in asio - before returning false // is numChannels ok? set true /override these in asio - before returning false
public abstract class DaqSystem { public abstract class DaqSystem {
public static final int PARAMETER_UNKNOWN = -1; public static final int PARAMETER_UNKNOWN = -1;
public static final int PARAMETER_FIXED = -2; public static final int PARAMETER_FIXED = -2;
private int streamStatus = STREAM_CLOSED; private int streamStatus = STREAM_CLOSED;
/** /**
* @return The 'type' of data source for display in the Data Source dialog * @return The 'type' of data source for display in the Data Source dialog
* <p> Calling functions should be able to handle 'null' * <p> Calling functions should be able to handle 'null'
*/ */
abstract public String getSystemType(); abstract public String getSystemType();
/** /**
* *
* @return A string describing the data source, e.g. the sound card name, file name, udp port, etc. * @return A string describing the data source, e.g. the sound card name, file name, udp port, etc.
*/ */
abstract public String getSystemName(); abstract public String getSystemName();
/** /**
* The AcquisitionDialog has been designed to that each data source type can plug * The AcquisitionDialog has been designed to that each data source type can plug
* in it's own panel of device specific controls. These could be things like a file * in it's own panel of device specific controls. These could be things like a file
* name, gain settings, channel lists, whatever is available for the specific device * name, gain settings, channel lists, whatever is available for the specific device
* <p> * <p>
* The AcquisitionDialog will handle placing this component on the dialog when a * The AcquisitionDialog will handle placing this component on the dialog when a
* particular DaqSystem is selected. The component will be placed between a drop down * particular DaqSystem is selected. The component will be placed between a drop down
* list of available DaqSystem's and a section of the dialog showing the sample rate and * list of available DaqSystem's and a section of the dialog showing the sample rate and
* number of channels. * number of channels.
* <p> * <p>
* @param acquisitionDialog the AcquisitionDialog this component will be added to * @param acquisitionDialog the AcquisitionDialog this component will be added to
* @return dialog component specific to this DAQ device * @return dialog component specific to this DAQ device
*/ */
abstract public JComponent getDaqSpecificDialogComponent(AcquisitionDialog acquisitionDialog); abstract public JComponent getDaqSpecificDialogComponent(AcquisitionDialog acquisitionDialog);
/** /**
* Get a channel list panel (invented for NI cards which have many more options) * Get a channel list panel (invented for NI cards which have many more options)
* @param acquisitionDialog reference to main acquisition dialog * @param acquisitionDialog reference to main acquisition dialog
* @return ChannelListPanel component. * @return ChannelListPanel component.
*/ */
public ChannelListPanel getDaqSpecificChannelListPanel(AcquisitionDialog acquisitionDialog) { public ChannelListPanel getDaqSpecificChannelListPanel(AcquisitionDialog acquisitionDialog) {
return null; return null;
} }
/** /**
* Called by AcquisitionDialog.SetParams so that the dialog componenet can update it's * Called by AcquisitionDialog.SetParams so that the dialog componenet can update it's
* fields * fields
* *
*/ */
abstract public void dialogSetParams(); abstract public void dialogSetParams();
/** /**
* Called by AcquisitionDialog.GetParams so that parameters can be extracted from the dialog * Called by AcquisitionDialog.GetParams so that parameters can be extracted from the dialog
* component. The DaqSystem should also implement PamSettings and handle storage of parameters * component. The DaqSystem should also implement PamSettings and handle storage of parameters
@ -94,49 +92,49 @@ public abstract class DaqSystem {
* dialog will not respond to its Ok button. * dialog will not respond to its Ok button.
*/ */
abstract public boolean dialogGetParams(); abstract public boolean dialogGetParams();
/** /**
* Tell a DAQ system it's been selected or deselected. * Tell a DAQ system it's been selected or deselected.
* @param select * @param select
*/ */
public void setSelected(boolean select) { public void setSelected(boolean select) {
} }
/** /**
* Get model changed events. * Get model changed events.
* @param changeType * @param changeType
*/ */
public void notifyModelChanged(int changeType) { public void notifyModelChanged(int changeType) {
} }
/** /**
* *
* @return the maximum sample rate supporrted by the selected device, or PARAMETER_UNKNOWN * @return the maximum sample rate supporrted by the selected device, or PARAMETER_UNKNOWN
*/ */
abstract public int getMaxSampleRate(); abstract public int getMaxSampleRate();
/** /**
* *
* @return the maximum number of channels supporrted by the selected device, or PARAMETER_UNKNOWN * @return the maximum number of channels supporrted by the selected device, or PARAMETER_UNKNOWN
*/ */
abstract public int getMaxChannels(); abstract public int getMaxChannels();
/** /**
* *
* @return peak to peak voltage for the device or PARAMETER_UNKNOWN * @return peak to peak voltage for the device or PARAMETER_UNKNOWN
*/ */
abstract public double getPeak2PeakVoltage(int swChannel); abstract public double getPeak2PeakVoltage(int swChannel);
/** /**
* Prepare the DaqSystem. * Prepare the DaqSystem.
* <p> * <p>
* Usually this is the time for opening files, preparing data buffers, etc. * Usually this is the time for opening files, preparing data buffers, etc.
* @param daqControl AcquisitionControl unit. * @param daqControl AcquisitionControl unit.
* @return true if OK, false otherwise. * @return true if OK, false otherwise.
*/ */
abstract public boolean prepareSystem(AcquisitionControl daqControl); abstract public boolean prepareSystem(AcquisitionControl daqControl);
/** /**
* Start the DaqSystem. This is called immediately after PrepareSystem * Start the DaqSystem. This is called immediately after PrepareSystem
* <p> * <p>
@ -148,46 +146,46 @@ public abstract class DaqSystem {
* @return true if OK, false otherwise * @return true if OK, false otherwise
*/ */
abstract public boolean startSystem(AcquisitionControl daqControl); abstract public boolean startSystem(AcquisitionControl daqControl);
/** /**
* Stop the DaqSystem. * Stop the DaqSystem.
* @param daqControl * @param daqControl
*/ */
abstract public void stopSystem(AcquisitionControl daqControl); abstract public void stopSystem(AcquisitionControl daqControl);
/** /**
* *
* @return true for real time systems (e.g. sound cards, NI cards, wav files * @return true for real time systems (e.g. sound cards, NI cards, wav files
* which are being played back over speakers. false for reading files which are to be * which are being played back over speakers. false for reading files which are to be
* processed as fast as possible with no playback. * processed as fast as possible with no playback.
*/ */
abstract public boolean isRealTime(); abstract public boolean isRealTime();
/** /**
* *
* @return true if the system can also play back sound - likely to be true for sound cards * @return true if the system can also play back sound - likely to be true for sound cards
* and ASIO, and some NI cards, false for wav files. Simulator ? * and ASIO, and some NI cards, false for wav files. Simulator ?
*/ */
abstract public boolean canPlayBack(float sampleRate); abstract public boolean canPlayBack(float sampleRate);
/** /**
* *
* @return the number of samples expected in each data unit. * @return the number of samples expected in each data unit.
*/ */
abstract public int getDataUnitSamples(); abstract public int getDataUnitSamples();
/** /**
* Gets a playback system for playing sound back out through headphones / speakers, etc. * Gets a playback system for playing sound back out through headphones / speakers, etc.
* <p> * <p>
* Generally, anything acquiring data in real time should play the sound back through * Generally, anything acquiring data in real time should play the sound back through
* itself so that clocks are correctly synchronised. i.e. A sound card input will go to the * itself so that clocks are correctly synchronised. i.e. A sound card input will go to the
* same sound card output, etc. At a later date, we may try to support output through * same sound card output, etc. At a later date, we may try to support output through
* different devices at different speeds - but this will be problematic ! * different devices at different speeds - but this will be problematic !
* <p> * <p>
* If data are being read from a file, then playback is through a sound card which sits * If data are being read from a file, then playback is through a sound card which sits
* in a stand alone implementation of PlaybackSystem * in a stand alone implementation of PlaybackSystem
* @param playbackControl * @param playbackControl
* @param daqSystem * @param daqSystem
* @return null if no playback available or a PlaybackSystem object. * @return null if no playback available or a PlaybackSystem object.
* @see PlaybackSystem * @see PlaybackSystem
* @see FilePlayback * @see FilePlayback
@ -203,7 +201,7 @@ public abstract class DaqSystem {
* *
*/ */
abstract public void daqHasEnded(); abstract public void daqHasEnded();
public static final int STREAM_CLOSED = 0; public static final int STREAM_CLOSED = 0;
public static final int STREAM_OPEN = 1; public static final int STREAM_OPEN = 1;
public static final int STREAM_RUNNING = 2; public static final int STREAM_RUNNING = 2;
@ -220,36 +218,36 @@ public abstract class DaqSystem {
public void setStreamStatus(int streamStatus) { public void setStreamStatus(int streamStatus) {
this.streamStatus = streamStatus; this.streamStatus = streamStatus;
} }
public boolean areSampleSettingsOk(int numInputsRequested, float sampleRateRequested){ public boolean areSampleSettingsOk(int numInputsRequested, float sampleRateRequested){
return true; return true;
} }
public void showSampleSettingsDialog(AcquisitionDialog acquisitionDialog){ public void showSampleSettingsDialog(AcquisitionDialog acquisitionDialog){
} }
public Component getStatusBarComponent() { public Component getStatusBarComponent() {
return null; return null;
} }
public boolean supportsChannelLists() { public boolean supportsChannelLists() {
return false; return false;
} }
/** /**
* *
* @return a bitmap of output channels. this should ALWAYS be * @return a bitmap of output channels. this should ALWAYS be
* a bitmap of channels 0 to n-1 even if different hardware channels * a bitmap of channels 0 to n-1 even if different hardware channels
* are used since hardware channels are no longer passed through PAMGUARD. * are used since hardware channels are no longer passed through PAMGUARD.
*/ */
public int getInputChannelMap(AcquisitionParameters acquisitionParameters) { public int getInputChannelMap(AcquisitionParameters acquisitionParameters) {
return PamUtils.makeChannelMap(acquisitionParameters.nChannels); return PamUtils.makeChannelMap(acquisitionParameters.nChannels);
} }
/** /**
* Gets a name for the acquisition device (may just be a number * Gets a name for the acquisition device (may just be a number
* but need to generalise). * but need to generalise).
* @return * @return
*/ */
public abstract String getDeviceName(); public abstract String getDeviceName();
@ -262,18 +260,18 @@ public abstract class DaqSystem {
public double getChannelGain(int channel) { public double getChannelGain(int channel) {
return 0; return 0;
} }
/** /**
* Get the number of bits in each sample. * Get the number of bits in each sample.
* @return the number of bits in each sample. * @return the number of bits in each sample.
*/ */
public int getSampleBits() { public int getSampleBits() {
return 16; return 16;
} }
/** /**
* *
* @return how often its reasonable to check whether or not the system has stalled. * @return how often its reasonable to check whether or not the system has stalled.
*/ */
public long getStallCheckSeconds() { public long getStallCheckSeconds() {
return 2; return 2;
@ -283,23 +281,23 @@ public abstract class DaqSystem {
/** /**
* Get a channel list panel (invented for NI cards which have many more options) * Get a channel list panel (invented for NI cards which have many more options)
* @param acquisitionDialog reference to main acquisition dialog * @param acquisitionDialog reference to main acquisition dialog
* @return ChannelListPanel component. * @return ChannelListPanel component.
*/ */
public ChannelListPanel getDaqSpecificChannelListNode(AcquisitionPaneFX acquisitionPaneFX) { public ChannelListPanel getDaqSpecificChannelListNode(AcquisitionPaneFX acquisitionPaneFX) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
/** /**
* The AcquisitionDialog has been designed to that each data source type can plug * The AcquisitionDialog has been designed to that each data source type can plug
* in it's own panel of device specific controls. These could be things like a file * in it's own panel of device specific controls. These could be things like a file
* name, gain settings, channel lists, whatever is available for the specific device * name, gain settings, channel lists, whatever is available for the specific device
* <p> * <p>
* The AcquisitionDialog will handle placing this component on the dialog when a * The AcquisitionDialog will handle placing this component on the dialog when a
* particular DaqSystem is selected. The component will be placed between a drop down * particular DaqSystem is selected. The component will be placed between a drop down
* list of available DaqSystem's and a section of the dialog showing the sample rate and * list of available DaqSystem's and a section of the dialog showing the sample rate and
* number of channels. * number of channels.
* <p> * <p>
* @param acquisitionDialog the AcquisitionPaneFX this component will be added to * @param acquisitionDialog the AcquisitionPaneFX this component will be added to
* @return dialog component specific to this DAQ device * @return dialog component specific to this DAQ device
@ -309,5 +307,5 @@ public abstract class DaqSystem {
return null; return null;
} }
} }

View File

@ -1,25 +1,23 @@
package Acquisition; package Acquisition;
import PamModel.CommonPluginInterface; import PamModel.CommonPluginInterface;
import PamModel.PamModel;
import PamModel.PamModuleInfo;
/** /**
* Interface for External DAQ Systems * Interface for External DAQ Systems
* *
* @author MO * @author MO
* *
*/ */
public interface DaqSystemInterface extends CommonPluginInterface { public interface DaqSystemInterface extends CommonPluginInterface {
/** /**
* Creates a new instance of the DAQ System controller, the class that extends * Creates a new instance of the DAQ System controller, the class that extends
* DaqSystem.class. The AcquisitionControl object that gets passed to the * DaqSystem.class. The AcquisitionControl object that gets passed to the
* interface provides the DAQ System with a link to hardware information * interface provides the DAQ System with a link to hardware information
* e.g. channel list, sample rate, etc. * e.g. channel list, sample rate, etc.
* <p> * <p>
* This field cannot be null. * This field cannot be null.
* *
* @param the AcquisitionControl object * @param the AcquisitionControl object
* @return the DaqSystem object * @return the DaqSystem object
*/ */

View File

@ -15,11 +15,11 @@ import PamController.PamController;
* is shared by multiple PamSettings classes. For example: the SoundCardParameters class is used * is shared by multiple PamSettings classes. For example: the SoundCardParameters class is used
* by the SoundCardSystem, ASIOSoundSystem and NewAsioSoundSystem classes. Each of these has it's own * by the SoundCardSystem, ASIOSoundSystem and NewAsioSoundSystem classes. Each of these has it's own
* type (see the individual getUnitType calls) but the SoundCardParameters class doesn't know who called * type (see the individual getUnitType calls) but the SoundCardParameters class doesn't know who called
* it and so can't properly check whether the type matches. Further, SoundCardParameters is extended by * it and so can't properly check whether the type matches. Further, SoundCardParameters is extended by
* NIDAQParams, SimParameters and SmruDaqParameters. So trying to make SoundCardParameters check for a * NIDAQParams, SimParameters and SmruDaqParameters. So trying to make SoundCardParameters check for a
* type would potentially screw up those extended classes. That being said, the extended classes are * type would potentially screw up those extended classes. That being said, the extended classes are
* able to check for their types themselves. * able to check for their types themselves.
* *
* @author dg50 * @author dg50
* *
*/ */
@ -30,8 +30,8 @@ public class DaqSystemXMLManager {
if (daqs == null) { if (daqs == null) {
return false; return false;
} }
for (int i = 0; i < daqs.size(); i++) { for (PamControlledUnit daq2 : daqs) {
AcquisitionControl daq = (AcquisitionControl) daqs.get(i); AcquisitionControl daq = (AcquisitionControl) daq2;
AcquisitionParameters daqParams = daq.getAcquisitionParameters(); AcquisitionParameters daqParams = daq.getAcquisitionParameters();
if (daqParams.daqSystemType.equals(daqSystemType)) { if (daqParams.daqSystemType.equals(daqSystemType)) {
return true; return true;

View File

@ -16,14 +16,14 @@ import PamModel.parametermanager.PamParameterSet.ParameterSetType;
public class FileInputParameters implements Serializable, Cloneable, ManagedParameters { public class FileInputParameters implements Serializable, Cloneable, ManagedParameters {
static public final long serialVersionUID = 1; static public final long serialVersionUID = 1;
static public final int MAX_RECENT_FILES = 20; static public final int MAX_RECENT_FILES = 20;
/** /**
* A list of the recent files or folders selected. * A list of the recent files or folders selected.
*/ */
public ArrayList<String> recentFiles = new ArrayList<String>(); public ArrayList<String> recentFiles = new ArrayList<>();
public boolean realTime; public boolean realTime;
public String getMostRecentFile() { public String getMostRecentFile() {
@ -34,21 +34,21 @@ public class FileInputParameters implements Serializable, Cloneable, ManagedPara
return null; return null;
} }
} }
public String systemType; public String systemType;
/** /**
* Repeat in an infinite loop * Repeat in an infinite loop
*/ */
public boolean repeatLoop; public boolean repeatLoop;
/** /**
* Skip a section an initial section of the file in millis. For example, use with SoundTrap calibration values. * Skip a section an initial section of the file in millis. For example, use with SoundTrap calibration values.
*/ */
public long skipStartFileTime = 0; public long skipStartFileTime = 0;
public int bitDepth; public int bitDepth;
/** /**
* @param systemType * @param systemType
*/ */
@ -71,7 +71,7 @@ public class FileInputParameters implements Serializable, Cloneable, ManagedPara
} }
return null; return null;
} }
@Override @Override
public PamParameterSet getParameterSet() { public PamParameterSet getParameterSet() {
// if the user has not selected this system type, just return null // if the user has not selected this system type, just return null

View File

@ -7,8 +7,6 @@ import java.awt.GridBagLayout;
import java.awt.Insets; import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -20,9 +18,9 @@ import java.util.Calendar;
import java.util.List; import java.util.List;
import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.UnsupportedAudioFileException; import javax.sound.sampled.UnsupportedAudioFileException;
import javax.sound.sampled.AudioFormat.Encoding;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
@ -32,33 +30,24 @@ import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import javax.swing.filechooser.FileFilter;
import org.jflac.FLACDecoder; import org.jflac.FLACDecoder;
import org.jflac.PCMProcessor;
import org.jflac.frame.Frame; import org.jflac.frame.Frame;
import org.jflac.metadata.StreamInfo;
import org.jflac.sound.spi.FlacEncoding;
import org.jflac.util.ByteData; import org.jflac.util.ByteData;
import org.pamguard.x3.sud.Chunk; import org.pamguard.x3.sud.Chunk;
import org.pamguard.x3.sud.SudAudioInputStream; import org.pamguard.x3.sud.SudAudioInputStream;
import org.pamguard.x3.sud.SudFileListener; import org.pamguard.x3.sud.SudFileListener;
import org.pamguard.x3.sud.SudParams;
import org.jflac.PCMProcessor;
import org.jflac.metadata.StreamInfo;
import org.jflac.sound.spi.FlacEncoding;
//import org.kc7bfi.jflac.FLACDecoder;
//import org.kc7bfi.jflac.PCMProcessor;
//import org.kc7bfi.jflac.frame.Frame;
//import org.kc7bfi.jflac.metadata.SeekPoint;
//import org.kc7bfi.jflac.metadata.StreamInfo;
//import org.kc7bfi.jflac.sound.spi.FlacEncoding;
//import org.kc7bfi.jflac.util.ByteData;
import wavFiles.ByteConverter;
import Acquisition.filedate.FileDate; import Acquisition.filedate.FileDate;
import Acquisition.filedate.FileDateDialogStrip; import Acquisition.filedate.FileDateDialogStrip;
import Acquisition.filedate.FileDateObserver; import Acquisition.filedate.FileDateObserver;
import Acquisition.filetypes.SoundFileType; import Acquisition.filetypes.SoundFileType;
import Acquisition.pamAudio.PamAudioFileManager;
import Acquisition.pamAudio.PamAudioFileFilter; import Acquisition.pamAudio.PamAudioFileFilter;
import Acquisition.pamAudio.PamAudioFileManager;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
import PamController.PamController; import PamController.PamController;
import PamController.PamSettingManager; import PamController.PamSettingManager;
@ -73,9 +62,19 @@ import PamView.panel.PamProgressBar;
import pamguard.GlobalArguments; import pamguard.GlobalArguments;
import warnings.PamWarning; import warnings.PamWarning;
//import org.kc7bfi.jflac.FLACDecoder;
//import org.kc7bfi.jflac.PCMProcessor;
//import org.kc7bfi.jflac.frame.Frame;
//import org.kc7bfi.jflac.metadata.SeekPoint;
//import org.kc7bfi.jflac.metadata.StreamInfo;
//import org.kc7bfi.jflac.sound.spi.FlacEncoding;
//import org.kc7bfi.jflac.util.ByteData;
import wavFiles.ByteConverter;
/** /**
* Implementation of DaqSystem for reading data from audio files. * Implementation of DaqSystem for reading data from audio files.
* *
* @author Doug Gillespie * @author Doug Gillespie
* @see Acquisition.DaqSystem * @see Acquisition.DaqSystem
* @see Acquisition.AcquisitionProcess * @see Acquisition.AcquisitionProcess
@ -109,7 +108,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
protected PamLabel speedLabel; protected PamLabel speedLabel;
/** /**
* using a system.currentTimeMS not PamCalander time to predict eta. * using a system.currentTimeMS not PamCalander time to predict eta.
*/ */
protected long fileStartTime; protected long fileStartTime;
@ -148,14 +147,14 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
protected ByteConverter byteConverter; protected ByteConverter byteConverter;
protected FileDateDialogStrip fileDateStrip; protected FileDateDialogStrip fileDateStrip;
/** /**
* Sound file types present in the current selections. * Sound file types present in the current selections.
*/ */
private List<SoundFileType> selectedFileTypes; private List<SoundFileType> selectedFileTypes;
/** /**
* Text field for skipping initial few seconds of a file. * Text field for skipping initial few seconds of a file.
*/ */
private JTextField skipSecondsField; private JTextField skipSecondsField;
@ -186,7 +185,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
/** /**
* Gets and where necessary creates ... * Gets and where necessary creates ...
* @return Daq dialog panel. * @return Daq dialog panel.
*/ */
protected JPanel getDialogPanel() { protected JPanel getDialogPanel() {
if (daqDialog == null) { if (daqDialog == null) {
@ -217,7 +216,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
constraints.fill = GridBagConstraints.NONE; constraints.fill = GridBagConstraints.NONE;
constraints.anchor = GridBagConstraints.WEST; constraints.anchor = GridBagConstraints.WEST;
constraints.gridx = 0; constraints.gridx = 0;
addComponent(p, repeat = new JCheckBox("Repeat"), constraints); addComponent(p, repeat = new JCheckBox("Repeat"), constraints);
constraints.gridx = 2; constraints.gridx = 2;
constraints.gridy = 1; constraints.gridy = 1;
constraints.gridwidth = 1; constraints.gridwidth = 1;
@ -234,7 +233,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
p.add(fileDateStrip.getDialogComponent(), constraints); p.add(fileDateStrip.getDialogComponent(), constraints);
// if (SMRUEnable.isEnable()) { // if (SMRUEnable.isEnable()) {
// no reason to hide this option from users. // no reason to hide this option from users.
constraints.gridy++; constraints.gridy++;
constraints.gridx = 0; constraints.gridx = 0;
constraints.gridwidth = 1; constraints.gridwidth = 1;
@ -287,8 +286,8 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
fileNameCombo.removeAllItems(); fileNameCombo.removeAllItems();
String file; String file;
if (fileInputParameters.recentFiles.size() == 0) return; if (fileInputParameters.recentFiles.size() == 0) return;
for (int i = 0; i < fileInputParameters.recentFiles.size(); i++){ for (String element : fileInputParameters.recentFiles) {
file = fileInputParameters.recentFiles.get(i); file = element;
if (file == null || file.length() == 0) continue; if (file == null || file.length() == 0) continue;
fileNameCombo.addItem(file); fileNameCombo.addItem(file);
} }
@ -301,7 +300,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
if (file != null && file.length() > 0) { if (file != null && file.length() > 0) {
fileInputParameters.recentFiles.remove(file); fileInputParameters.recentFiles.remove(file);
fileInputParameters.recentFiles.add(0, file); fileInputParameters.recentFiles.add(0, file);
// check we're not building up too long a list. // check we're not building up too long a list.
while (fileInputParameters.recentFiles.size() > FileInputParameters.MAX_RECENT_FILES) { while (fileInputParameters.recentFiles.size() > FileInputParameters.MAX_RECENT_FILES) {
fileInputParameters.recentFiles.remove(fileInputParameters.recentFiles.size()-1); fileInputParameters.recentFiles.remove(fileInputParameters.recentFiles.size()-1);
fileInputParameters.recentFiles.trimToSize(); fileInputParameters.recentFiles.trimToSize();
@ -317,11 +316,11 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
if (skipSecondsField!=null) { if (skipSecondsField!=null) {
try { try {
Double skipSeconds = Double.valueOf(skipSecondsField.getText())*1000.; // saved in millis. Double skipSeconds = Double.valueOf(skipSecondsField.getText())*1000.; // saved in millis.
fileInputParameters.skipStartFileTime = skipSeconds.longValue(); fileInputParameters.skipStartFileTime = skipSeconds.longValue();
} }
catch (Exception e) { catch (Exception e) {
return false; return false;
} }
} }
@ -335,13 +334,13 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
@Override @Override
public String getSystemName() { public String getSystemName() {
if (fileInputParameters.recentFiles == null) return null; if ((fileInputParameters.recentFiles == null) || (fileInputParameters.recentFiles.size() < 1)) return null;
if (fileInputParameters.recentFiles.size() < 1) return null;
File f = getCurrentFile(); File f = getCurrentFile();
if (f == null) return null; if (f == null) return null;
return f.getName(); return f.getName();
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (e.getSource() == fileSelect) { if (e.getSource() == fileSelect) {
@ -374,8 +373,8 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
javax.swing.filechooser.FileFilter[] filters = fileChooser javax.swing.filechooser.FileFilter[] filters = fileChooser
.getChoosableFileFilters(); .getChoosableFileFilters();
for (int i = 0; i < filters.length; i++) { for (FileFilter filter : filters) {
fileChooser.removeChoosableFileFilter(filters[i]); fileChooser.removeChoosableFileFilter(filter);
} }
fileChooser.addChoosableFileFilter(new PamAudioFileFilter()); fileChooser.addChoosableFileFilter(new PamAudioFileFilter());
@ -392,7 +391,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
} }
/** /**
* Called when user selects a file in the dialog. * Called when user selects a file in the dialog.
* @param newFile * @param newFile
*/ */
public void setNewFile (String newFile) { public void setNewFile (String newFile) {
@ -403,17 +402,16 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
} }
/** /**
* Called when a new file or folder is selected. * Called when a new file or folder is selected.
* @param newFile * @param newFile
*/ */
public void interpretNewFile(String newFile){ public void interpretNewFile(String newFile){
if (newFile == null) return; if ((newFile == null) || (newFile.length() == 0)) return;
if (newFile.length() == 0) return;
File file = new File(newFile); File file = new File(newFile);
setSelectedFileTypes(acquisitionControl.soundFileTypes.getUsedTypes(file)); setSelectedFileTypes(acquisitionControl.soundFileTypes.getUsedTypes(file));
if (file == null) return; if (file == null) return;
// try to work out the date of the file // try to work out the date of the file
@ -430,13 +428,13 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
// acquisitionDialog.NotifyChange(); // acquisitionDialog.NotifyChange();
if (file.isFile() && !file.isHidden() && acquisitionDialog != null) { if (file.isFile() && !file.isHidden() && acquisitionDialog != null) {
try { try {
System.out.println("FileInputSystem - interpretNewFile"); System.out.println("FileInputSystem - interpretNewFile");
AudioInputStream audioStream = PamAudioFileManager.getInstance().getAudioInputStream(file); AudioInputStream audioStream = PamAudioFileManager.getInstance().getAudioInputStream(file);
// // Get additional information from the header if it's a wav file. // // Get additional information from the header if it's a wav file.
// if (WavFileInputStream.class.isAssignableFrom(audioStream.getClass())) { // if (WavFileInputStream.class.isAssignableFrom(audioStream.getClass())) {
// WavHeader wavHeader = ((WavFileInputStream) audioStream).getWavHeader(); // WavHeader wavHeader = ((WavFileInputStream) audioStream).getWavHeader();
// int nChunks = wavHeader.getNumHeadChunks(); // int nChunks = wavHeader.getNumHeadChunks();
// for (int i = 0; i < nChunks; i++) { // for (int i = 0; i < nChunks; i++) {
// WavHeadChunk aChunk = wavHeader.getHeadChunk(i); // WavHeadChunk aChunk = wavHeader.getHeadChunk(i);
@ -447,7 +445,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
if (audioStream instanceof SudAudioInputStream) { if (audioStream instanceof SudAudioInputStream) {
acquisitionControl.getSUDNotificationManager().interpretNewFile(newFile, (SudAudioInputStream) audioStream); acquisitionControl.getSUDNotificationManager().interpretNewFile(newFile, (SudAudioInputStream) audioStream);
} }
AudioFormat audioFormat = audioStream.getFormat(); AudioFormat audioFormat = audioStream.getFormat();
// fileLength = file.length(); // fileLength = file.length();
fileSamples = audioStream.getFrameLength(); fileSamples = audioStream.getFrameLength();
@ -473,7 +471,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
super.setStreamStatus(streamStatus); super.setStreamStatus(streamStatus);
// file has ended, so notify the daq control. // file has ended, so notify the daq control.
if (streamStatus == STREAM_ENDED) { if (streamStatus == STREAM_ENDED) {
// tell the rest of PAMGUARD to stop. // tell the rest of PAMGUARD to stop.
PamController.getInstance().stopLater(); PamController.getInstance().stopLater();
} }
} }
@ -511,24 +509,29 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
return false; return false;
} }
@Override
public Serializable getSettingsReference() { public Serializable getSettingsReference() {
return fileInputParameters; return fileInputParameters;
} }
@Override
public long getSettingsVersion() { public long getSettingsVersion() {
return FileInputParameters.serialVersionUID; return FileInputParameters.serialVersionUID;
} }
@Override
public String getUnitName() { public String getUnitName() {
// return "File Input System"; // return "File Input System";
return acquisitionControl.getUnitName(); return acquisitionControl.getUnitName();
} }
@Override
public String getUnitType() { public String getUnitType() {
// return "Acquisition System"; // return "Acquisition System";
return "File Input System"; return "File Input System";
} }
@Override
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) { public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
// if (PamSettingManager.getInstance().isSettingsUnit(this, pamControlledUnitSettings)) { // if (PamSettingManager.getInstance().isSettingsUnit(this, pamControlledUnitSettings)) {
fileInputParameters = ((FileInputParameters) pamControlledUnitSettings.getSettings()).clone(); fileInputParameters = ((FileInputParameters) pamControlledUnitSettings.getSettings()).clone();
@ -561,16 +564,15 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
// if (fileInputParameters.recentFiles == null) return false; // if (fileInputParameters.recentFiles == null) return false;
// if (fileInputParameters.recentFiles.size() < 1) return false; // if (fileInputParameters.recentFiles.size() < 1) return false;
// String fileName = fileInputParameters.recentFiles.get(0); // String fileName = fileInputParameters.recentFiles.get(0);
if (runFileAnalysis() == false) { if (!runFileAnalysis()) {
return false; return false;
} }
return true; return true;
} }
public File getCurrentFile() { public File getCurrentFile() {
// System.out.println("fileInputParameters: " + fileInputParameters); // System.out.println("fileInputParameters: " + fileInputParameters);
if (fileInputParameters.recentFiles == null) return null; if ((fileInputParameters.recentFiles == null) || (fileInputParameters.recentFiles.size() < 1)) return null;
if (fileInputParameters.recentFiles.size() < 1) return null;
String fileName = fileInputParameters.recentFiles.get(0); String fileName = fileInputParameters.recentFiles.get(0);
return new File(fileName); return new File(fileName);
} }
@ -585,8 +587,8 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
} }
/** /**
* Open the audio stream for processing. * Open the audio stream for processing.
* @return true if audio stream opened correctly. * @return true if audio stream opened correctly.
*/ */
public boolean prepareInputFile() { public boolean prepareInputFile() {
@ -603,7 +605,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
audioStream.close(); audioStream.close();
} }
// System.out.println("FileInputSystem - prepareInputFile"); // System.out.println("FileInputSystem - prepareInputFile");
audioStream = PamAudioFileManager.getInstance().getAudioInputStream(currentFile); audioStream = PamAudioFileManager.getInstance().getAudioInputStream(currentFile);
@ -627,8 +629,8 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
audioFormat = audioStream.getFormat(); audioFormat = audioStream.getFormat();
if (audioFormat==null) { if (audioFormat==null) {
System.err.println("AudioFormat was null: " + currentFile.getAbsolutePath()); System.err.println("AudioFormat was null: " + currentFile.getAbsolutePath());
return false; return false;
} }
// fileLength = currentFile.length(); // fileLength = currentFile.length();
@ -639,8 +641,8 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
fileInputParameters.bitDepth = audioFormat.getSampleSizeInBits(); fileInputParameters.bitDepth = audioFormat.getSampleSizeInBits();
loadByteConverter(audioFormat); loadByteConverter(audioFormat);
// System.out.println("FileInputSystem - prepareInputFile done"); // System.out.println("FileInputSystem - prepareInputFile done");
} catch (UnsupportedAudioFileException ex) { } catch (UnsupportedAudioFileException ex) {
@ -652,7 +654,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); ex.printStackTrace();
return false; return false;
} }
return true; return true;
} }
@ -671,7 +673,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
this.newDataUnits = acquisitionControl.getDaqProcess().getNewDataQueue(); this.newDataUnits = acquisitionControl.getDaqProcess().getNewDataQueue();
// if (this.newDataUnits == null) { // if (this.newDataUnits == null) {
// System.err.println("newDataUnits: == null: "); // System.err.println("newDataUnits: == null: ");
// return false; // return false;
// } // }
@ -679,7 +681,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
String audioFileStr = getCurrentFile()==null? "Null File": getCurrentFile().getAbsolutePath(); String audioFileStr = getCurrentFile()==null? "Null File": getCurrentFile().getAbsolutePath();
String title = "Error loading audio file"; String title = "Error loading audio file";
String msg = "<html><p>There was an error trying to access the audio file </p><b> " + String msg = "<html><p>There was an error trying to access the audio file </p><b> " +
audioFileStr + audioFileStr +
"</b><br><br><p>Please check to ensure that the file exists, and that the path entered in PAMGuard is correct.</p>" + "</b><br><br><p>Please check to ensure that the file exists, and that the path entered in PAMGuard is correct.</p>" +
"<p>Note this error may also indicate that the file is corrupt and unreadable by PAMGuard.</p></html>"; "<p>Note this error may also indicate that the file is corrupt and unreadable by PAMGuard.</p></html>";
@ -707,9 +709,9 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
String audioFileStr = getCurrentFile()==null? "Null File": getCurrentFile().getAbsolutePath(); String audioFileStr = getCurrentFile()==null? "Null File": getCurrentFile().getAbsolutePath();
System.err.println("FileInputSystem: runFileAnalysis: AudioFile format is null: " + audioFileStr); System.err.println("FileInputSystem: runFileAnalysis: AudioFile format is null: " + audioFileStr);
return false; return false;
} }
nChannels = audioFormat.getChannels(); nChannels = audioFormat.getChannels();
@ -733,11 +735,11 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
} }
/** /**
* Interpret the file name to get the file time. * Interpret the file name to get the file time.
* <p>Moved to a separate function so it can be overridden in a special version * <p>Moved to a separate function so it can be overridden in a special version
* for the DCL5 data set. * for the DCL5 data set.
* @param file audio file. * @param file audio file.
* @return time in milliseconds. * @return time in milliseconds.
*/ */
public long getFileStartTime(File file) { public long getFileStartTime(File file) {
// if there is no file, return 0 // if there is no file, return 0
@ -749,11 +751,11 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
public boolean startSystem(AcquisitionControl daqControl) { public boolean startSystem(AcquisitionControl daqControl) {
if (audioStream == null) return false; if (audioStream == null) return false;
dontStop = true; dontStop = true;
fullyStopped = false; fullyStopped = false;
theThread.start(); theThread.start();
@ -767,7 +769,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
public void stopSystem(AcquisitionControl daqControl) { public void stopSystem(AcquisitionControl daqControl) {
/* /*
* This only gets called when daq is stopped manually from the GUI menu. * This only gets called when daq is stopped manually from the GUI menu.
* It does not get called when a file ends. * It does not get called when a file ends.
*/ */
boolean stillRunning = (audioStream != null); boolean stillRunning = (audioStream != null);
@ -813,7 +815,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
/** /**
* FLAC uses such a different way of decoding data to wav and aif * FLAC uses such a different way of decoding data to wav and aif
* that it needs to use it's own reader. * that it needs to use it's own reader.
*/ */
protected void collectFlacData() { protected void collectFlacData() {
FileInputStream fileStream; FileInputStream fileStream;
@ -875,7 +877,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
@Override @Override
public void processPCM(ByteData byteData) { public void processPCM(ByteData byteData) {
if (dontStop == false) { if (!dontStop) {
try { try {
fileStream.close(); // will make the flac reader bomb out ! fileStream.close(); // will make the flac reader bomb out !
} }
@ -914,7 +916,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
sayEta(); sayEta();
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (lastProgressTime > 0 && totalSamples > lastProgressUpdate) { if (lastProgressTime > 0 && totalSamples > lastProgressUpdate) {
double speed = (double) (totalSamples - lastProgressUpdate) / double speed = (double) (totalSamples - lastProgressUpdate) /
getSampleRate() / ((now-lastProgressTime)/1000.); getSampleRate() / ((now-lastProgressTime)/1000.);
speedLabel.setText(String.format(" (%3.1f X RT)", speed)); speedLabel.setText(String.format(" (%3.1f X RT)", speed));
} }
@ -923,7 +925,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
} }
while (newDataUnits.getQueueSize() > 3*nChannels) { while (newDataUnits.getQueueSize() > 3*nChannels) {
if (dontStop == false) break; if (!dontStop) break;
try { try {
Thread.sleep(2); Thread.sleep(2);
} catch (Exception ex) { } catch (Exception ex) {
@ -943,6 +945,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
public class CollectorThread implements Runnable { public class CollectorThread implements Runnable {
@Override
public void run() { public void run() {
if (audioFormat.getEncoding() == FlacEncoding.FLAC) { if (audioFormat.getEncoding() == FlacEncoding.FLAC) {
collectFlacData(); collectFlacData();
@ -985,9 +988,9 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
break; // file read error break; // file read error
} }
while (bytesRead < blockSize) { while (bytesRead < blockSize) {
// for single file operation, don't do anything, but need to have a hook // for single file operation, don't do anything, but need to have a hook
// in here to read multiple files, in which case we may just get the extra // in here to read multiple files, in which case we may just get the extra
// samples from the next file. // samples from the next file.
if (bytesRead == -1) { if (bytesRead == -1) {
bytesRead = 0; bytesRead = 0;
} }
@ -1009,7 +1012,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
} }
if (bytesRead > 0) { if (bytesRead > 0) {
// convert byte array to set of double arrays, one per // convert byte array to set of double arrays, one per
// channel // channel
newSamples = bytesRead / audioFormat.getFrameSize(); newSamples = bytesRead / audioFormat.getFrameSize();
doubleData = new double[nChannels][newSamples]; doubleData = new double[nChannels][newSamples];
int convertedSamples = byteConverter.bytesToDouble(byteArray, doubleData, bytesRead); int convertedSamples = byteConverter.bytesToDouble(byteArray, doubleData, bytesRead);
@ -1038,7 +1041,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
sayEta(); sayEta();
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (lastProgressTime > 0 && totalSamples > lastProgressUpdate) { if (lastProgressTime > 0 && totalSamples > lastProgressUpdate) {
double speed = (double) (totalSamples - lastProgressUpdate) / double speed = (double) (totalSamples - lastProgressUpdate) /
getSampleRate() / ((now-lastProgressTime)/1000.); getSampleRate() / ((now-lastProgressTime)/1000.);
if (speedLabel!=null) speedLabel.setText(String.format(" (%3.1f X RT)", speed)); if (speedLabel!=null) speedLabel.setText(String.format(" (%3.1f X RT)", speed));
} }
@ -1051,7 +1054,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
* unit, then set it's reference to zero. * unit, then set it's reference to zero.
*/ */
while (newDataUnits.getQueueSize() > 3*nChannels) { while (newDataUnits.getQueueSize() > 3*nChannels) {
if (dontStop == false) break; if (!dontStop) break;
try { try {
Thread.sleep(1); Thread.sleep(1);
} catch (Exception ex) { } catch (Exception ex) {
@ -1062,7 +1065,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
totalSamples += newSamples; totalSamples += newSamples;
readFileSamples += newSamples; readFileSamples += newSamples;
} }
else { else {
break; // end of file break; // end of file
} }
@ -1079,10 +1082,10 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
} }
} }
// note the reason why the file has ended. // note the reason why the file has ended.
if (dontStop == false) { // stop button pressed if (!dontStop) { // stop button pressed
setStreamStatus(STREAM_PAUSED); setStreamStatus(STREAM_PAUSED);
} }
else { // file ended, since dont stop is true. else { // file ended, since dont stop is true.
setStreamStatus(STREAM_ENDED); setStreamStatus(STREAM_ENDED);
} }
//acquisitionControl.getDaqProcess().acquisitionStopped(); //acquisitionControl.getDaqProcess().acquisitionStopped();
@ -1094,13 +1097,13 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
} }
/** /**
* Open next file in a list for continuous processing, not the * Open next file in a list for continuous processing, not the
* function that opens a file for normal processing. * function that opens a file for normal processing.
* @param totalSamples * @param totalSamples
* @return * @return
*/ */
protected boolean openNextFile(long totalSamples) { protected boolean openNextFile(long totalSamples) {
if (fileInputParameters.repeatLoop == false) { if (!fileInputParameters.repeatLoop) {
return false; return false;
} }
// otherwise, open the same file again. // otherwise, open the same file again.
@ -1112,7 +1115,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
/** Format one channel of the data in a byte array into a sample array. /** Format one channel of the data in a byte array into a sample array.
*/ */
public static double[] bytesToSamples(byte[] byteArray, long nBytes, int channel, public static double[] bytesToSamples(byte[] byteArray, long nBytes, int channel,
AudioFormat audioFormat) AudioFormat audioFormat)
{ {
int nSamples = (int)(nBytes / audioFormat.getFrameSize()); int nSamples = (int)(nBytes / audioFormat.getFrameSize());
double[] samples = new double[nSamples]; double[] samples = new double[nSamples];
@ -1120,7 +1123,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
int bytesPerSample = ((audioFormat.getSampleSizeInBits() + 7) / 8); int bytesPerSample = ((audioFormat.getSampleSizeInBits() + 7) / 8);
int byteI = channel * bytesPerSample; int byteI = channel * bytesPerSample;
for (int isamp = 0; isamp < nSamples; isamp++) { for (int isamp = 0; isamp < nSamples; isamp++) {
samples[isamp] = samples[isamp] =
getSample(byteArray, byteI, bytesPerSample, audioFormat.isBigEndian()); getSample(byteArray, byteI, bytesPerSample, audioFormat.isBigEndian());
byteI += audioFormat.getFrameSize(); byteI += audioFormat.getFrameSize();
} }
@ -1160,7 +1163,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
} }
/** /**
* Called when all files to be processed have been processed. * Called when all files to be processed have been processed.
*/ */
protected void fileListComplete() { protected void fileListComplete() {
if (GlobalArguments.getParam(PamController.AUTOEXIT) != null) { if (GlobalArguments.getParam(PamController.AUTOEXIT) != null) {
@ -1248,7 +1251,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
/** /**
* Get the acquisition control for the input system * Get the acquisition control for the input system
* @return the acquisition control. * @return the acquisition control.
*/ */
public AcquisitionControl getAquisitionControl() { public AcquisitionControl getAquisitionControl() {
return this.acquisitionControl; return this.acquisitionControl;
@ -1272,7 +1275,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
/** /**
* Called when the file or file list selection is changes and finds a list of all * Called when the file or file list selection is changes and finds a list of all
* sound file types included in the selection. this is only implemented for SUD files * sound file types included in the selection. this is only implemented for SUD files
* at the moment, the idea being to offer some additional functionality. * at the moment, the idea being to offer some additional functionality.
* @param selectedFileTypes the selectedFileTypes to set * @param selectedFileTypes the selectedFileTypes to set
*/ */
public void setSelectedFileTypes(List<SoundFileType> selectedFileTypes) { public void setSelectedFileTypes(List<SoundFileType> selectedFileTypes) {

View File

@ -7,7 +7,6 @@ import java.lang.reflect.Field;
import PamModel.parametermanager.ManagedParameters; import PamModel.parametermanager.ManagedParameters;
import PamModel.parametermanager.PamParameterSet; import PamModel.parametermanager.PamParameterSet;
import PamModel.parametermanager.PrivatePamParameterData; import PamModel.parametermanager.PrivatePamParameterData;
import simulatedAcquisition.SimProcess;
/** /**
* Control parameters for FolderInputSystem * Control parameters for FolderInputSystem
@ -18,11 +17,11 @@ import simulatedAcquisition.SimProcess;
public class FolderInputParameters extends FileInputParameters implements Serializable, Cloneable, ManagedParameters { public class FolderInputParameters extends FileInputParameters implements Serializable, Cloneable, ManagedParameters {
static public final long serialVersionUID = 1; static public final long serialVersionUID = 1;
public boolean subFolders; public boolean subFolders;
public boolean mergeFiles; public boolean mergeFiles;
private String[] selectedFileNames; private String[] selectedFileNames;
/** /**
@ -38,9 +37,9 @@ public class FolderInputParameters extends FileInputParameters implements Serial
} }
/** /**
* Get the list of selected files as strings. If you want them as * Get the list of selected files as strings. If you want them as
* Files, call getselectedFileFiles() * Files, call getselectedFileFiles()
* @return List of file paths in String format. * @return List of file paths in String format.
*/ */
public String[] getSelectedFiles() { public String[] getSelectedFiles() {
return selectedFileNames; return selectedFileNames;
@ -53,7 +52,7 @@ public class FolderInputParameters extends FileInputParameters implements Serial
public void setSelectedFiles(String[] selectedFiles) { public void setSelectedFiles(String[] selectedFiles) {
this.selectedFileNames = selectedFiles; this.selectedFileNames = selectedFiles;
} }
/** /**
* Set the list of selected files. Note that these are now stored as strings * Set the list of selected files. Note that these are now stored as strings
* to avoid some serialisation problems with some subclasses of io.File * to avoid some serialisation problems with some subclasses of io.File
@ -69,11 +68,11 @@ public class FolderInputParameters extends FileInputParameters implements Serial
selectedFileNames[i] = files[i].getAbsolutePath(); selectedFileNames[i] = files[i].getAbsolutePath();
} }
} }
/** /**
* Get the list of selected Files, converted back to File objects * Get the list of selected Files, converted back to File objects
* from strings * from strings
* @return list of selected files. * @return list of selected files.
*/ */
public File[] getSelectedFileFiles() { public File[] getSelectedFileFiles() {
if (selectedFileNames == null) { if (selectedFileNames == null) {

View File

@ -24,16 +24,14 @@ import javax.swing.JPanel;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.Timer; import javax.swing.Timer;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import Acquisition.filedate.FileDateDialogStrip; import Acquisition.filedate.FileDateDialogStrip;
import Acquisition.layoutFX.AcquisitionPaneFX; import Acquisition.layoutFX.AcquisitionPaneFX;
import Acquisition.layoutFX.DAQSettingsPane; import Acquisition.layoutFX.DAQSettingsPane;
import Acquisition.layoutFX.FolderInputPane; import Acquisition.layoutFX.FolderInputPane;
import javafx.application.Platform;
import pamguard.GlobalArguments;
import Acquisition.pamAudio.PamAudioFileManager;
import Acquisition.pamAudio.PamAudioFileFilter; import Acquisition.pamAudio.PamAudioFileFilter;
import Acquisition.pamAudio.PamAudioFileLoader; import Acquisition.pamAudio.PamAudioFileLoader;
import Acquisition.pamAudio.PamAudioSystem; import Acquisition.pamAudio.PamAudioFileManager;
import PamController.DataInputStore; import PamController.DataInputStore;
import PamController.InputStoreInfo; import PamController.InputStoreInfo;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
@ -52,12 +50,14 @@ import PamView.dialog.PamLabel;
import PamView.panel.PamPanel; import PamView.panel.PamPanel;
import PamView.panel.PamProgressBar; import PamView.panel.PamProgressBar;
import PamguardMVC.debug.Debug; import PamguardMVC.debug.Debug;
import javafx.application.Platform;
import pamguard.GlobalArguments;
/** /**
* Read multiple files in sequence. Options exist to either pause and * Read multiple files in sequence. Options exist to either pause and
* restart analysis after each file, or to merge files into one long * restart analysis after each file, or to merge files into one long
* continuous sound stream. * continuous sound stream.
* *
* @author Doug Gillespie * @author Doug Gillespie
* *
*/ */
@ -70,7 +70,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
private boolean running = false; private boolean running = false;
protected ArrayList<WavFileType> allFiles = new ArrayList<WavFileType>(); protected ArrayList<WavFileType> allFiles = new ArrayList<>();
protected int currentFile; protected int currentFile;
@ -85,18 +85,18 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
protected long eta = -1; protected long eta = -1;
private FolderInputParameters folderInputParameters; private FolderInputParameters folderInputParameters;
public static final String GlobalWavFolderArg = "-wavfilefolder"; public static final String GlobalWavFolderArg = "-wavfilefolder";
/** /**
* Text field for skipping initial few seconds of a file. * Text field for skipping initial few seconds of a file.
*/ */
private JTextField skipSecondsField; private JTextField skipSecondsField;
/** /**
* Panel which shows bespoke settings for certain audio loaders. Contains nothing * Panel which shows bespoke settings for certain audio loaders. Contains nothing
* if the audio loader has no settings or no file is selected. * if the audio loader has no settings or no file is selected.
*/ */
protected PamPanel audioLoaderHolder; protected PamPanel audioLoaderHolder;
@ -109,11 +109,11 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
@Override @Override
public boolean prepareInputFile() { public boolean prepareInputFile() {
boolean ans = super.prepareInputFile(); boolean ans = super.prepareInputFile();
if (ans == false && ++currentFile < allFiles.size()) { if (!ans && ++currentFile < allFiles.size()) {
System.out.println("Failed to open sound file. Try again with file " + allFiles.get(currentFile).getName()); System.out.println("Failed to open sound file. Try again with file " + allFiles.get(currentFile).getName());
/* /*
* jumping striaght to the next file messes it up if it thinks the files * jumping striaght to the next file messes it up if it thinks the files
* are continuous, so we HAVE to stop and restart. * are continuous, so we HAVE to stop and restart.
*/ */
// return prepareInputFile(); // return prepareInputFile();
PamController.getInstance().pamStop(); PamController.getInstance().pamStop();
@ -138,7 +138,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
} }
/** /**
* Check to see if acquisition source folder was set in the command line. * Check to see if acquisition source folder was set in the command line.
*/ */
private String[] checkComandLineFolder() { private String[] checkComandLineFolder() {
String globalFolder = GlobalArguments.getParam(GlobalWavFolderArg); String globalFolder = GlobalArguments.getParam(GlobalWavFolderArg);
@ -146,28 +146,29 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
if (globalFolder == null) { if (globalFolder == null) {
return null; return null;
} }
// see if it at least exists, though will we want to do this for Network folders ? // see if it at least exists, though will we want to do this for Network folders ?
File aFile = new File(globalFolder); File aFile = new File(globalFolder);
if (aFile.exists() == false) { if (!aFile.exists()) {
System.err.printf("Command line wav folder \"%s\" does not exist", globalFolder); System.err.printf("Command line wav folder \"%s\" does not exist", globalFolder);
// return null; // return null;
} }
String[] selList = {globalFolder}; 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 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. // need to worry about how to wait for this since it's starting in a different thread.
//makeSelFileList(); //makeSelFileList();
return selList; return selList;
} }
/** /**
* Restarts after a file has ended when processing multiple files. * Restarts after a file has ended when processing multiple files.
* 27 Jan 2011 - this now reschedules in the AWT thread * 27 Jan 2011 - this now reschedules in the AWT thread
* @author Doug Gillespie * @author Doug Gillespie
* *
*/ */
class RestartTimer implements ActionListener { class RestartTimer implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// System.out.println("Restart later time action"); // System.out.println("Restart later time action");
@ -177,8 +178,8 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
} }
} }
@Override @Override
protected JPanel createDaqDialogPanel() { protected JPanel createDaqDialogPanel() {
JPanel p = new JPanel(); JPanel p = new JPanel();
@ -247,7 +248,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
} }
// if (SMRUEnable.isEnable()) { // if (SMRUEnable.isEnable()) {
// no reason to hide this option from users. // no reason to hide this option from users.
constraints.gridy++; constraints.gridy++;
constraints.gridx = 0; constraints.gridx = 0;
constraints.gridwidth = 1; constraints.gridwidth = 1;
@ -259,7 +260,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
// } // }
//panel to show bespoke settings for certain audio loaders. //panel to show bespoke settings for certain audio loaders.
constraints.anchor = GridBagConstraints.WEST; constraints.anchor = GridBagConstraints.WEST;
constraints.gridx = 0; constraints.gridx = 0;
constraints.gridy++; constraints.gridy++;
@ -271,7 +272,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
return p; return p;
} }
class FileComboListener implements ActionListener { class FileComboListener implements ActionListener {
@Override @Override
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
@ -292,12 +293,12 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
checkFileHeaders(); checkFileHeaders();
} }
} }
/** /**
* Checks file length matched actual file data length and repairs if necessary. * Checks file length matched actual file data length and repairs if necessary.
*/ */
public void checkFileHeaders() { public void checkFileHeaders() {
CheckWavFileHeaders.showDialog(acquisitionDialog, this); CheckWavFileHeaders.showDialog(acquisitionDialog, this);
@ -306,13 +307,14 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
class FindAudioFolder implements ActionListener { class FindAudioFolder implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
selectFolder(); selectFolder();
} }
} }
@Override @Override
public void setSelected(boolean select) { public void setSelected(boolean select) {
@ -323,15 +325,15 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
} }
/** /**
* Make a list of wav files within a folder. In some circumstances this can be a list * 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 * of actual files in a folder. Also needs to handle the possibility of it using
* a globally set folder name. * a globally set folder name.
* @return flag to indicate...nothing? * @return flag to indicate...nothing?
*/ */
public int makeSelFileList() { public int makeSelFileList() {
String[] selection = checkComandLineFolder(); String[] selection = checkComandLineFolder();
if (selection == null) { if (selection == null) {
if (fileInputParameters.recentFiles == null || fileInputParameters.recentFiles.size() < 1) { if (fileInputParameters.recentFiles == null || fileInputParameters.recentFiles.size() < 1) {
return 0; return 0;
@ -346,9 +348,9 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
} }
return makeSelFileList(selection); return makeSelFileList(selection);
} }
/** /**
* Make a list of wav files within a folder. * Make a list of wav files within a folder.
* @param rootList * @param rootList
* @return * @return
*/ */
@ -356,22 +358,22 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
// File[] selectedFiles = folderInputParameters.getSelectedFiles(); // File[] selectedFiles = folderInputParameters.getSelectedFiles();
// if (selectedFiles.length == 1 && selectedFiles[0].isDirectory()) { // if (selectedFiles.length == 1 && selectedFiles[0].isDirectory()) {
// String folderName = fileInputParameters.recentFiles.get(0); // String folderName = fileInputParameters.recentFiles.get(0);
//Swing calls a dialog with progress bar from the wavListWorker //Swing calls a dialog with progress bar from the wavListWorker
wavListStart = System.currentTimeMillis(); wavListStart = System.currentTimeMillis();
if (folderInputPane==null) { if (folderInputPane==null) {
//Swing way //Swing way
wavListWorker.startFileListProcess(PamController.getMainFrame(), rootList, wavListWorker.startFileListProcess(PamController.getMainFrame(), rootList,
folderInputParameters.subFolders, true); folderInputParameters.subFolders, true);
} }
else { else {
//FX system //FX system
PamWorker<FileListData<WavFileType>> worker = wavListWorker.makeFileListProcess(rootList, folderInputParameters.subFolders, true); PamWorker<FileListData<WavFileType>> worker = wavListWorker.makeFileListProcess(rootList, folderInputParameters.subFolders, true);
folderInputPane.setFileWorker(worker); folderInputPane.setFileWorker(worker);
if (worker!=null) worker.start(); if (worker!=null) worker.start();
} }
return 0; return 0;
} }
@ -413,7 +415,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
// folderProgress.setValue(0); // folderProgress.setValue(0);
// //
// Collections.sort(allFiles); // Collections.sort(allFiles);
// //
// return allFiles.size(); // return allFiles.size();
// //
// } // }
@ -463,9 +465,9 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
if (ans == JFileChooser.APPROVE_OPTION) { if (ans == JFileChooser.APPROVE_OPTION) {
/* /*
* if it's a single directory that's been selected, then * if it's a single directory that's been selected, then
* set that with setNewFile. If multiple files and directories * set that with setNewFile. If multiple files and directories
* are accepted, select the parent directory of all of them. * are accepted, select the parent directory of all of them.
*/ */
File[] files = fc.getSelectedFiles(); File[] files = fc.getSelectedFiles();
if (files.length <= 0) return; if (files.length <= 0) return;
@ -477,12 +479,12 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
File aFile = files[0]; File aFile = files[0];
setNewFile(aFile.getAbsolutePath()); setNewFile(aFile.getAbsolutePath());
} }
/* /*
* The file chooser is returning sub classes of File which are not * The file chooser is returning sub classes of File which are not
* serialisable, so we can't use them. We need to convert their * serialisable, so we can't use them. We need to convert their
* names to strings, which can be safely serialized. This will * names to strings, which can be safely serialized. This will
* all happen in FolderInputParameters. * all happen in FolderInputParameters.
*/ */
folderInputParameters.setSelectedFiles(fc.getSelectedFiles()); folderInputParameters.setSelectedFiles(fc.getSelectedFiles());
@ -500,12 +502,12 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
} }
long wavListStart; long wavListStart;
/** /**
* Creates a list of wav files. * Creates a list of wav files.
*/ */
WavListWorker wavListWorker = new WavListWorker(new WavListReceiver()); WavListWorker wavListWorker = new WavListWorker(new WavListReceiver());
private class WavListReceiver implements WavListUser { private class WavListReceiver implements WavListUser {
@Override @Override
@ -522,8 +524,8 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
} }
/* /*
* don't actually need to do anything ? Could make a new list, but do it from what's in the * don't actually need to do anything ? Could make a new list, but do it from what's in the
* folder parameters, not the file parameters. do nothing here, or it gets too complicated. * folder parameters, not the file parameters. do nothing here, or it gets too complicated.
* Call the search function from the file select part of the dialot. * Call the search function from the file select part of the dialot.
*/ */
// test the new Wav list worker ... // test the new Wav list worker ...
@ -533,31 +535,31 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
} }
/** /**
* Callback when the file list has completed it's background task. * Callback when the file list has completed it's background task.
* @param fileListData * @param fileListData
*/ */
public void newFileList(FileListData<WavFileType> fileListData) { public void newFileList(FileListData<WavFileType> fileListData) {
// System.out.printf("Wav list recieved with %d files after %d millis\n", // System.out.printf("Wav list recieved with %d files after %d millis\n",
// fileListData.getFileCount(), System.currentTimeMillis() - wavListStart); // fileListData.getFileCount(), System.currentTimeMillis() - wavListStart);
allFiles = fileListData.getListCopy(); allFiles = fileListData.getListCopy();
List<WavFileType> asList = allFiles; List<WavFileType> asList = allFiles;
setSelectedFileTypes(acquisitionControl.soundFileTypes.getUsedTypes(allFiles)); setSelectedFileTypes(acquisitionControl.soundFileTypes.getUsedTypes(allFiles));
//set the date of the first file. //set the date of the first file.
setFileDateText(); setFileDateText();
//set any bespoke options for the files to be laoded. //set any bespoke options for the files to be laoded.
setFileOptionPanel(); setFileOptionPanel();
// also open up the first file and get the sample rate and number of channels from it // also open up the first file and get the sample rate and number of channels from it
// and set these // and set these
File file = getCurrentFile(); File file = getCurrentFile();
if (file == null) return; if (file == null) return;
AudioInputStream audioStream; AudioInputStream audioStream;
/****Swing GUI stuff****/ /****Swing GUI stuff****/
if (file.isFile() && !file.isHidden() && acquisitionDialog != null) { if (file.isFile() && !file.isHidden() && acquisitionDialog != null) {
//Hidden files should not be used in analysis... //Hidden files should not be used in analysis...
@ -574,31 +576,31 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
System.err.println("Error in file " + file.getAbsolutePath() + " " + Ex.getLocalizedMessage()); System.err.println("Error in file " + file.getAbsolutePath() + " " + Ex.getLocalizedMessage());
} }
} }
// set the min and max of the folder progress bar // set the min and max of the folder progress bar
folderProgress.setMinimum(0); folderProgress.setMinimum(0);
folderProgress.setMaximum(allFiles.size()); folderProgress.setMaximum(allFiles.size());
/****FX GUI stuff****/ /****FX GUI stuff****/
if (folderInputPane!=null) { if (folderInputPane!=null) {
Platform.runLater(()->{ Platform.runLater(()->{
folderInputPane.newFileList(fileListData); folderInputPane.newFileList(fileListData);
}); });
} }
} }
/** /**
* Fudge function so that the RonaInputsystem can always fudge the number * Fudge function so that the RonaInputsystem can always fudge the number
* of channels to be 7. * of channels to be 7.
* @param nChannels * @param nChannels
* @return * @return
*/ */
protected int fudgeNumChannels(int nChannels) { protected int fudgeNumChannels(int nChannels) {
return nChannels; return nChannels;
} }
/** /**
* Set bespoke options for certain file types. * Set bespoke options for certain file types.
*/ */
public void setFileOptionPanel() { public void setFileOptionPanel() {
getDialogPanel(); // make sure panel is created getDialogPanel(); // make sure panel is created
@ -606,8 +608,8 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
audioLoaderHolder.removeAll(); audioLoaderHolder.removeAll();
if (allFiles.size() > 0) { if (allFiles.size() > 0) {
//Get all the audio file laoders that will be used for this list of files. Usually //Get all the audio file laoders that will be used for this list of files. Usually
//just one but possible that there can be mixed files. //just one but possible that there can be mixed files.
ArrayList<PamAudioFileLoader> loaders = PamAudioFileManager.getInstance().getAudioFileLoaders(allFiles); ArrayList<PamAudioFileLoader> loaders = PamAudioFileManager.getInstance().getAudioFileLoaders(allFiles);
GridBagConstraints constraints = new GridBagConstraints(); GridBagConstraints constraints = new GridBagConstraints();
@ -627,7 +629,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
} }
/** /**
* Show the date of the first file in the dialog. * Show the date of the first file in the dialog.
*/ */
public void setFileDateText() { public void setFileDateText() {
if (allFiles.size() > 0) { if (allFiles.size() > 0) {
@ -670,9 +672,9 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
@Override @Override
protected boolean openNextFile(long totalSamples) { protected boolean openNextFile(long totalSamples) {
boolean ans = false; boolean ans = false;
if (folderInputParameters.mergeFiles == false) return false; if (!folderInputParameters.mergeFiles) return false;
long currFileStart = 0; long currFileStart = 0;
long currFileLength = 0; long currFileLength = 0;
long currFileEnd = 0; long currFileEnd = 0;
@ -692,7 +694,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
} }
if (currFileEnd == 0) { if (currFileEnd == 0) {
// System.out.println("OpenNextfile " + currentFile + " " + allFiles.get(currentFile).getName()); // System.out.println("OpenNextfile " + currentFile + " " + allFiles.get(currentFile).getName());
// also check to see if the start time of the next file is the same as the // also check to see if the start time of the next file is the same as the
// end time of the current file. // end time of the current file.
currFileEnd = PamCalendar.getTimeInMillis(); currFileEnd = PamCalendar.getTimeInMillis();
long lastBit = (long) ((blockSamples * 1000L) / getSampleRate()); long lastBit = (long) ((blockSamples * 1000L) / getSampleRate());
@ -705,22 +707,22 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
currentFile--; currentFile--;
return false; return false;
/* /*
* Return since it's not possible to merge this file into the * Return since it's not possible to merge this file into the
* next one. In this instance, DAQ will restart, and the currentfile * next one. In this instance, DAQ will restart, and the currentfile
* counter will increment elsewhere. * counter will increment elsewhere.
*/ */
} }
setFolderProgress(); setFolderProgress();
// sayEta(); // sayEta();
/* /*
* I think that here, we just need a check of the file. the prepareInputFile in * I think that here, we just need a check of the file. the prepareInputFile in
* this class will (on failure) move straight to the next file and also issue a * this class will (on failure) move straight to the next file and also issue a
* stop/start, which is not good if it's trying a continuous file, where this is * stop/start, which is not good if it's trying a continuous file, where this is
* being called, if false is returned it should manage moving onto the next file by * being called, if false is returned it should manage moving onto the next file by
* itself if we use the super.prep .... * itself if we use the super.prep ....
*/ */
ans = super.prepareInputFile(); ans = super.prepareInputFile();
if (ans == false) { if (!ans) {
return false; return false;
} }
currentFileStart = System.currentTimeMillis(); currentFileStart = System.currentTimeMillis();
@ -728,11 +730,11 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
// acquisitionControl.getDaqProcess().setSampleRate(currentSampleRate = audioFormat.getSampleRate(), true); // acquisitionControl.getDaqProcess().setSampleRate(currentSampleRate = audioFormat.getSampleRate(), true);
// } // }
/** /**
* Send a dataunit to the database to mark the file changeover. * Send a dataunit to the database to mark the file changeover.
*/ */
DaqStatusDataUnit daqStatusDataUnit = new DaqStatusDataUnit(currentFileStart, currentFileStart, currentFileStart, DaqStatusDataUnit daqStatusDataUnit = new DaqStatusDataUnit(currentFileStart, currentFileStart, currentFileStart,
totalSamples, null, "NextFile", "File End", totalSamples, null, "NextFile", "File End",
acquisitionControl.acquisitionParameters, getSystemName(), totalSamples/getSampleRate(), 0); acquisitionControl.acquisitionParameters, getSystemName(), totalSamples/getSampleRate(), 0);
acquisitionControl.getAcquisitionProcess().getDaqStatusDataBlock().addPamData(daqStatusDataUnit); acquisitionControl.getAcquisitionProcess().getDaqStatusDataBlock().addPamData(daqStatusDataUnit);
} }
return ans; return ans;
@ -746,14 +748,14 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
} }
if (currentFile < allFiles.size()) { if (currentFile < allFiles.size()) {
// only restart if the file ended - not if it stopped // only restart if the file ended - not if it stopped
if (getStreamStatus() == STREAM_ENDED && PamController.getInstance().isManualStop() == false) { if (getStreamStatus() == STREAM_ENDED && !PamController.getInstance().isManualStop()) {
// System.out.println(String.format("Start new file timer (file %d/%d)",currentFile+1,allFiles.size())); // System.out.println(String.format("Start new file timer (file %d/%d)",currentFile+1,allFiles.size()));
newFileTimer.start(); newFileTimer.start();
} }
} }
calculateETA(); calculateETA();
setFolderProgress(); setFolderProgress();
if (currentFile > 0 && currentFile >= allFiles.size()) { if (currentFile > 0 && currentFile >= allFiles.size()) {
fileListComplete(); fileListComplete();
} }
@ -776,7 +778,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
PamProgressBar folderProgress = new PamProgressBar(PamProgressBar.defaultColor); PamProgressBar folderProgress = new PamProgressBar(PamProgressBar.defaultColor);
private FolderInputPane folderInputPane; private FolderInputPane folderInputPane;
@Override @Override
public Component getStatusBarComponent() { public Component getStatusBarComponent() {
@ -817,24 +819,24 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
currentFile = 0; currentFile = 0;
if (skipSecondsField!=null) { if (skipSecondsField!=null) {
try { try {
Double skipSeconds = Double.valueOf(skipSecondsField.getText())*1000.; // saved in millis. Double skipSeconds = Double.valueOf(skipSecondsField.getText())*1000.; // saved in millis.
folderInputParameters.skipStartFileTime = skipSeconds.longValue(); folderInputParameters.skipStartFileTime = skipSeconds.longValue();
} }
catch (Exception e) { catch (Exception e) {
return false; return false;
} }
} }
//get bespoke paramters from selected audio loaders. //get bespoke paramters from selected audio loaders.
ArrayList<PamAudioFileLoader> loaders = PamAudioFileManager.getInstance().getAudioFileLoaders(allFiles); ArrayList<PamAudioFileLoader> loaders = PamAudioFileManager.getInstance().getAudioFileLoaders(allFiles);
for (PamAudioFileLoader loader : loaders) { for (PamAudioFileLoader loader : loaders) {
if (loader.getSettingsPane()!=null) { if (loader.getSettingsPane()!=null) {
loader.getSettingsPane().getParams(); loader.getSettingsPane().getParams();
} }
} }
return super.dialogGetParams(); return super.dialogGetParams();
} }
@ -845,7 +847,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
// would hold a null. The system type is used by the getParameterSet method to decide // would hold a null. The system type is used by the getParameterSet method to decide
// whether or not to include the parameters in the XML output // whether or not to include the parameters in the XML output
if (fileInputParameters.systemType==null) fileInputParameters.systemType=getSystemType(); if (fileInputParameters.systemType==null) fileInputParameters.systemType=getSystemType();
super.dialogSetParams(); super.dialogSetParams();
subFolders.setSelected(folderInputParameters.subFolders); subFolders.setSelected(folderInputParameters.subFolders);
mergeFiles.setSelected(folderInputParameters.mergeFiles); mergeFiles.setSelected(folderInputParameters.mergeFiles);
@ -853,7 +855,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
if (skipSecondsField!=null) { if (skipSecondsField!=null) {
skipSecondsField.setText(String.format("%.1f", fileInputParameters.skipStartFileTime/1000.)); skipSecondsField.setText(String.format("%.1f", fileInputParameters.skipStartFileTime/1000.));
} }
} }
@Override @Override
@ -918,14 +920,15 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
/****JavaFX bits***/ /****JavaFX bits***/
@Override
public DAQSettingsPane getDAQSpecificPane(AcquisitionPaneFX acquisitionPaneFX) { public DAQSettingsPane getDAQSpecificPane(AcquisitionPaneFX acquisitionPaneFX) {
if (folderInputPane==null) this.folderInputPane = new FolderInputPane(this, acquisitionPaneFX); if (folderInputPane==null) this.folderInputPane = new FolderInputPane(this, acquisitionPaneFX);
return folderInputPane; return folderInputPane;
} }
/** /**
* Called by AcquisitionDialog.SetParams so that the dialog node can update it's * Called by AcquisitionDialog.SetParams so that the dialog node can update it's
* fields. * fields.
*/ */
public void dialogFXSetParams() { public void dialogFXSetParams() {
folderInputPane.setParams(folderInputParameters); folderInputPane.setParams(folderInputParameters);
@ -933,7 +936,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
@Override @Override
public InputStoreInfo getStoreInfo(boolean detail) { public InputStoreInfo getStoreInfo(boolean detail) {
System.out.println("FolderInputSystem: Get store info start:"); System.out.println("FolderInputSystem: Get store info start:");
if (allFiles == null || allFiles.size() == 0) { if (allFiles == null || allFiles.size() == 0) {
return null; return null;
} }
@ -963,12 +966,12 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
lastFileEnd = allFileStarts[i] + (long) (lastFile.getDurationInSeconds()*1000.); lastFileEnd = allFileStarts[i] + (long) (lastFile.getDurationInSeconds()*1000.);
} }
} }
storeInfo.setFirstFileStart(firstFileStart); // just incase changed. storeInfo.setFirstFileStart(firstFileStart); // just incase changed.
storeInfo.setLastFileEnd(lastFileEnd); // just incase changed storeInfo.setLastFileEnd(lastFileEnd); // just incase changed
storeInfo.setFileStartTimes(allFileStarts); storeInfo.setFileStartTimes(allFileStarts);
storeInfo.setFileEndTimes(allFileEnds); storeInfo.setFileEndTimes(allFileEnds);
} }
System.out.println("FolderInputSystem: Get store info complete:"); System.out.println("FolderInputSystem: Get store info complete:");
return storeInfo; return storeInfo;
} }
@ -977,8 +980,8 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
/** /**
* Called from the reprocess manager just before PAMGuard starts with a time * Called from the reprocess manager just before PAMGuard starts with a time
* we want to process from. This should be equal to the start of one of the files * we want to process from. This should be equal to the start of one of the files
* so all we have to do (in principle) is to set the currentfile to that index and * so all we have to do (in principle) is to set the currentfile to that index and
* processing will continue from there. * processing will continue from there.
*/ */
if (allFiles == null || allFiles.size() == 0) { if (allFiles == null || allFiles.size() == 0) {
System.out.println("Daq setanal start time: no files to check against"); System.out.println("Daq setanal start time: no files to check against");
@ -987,7 +990,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
System.out.printf("setAnalysisStarttTime: checking %d files for start time of %s\n", allFiles.size(), PamCalendar.formatDBDateTime(startTime)); 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 * 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. * correctly to not over confuse the batch processing system.
*/ */
long lastFileTime = getFileStartTime(allFiles.get(allFiles.size()-1).getAbsoluteFile()); long lastFileTime = getFileStartTime(allFiles.get(allFiles.size()-1).getAbsoluteFile());
if (startTime > lastFileTime) { if (startTime > lastFileTime) {
@ -1008,13 +1011,14 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
return true; return true;
} }
} }
return false; return false;
} }
/** /**
* Get a status update for batch processing. * Get a status update for batch processing.
*/ */
@Override
public String getBatchStatus() { public String getBatchStatus() {
int nFiles = 0; int nFiles = 0;
if (allFiles != null) { if (allFiles != null) {
@ -1025,8 +1029,8 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
String bs = String.format("%d,%d,%d,%s", nFiles,currentFile,generalStatus,currFile); String bs = String.format("%d,%d,%d,%s", nFiles,currentFile,generalStatus,currFile);
return bs; return bs;
} }
} }

View File

@ -10,18 +10,18 @@ public class KETime {
/** /**
* Unpack the KE buoy data format. This has a decimal number of * Unpack the KE buoy data format. This has a decimal number of
* seconds, but is otherwise quite rational. * seconds, but is otherwise quite rational.
* @param numPart - the date string * @param numPart - the date string
* @return time in millis * @return time in millis
*/ */
public static long getKEBuoyTime(String numPart) { public static long getKEBuoyTime(String numPart) {
int dotPos = numPart.indexOf('.', 0); int dotPos = numPart.indexOf('.', 0);
if (dotPos < 0) { if (dotPos < 0) {
return Long.MIN_VALUE; return Long.MIN_VALUE;
} }
String mainBit = numPart.substring(0, dotPos); String mainBit = numPart.substring(0, dotPos);
String fracPart = numPart.substring(dotPos); String fracPart = numPart.substring(dotPos);
String fmt = "yyyyMMdd_HHmmss"; String fmt = "yyyyMMdd_HHmmss";
@ -42,32 +42,32 @@ public class KETime {
cl.setTimeZone(TimeZone.getTimeZone("GMT")); cl.setTimeZone(TimeZone.getTimeZone("GMT"));
cl.setTime(d); cl.setTime(d);
long millis = cl.getTimeInMillis(); long millis = cl.getTimeInMillis();
try { try {
double fracBit = Double.valueOf(fracPart); double fracBit = Double.valueOf(fracPart);
millis += (long) (fracBit*1000.); millis += (long) (fracBit*1000.);
} }
catch (NumberFormatException e) { catch (NumberFormatException e) {
} }
return millis; return millis;
} }
/** /**
* Unpack the PLA buoy data format (superseeds KE Buoy). This has a nanosecond value after the seconds * Unpack the PLA buoy data format (superseeds KE Buoy). This has a nanosecond value after the seconds
* e.g. would be ddmmyyyy_HHMMSS_FFFFF in MATLAB format. * e.g. would be ddmmyyyy_HHMMSS_FFFFF in MATLAB format.
* @param numPart - the date string * @param numPart - the date string
* @return time in millis * @return time in millis
*/ */
public static long getPLABuoyTime(String numPart) { public static long getPLABuoyTime(String numPart) {
String[] timeSections=numPart.split("_"); String[] timeSections=numPart.split("_");
//got have a data section, time section and then nanosecond section //got have a data section, time section and then nanosecond section
if (timeSections.length!=3 || timeSections[2].length()!=6){ if (timeSections.length!=3 || timeSections[2].length()!=6){
return Long.MIN_VALUE; return Long.MIN_VALUE;
} }
String mainBit = timeSections[0]+timeSections[1]; String mainBit = timeSections[0]+timeSections[1];
String fracPart = timeSections[2]; String fracPart = timeSections[2];
String fmt = "yyyyMMddHHmmss"; String fmt = "yyyyMMddHHmmss";
@ -88,13 +88,13 @@ public class KETime {
cl.setTimeZone(TimeZone.getTimeZone("GMT")); cl.setTimeZone(TimeZone.getTimeZone("GMT"));
cl.setTime(d); cl.setTime(d);
long millis = cl.getTimeInMillis(); long millis = cl.getTimeInMillis();
try { try {
double fracBit = Double.valueOf(fracPart); double fracBit = Double.valueOf(fracPart);
millis += (long) (fracBit/1000.); millis += (long) (fracBit/1000.);
} }
catch (NumberFormatException e) { catch (NumberFormatException e) {
} }
return millis; return millis;

View File

@ -8,24 +8,21 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import PamDetection.RawDataUnit; import PamDetection.RawDataUnit;
import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;
import PamguardMVC.PamRawDataBlock; import PamguardMVC.PamRawDataBlock;
import binaryFileStorage.BinaryDataSource; import binaryFileStorage.BinaryDataSource;
import binaryFileStorage.BinaryHeader; import binaryFileStorage.BinaryHeader;
import binaryFileStorage.BinaryObjectData; import binaryFileStorage.BinaryObjectData;
import binaryFileStorage.BinaryOutputStream;
import binaryFileStorage.ModuleFooter; import binaryFileStorage.ModuleFooter;
import binaryFileStorage.ModuleHeader; import binaryFileStorage.ModuleHeader;
import binaryFileStorage.PackedBinaryObject;
/** /**
* Data source for Raw acoustic data. This is set up to NEVER * Data source for Raw acoustic data. This is set up to NEVER
* be written to binary storage files - WAV files are way better * be written to binary storage files - WAV files are way better
* for that. The purpose of this class is to enable sending of * for that. The purpose of this class is to enable sending of
* raw audio data over the network. Currently assumes 16 bit audio, * raw audio data over the network. Currently assumes 16 bit audio,
* but may make this more flexible in the future is higher res ADC's * but may make this more flexible in the future is higher res ADC's
* are in use within PAMGUARD. * are in use within PAMGUARD.
* @author Doug Gillespie * @author Doug Gillespie
* *
*/ */
@ -35,7 +32,7 @@ public class RawDataBinaryDataSource extends BinaryDataSource {
private ByteArrayOutputStream bos; private ByteArrayOutputStream bos;
private DataOutputStream dos; private DataOutputStream dos;
private long offsetSamples; private long offsetSamples;
public RawDataBinaryDataSource(PamRawDataBlock sisterDataBlock) { public RawDataBinaryDataSource(PamRawDataBlock sisterDataBlock) {
super(sisterDataBlock); super(sisterDataBlock);
setDoBinaryStore(false); setDoBinaryStore(false);
@ -72,8 +69,8 @@ public class RawDataBinaryDataSource extends BinaryDataSource {
@Override @Override
public BinaryObjectData getPackedData(PamDataUnit pamDataUnit) { public BinaryObjectData getPackedData(PamDataUnit pamDataUnit) {
/** /**
* Pack a raw data unit. N.B. Raw data units in PAMGAURD only contain a single * Pack a raw data unit. N.B. Raw data units in PAMGAURD only contain a single
* channel of data. The channel number will need to be packed into the header. * channel of data. The channel number will need to be packed into the header.
*/ */
RawDataUnit rawDataUnit = (RawDataUnit) pamDataUnit; RawDataUnit rawDataUnit = (RawDataUnit) pamDataUnit;
int duration = rawDataUnit.getSampleDuration().intValue(); int duration = rawDataUnit.getSampleDuration().intValue();
@ -98,14 +95,14 @@ public class RawDataBinaryDataSource extends BinaryDataSource {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return new BinaryObjectData(0, bos.toByteArray()); return new BinaryObjectData(0, bos.toByteArray());
} }
@Override @Override
public PamDataUnit sinkData(BinaryObjectData binaryObjectData, public PamDataUnit sinkData(BinaryObjectData binaryObjectData,
BinaryHeader bh, int moduleVersion) { BinaryHeader bh, int moduleVersion) {
ByteArrayInputStream bis = new ByteArrayInputStream(binaryObjectData.getData(), ByteArrayInputStream bis = new ByteArrayInputStream(binaryObjectData.getData(),
0, binaryObjectData.getDataLength()); 0, binaryObjectData.getDataLength());
DataInputStream dis = new DataInputStream(bis); DataInputStream dis = new DataInputStream(bis);
long startSample; long startSample;
@ -117,15 +114,15 @@ public class RawDataBinaryDataSource extends BinaryDataSource {
try { try {
startSample = dis.readLong(); startSample = dis.readLong();
/* /*
* Muck a bit with the timing so that within this network received * Muck a bit with the timing so that within this network received
* data, sample counts get restarted at 0. This will ensure that * data, sample counts get restarted at 0. This will ensure that
* millisecond and ADC count timings end up about right for the data. * millisecond and ADC count timings end up about right for the data.
*/ */
if (offsetSamples == 0) { if (offsetSamples == 0) {
offsetSamples = startSample; offsetSamples = startSample;
} }
startSample -= offsetSamples; // subtract off the offset from the sample number. startSample -= offsetSamples; // subtract off the offset from the sample number.
channelMap = dis.readInt(); channelMap = dis.readInt();
duration = dis.readInt(); duration = dis.readInt();
nBytes = dis.readByte(); nBytes = dis.readByte();
@ -142,8 +139,8 @@ public class RawDataBinaryDataSource extends BinaryDataSource {
} }
RawDataUnit rawDataUnit = new RawDataUnit(binaryObjectData.getTimeMilliseconds(), channelMap, startSample, duration); RawDataUnit rawDataUnit = new RawDataUnit(binaryObjectData.getTimeMilliseconds(), channelMap, startSample, duration);
rawDataUnit.setRawData(rawData, true); rawDataUnit.setRawData(rawData, true);
// System.out.println("raw data arrived to unpack on channels " + // System.out.println("raw data arrived to unpack on channels " +
// channelMap + " sample " + startSample); // channelMap + " sample " + startSample);
return rawDataUnit; return rawDataUnit;
} }

View File

@ -10,11 +10,9 @@ import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.UnsupportedAudioFileException; import javax.sound.sampled.UnsupportedAudioFileException;
import javax.sound.sampled.AudioFormat.Encoding;
import javax.swing.filechooser.FileFilter;
//import org.kc7bfi.jflac.FLACDecoder; //import org.kc7bfi.jflac.FLACDecoder;
//import org.kc7bfi.jflac.PCMProcessor; //import org.kc7bfi.jflac.PCMProcessor;
@ -25,27 +23,26 @@ import org.jflac.PCMProcessor;
import org.jflac.metadata.StreamInfo; import org.jflac.metadata.StreamInfo;
import org.jflac.util.ByteData; import org.jflac.util.ByteData;
import wavFiles.ByteConverter;
import Acquisition.pamAudio.PamAudioFileManager;
import Acquisition.pamAudio.PamAudioFileFilter; import Acquisition.pamAudio.PamAudioFileFilter;
import Acquisition.pamAudio.PamAudioSystem; import Acquisition.pamAudio.PamAudioFileManager;
import PamDetection.RawDataUnit; import PamDetection.RawDataUnit;
import PamUtils.FileParts; import PamUtils.FileParts;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
import PamUtils.PamFileFilter; import PamUtils.PamFileFilter;
import PamUtils.PamUtils; import PamUtils.PamUtils;
import wavFiles.ByteConverter;
/** /**
* Bespoke system for handling data from the Rona hydrophone array which * Bespoke system for handling data from the Rona hydrophone array which
* consists of sets of seven files, each with different ends in th ename. * consists of sets of seven files, each with different ends in th ename.
* @author Doug * @author Doug
* *
*/ */
public class RonaInputSystem extends FolderInputSystem { public class RonaInputSystem extends FolderInputSystem {
private static final int RONACHANNELS = 0x21; // channels 5 and 0 private static final int RONACHANNELS = 0x21; // channels 5 and 0
private static final int NCHANNELS = PamUtils.getNumChannels(RONACHANNELS); private static final int NCHANNELS = PamUtils.getNumChannels(RONACHANNELS);
private AudioInputStream[] audioStreams = new AudioInputStream[NCHANNELS]; private AudioInputStream[] audioStreams = new AudioInputStream[NCHANNELS];
@ -58,9 +55,9 @@ public class RonaInputSystem extends FolderInputSystem {
private int readyMask = PamUtils.makeChannelMap(NCHANNELS); private int readyMask = PamUtils.makeChannelMap(NCHANNELS);
private int runningChannels; private int runningChannels;
private long lastFileTime = 0; private long lastFileTime = 0;
public static final String systemType = "Rona File Folders"; public static final String systemType = "Rona File Folders";
public RonaInputSystem(AcquisitionControl acquisitionControl) { public RonaInputSystem(AcquisitionControl acquisitionControl) {
@ -98,7 +95,7 @@ public class RonaInputSystem extends FolderInputSystem {
@Override @Override
public boolean accept(File f) { public boolean accept(File f) {
if (super.accept(f) == false) { if (!super.accept(f)) {
return false; return false;
} }
if (f.isDirectory()) { if (f.isDirectory()) {
@ -108,11 +105,11 @@ public class RonaInputSystem extends FolderInputSystem {
String name = f.getName(); String name = f.getName();
int lastDot = name.lastIndexOf('.'); int lastDot = name.lastIndexOf('.');
if (lastDot < 0) return false; if (lastDot < 0) return false;
char ch = name.charAt(lastDot-1); char ch = name.charAt(lastDot-1);
if ('1' != ch) { if ('1' != ch) {
return false; return false;
} }
// now check all other files in the set exist. // now check all other files in the set exist.
for (int i = 1; i < NCHANNELS; i++) { for (int i = 1; i < NCHANNELS; i++) {
File chanFile = findChannelFile(f, i, 2); File chanFile = findChannelFile(f, i, 2);
if (chanFile == null) { if (chanFile == null) {
@ -177,14 +174,14 @@ public class RonaInputSystem extends FolderInputSystem {
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); ex.printStackTrace();
return false; return false;
} }
return true; return true;
} }
/** /**
* swap the last digit in a file name for the higher channel * swap the last digit in a file name for the higher channel
* number - rememebr the channels are one indexed. * number - rememebr the channels are one indexed.
* @param baseFile base file * @param baseFile base file
* @param index 0 based file index * @param index 0 based file index
* @return new file with the 1 replaced by another number * @return new file with the 1 replaced by another number
@ -199,7 +196,7 @@ public class RonaInputSystem extends FolderInputSystem {
} }
/** /**
* Search for a nearby file with the same name, but secondds may differ * Search for a nearby file with the same name, but secondds may differ
* by one or two secs - may need to generate complete new file names ! * by one or two secs - may need to generate complete new file names !
* @param baseFile * @param baseFile
* @param index * @param index
@ -214,7 +211,7 @@ public class RonaInputSystem extends FolderInputSystem {
index = PamUtils.getNthChannel(index, RONACHANNELS); index = PamUtils.getNthChannel(index, RONACHANNELS);
/* /*
* files are in the format 20051209-185714-02.flac * files are in the format 20051209-185714-02.flac
* so get the time and add an offset to make a new file name. * so get the time and add an offset to make a new file name.
*/ */
long fileTime = getFileStartTime(baseFile); long fileTime = getFileStartTime(baseFile);
if (fileTime <= 0) { if (fileTime <= 0) {
@ -245,7 +242,7 @@ public class RonaInputSystem extends FolderInputSystem {
@Override @Override
public boolean prepareSystem(AcquisitionControl daqControl) { public boolean prepareSystem(AcquisitionControl daqControl) {
this.acquisitionControl = daqControl; this.acquisitionControl = daqControl;
if (prepareInputFile() == false) { if (!prepareInputFile()) {
return false; return false;
} }
this.newDataUnits = acquisitionControl.getDaqProcess().getNewDataQueue(); this.newDataUnits = acquisitionControl.getDaqProcess().getNewDataQueue();
@ -285,7 +282,7 @@ public class RonaInputSystem extends FolderInputSystem {
currentFileStart = System.currentTimeMillis(); currentFileStart = System.currentTimeMillis();
fileStartTime = currentFileStart; fileStartTime = currentFileStart;
for (int i = 0; i < NCHANNELS; i++) { for (int i = 0; i < NCHANNELS; i++) {
Thread thread = new Thread(flacThreads[i]); Thread thread = new Thread(flacThreads[i]);
thread.start(); thread.start();
@ -304,7 +301,7 @@ public class RonaInputSystem extends FolderInputSystem {
else { else {
runningChannels &= ~(1<<channel); runningChannels &= ~(1<<channel);
} }
System.out.println(String.format("Set channel %d run status to %s overall status was %d, is now %d (%s)", channel, new Boolean(running).toString(), System.out.println(String.format("Set channel %d run status to %s overall status was %d, is now %d (%s)", channel, new Boolean(running).toString(),
was, runningChannels, PamUtils.getChannelList(runningChannels))); was, runningChannels, PamUtils.getChannelList(runningChannels)));
@ -332,7 +329,7 @@ public class RonaInputSystem extends FolderInputSystem {
calculateETA(); calculateETA();
systemHasStopped(runningChannels > 0); systemHasStopped(runningChannels > 0);
} }
@Override @Override
protected void calculateETA() { protected void calculateETA() {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@ -359,8 +356,8 @@ public class RonaInputSystem extends FolderInputSystem {
double[] newRaw = Arrays.copyOf(readyDataUnits[i].getRawData(), (int) firstDataLen); double[] newRaw = Arrays.copyOf(readyDataUnits[i].getRawData(), (int) firstDataLen);
readyDataUnits[i].setRawData(newRaw); readyDataUnits[i].setRawData(newRaw);
/** /**
* Will also need to stop the run at this point since it's evident that one file is longer than others * Will also need to stop the run at this point since it's evident that one file is longer than others
* and will now go into a wait state while it tries to match it's data with other channels. * and will now go into a wait state while it tries to match it's data with other channels.
*/ */
dontStop = false; dontStop = false;
} }
@ -368,7 +365,7 @@ public class RonaInputSystem extends FolderInputSystem {
newDataUnits.addNewData(readyDataUnits[i]); newDataUnits.addNewData(readyDataUnits[i]);
} }
while (newDataUnits.getQueueSize() > NCHANNELS) { while (newDataUnits.getQueueSize() > NCHANNELS) {
if (dontStop == false) break; if (!dontStop) break;
try { try {
Thread.sleep(2); Thread.sleep(2);
} catch (Exception ex) { } catch (Exception ex) {
@ -403,7 +400,7 @@ public class RonaInputSystem extends FolderInputSystem {
@Override @Override
public void processPCM(ByteData byteData) { public void processPCM(ByteData byteData) {
if (dontStop == false) { if (!dontStop) {
try { try {
fileStream.close(); // will make the flac reader bomb out ! fileStream.close(); // will make the flac reader bomb out !
} }
@ -443,12 +440,12 @@ public class RonaInputSystem extends FolderInputSystem {
// newDataUnit.timeMilliseconds = blockMillis; // newDataUnit.timeMilliseconds = blockMillis;
PamCalendar.setSoundFileTimeInMillis(blockMillis); PamCalendar.setSoundFileTimeInMillis(blockMillis);
if (fileSamples > 0 && totalSamples - lastProgressUpdate >= getSampleRate()*2) { if (fileSamples > 0 && totalSamples - lastProgressUpdate >= getSampleRate()*2) {
int progress = (int) (1000. * (float)theseFileSamples / (float) fileSamples); int progress = (int) (1000. * theseFileSamples / fileSamples);
fileProgress.setValue(progress); fileProgress.setValue(progress);
sayEta(); sayEta();
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (lastProgressTime > 0 && totalSamples > lastProgressUpdate) { if (lastProgressTime > 0 && totalSamples > lastProgressUpdate) {
double speed = (double) (totalSamples - lastProgressUpdate) / double speed = (double) (totalSamples - lastProgressUpdate) /
getSampleRate() / ((now-lastProgressTime)/1000.); getSampleRate() / ((now-lastProgressTime)/1000.);
speedLabel.setText(String.format(" (%3.1f X RT)", speed)); speedLabel.setText(String.format(" (%3.1f X RT)", speed));
} }
@ -458,18 +455,18 @@ public class RonaInputSystem extends FolderInputSystem {
} }
/** /**
* Sit and wait until all threads have put there data units into the * Sit and wait until all threads have put there data units into the
* ready array, then they will release at the same time and this thread * ready array, then they will release at the same time and this thread
* can continue round. * can continue round.
*/ */
for (int ichan = 0; ichan < 1; ichan++) { for (int ichan = 0; ichan < 1; ichan++) {
while (waitingDataUnit(ichan+channelOffset)) { while (waitingDataUnit(ichan+channelOffset)) {
if (dontStop == false) break; if (!dontStop) break;
try { try {
Thread.sleep(2); Thread.sleep(2);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
} }
@ -522,7 +519,7 @@ public class RonaInputSystem extends FolderInputSystem {
// byteData = flacDecoder.decodeFrame(flacFrame, byteData); // byteData = flacDecoder.decodeFrame(flacFrame, byteData);
// } // }
} catch (IOException e) { } catch (IOException e) {
// don't print this since it happens naturally when we press the stop button. // don't print this since it happens naturally when we press the stop button.
// e.printStackTrace(); // e.printStackTrace();
} }
try { try {

View File

@ -5,7 +5,6 @@ import java.io.Serializable;
import PamModel.parametermanager.ManagedParameters; import PamModel.parametermanager.ManagedParameters;
import PamModel.parametermanager.PamParameterSet; import PamModel.parametermanager.PamParameterSet;
import PamModel.parametermanager.PamParameterSet.ParameterSetType; import PamModel.parametermanager.PamParameterSet.ParameterSetType;
import simulatedAcquisition.SimProcess;
/** /**
* Used by SoundCardSystem * Used by SoundCardSystem
@ -16,12 +15,12 @@ import simulatedAcquisition.SimProcess;
public class SoundCardParameters implements Serializable, Cloneable, ManagedParameters { public class SoundCardParameters implements Serializable, Cloneable, ManagedParameters {
public static final long serialVersionUID = 1; public static final long serialVersionUID = 1;
public int deviceNumber; public int deviceNumber;
public String systemType; public String systemType;
/** /**
* @param systemType * @param systemType
*/ */

View File

@ -8,6 +8,7 @@ import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem; import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer; import javax.sound.sampled.Mixer;
import javax.sound.sampled.Mixer.Info;
import javax.sound.sampled.TargetDataLine; import javax.sound.sampled.TargetDataLine;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -16,19 +17,18 @@ import javax.swing.border.TitledBorder;
import Acquisition.layoutFX.AcquisitionPaneFX; import Acquisition.layoutFX.AcquisitionPaneFX;
import Acquisition.layoutFX.DAQSettingsPane; import Acquisition.layoutFX.DAQSettingsPane;
import Acquisition.layoutFX.SoundCardDAQPane; import Acquisition.layoutFX.SoundCardDAQPane;
import soundPlayback.PlaybackControl;
import soundPlayback.PlaybackSystem;
import soundPlayback.SoundCardPlayback;
import wavFiles.ByteConverter;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
import PamController.PamSettingManager; import PamController.PamSettingManager;
import PamController.PamSettings; import PamController.PamSettings;
import PamDetection.RawDataUnit; import PamDetection.RawDataUnit;
import PamguardMVC.debug.Debug; import soundPlayback.PlaybackControl;
import soundPlayback.PlaybackSystem;
import soundPlayback.SoundCardPlayback;
import wavFiles.ByteConverter;
/** /**
* Everything and everything to do with controlling and reading sound cards. * Everything and everything to do with controlling and reading sound cards.
* *
* @author Doug Gillespie * @author Doug Gillespie
* @see Acquisition.DaqSystem * @see Acquisition.DaqSystem
* @see Acquisition.AcquisitionProcess * @see Acquisition.AcquisitionProcess
@ -39,26 +39,26 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
public static final String sysType = "Sound Card"; public static final String sysType = "Sound Card";
JPanel daqDialog; JPanel daqDialog;
JComboBox audioDevices; JComboBox audioDevices;
SoundCardParameters soundCardParameters = new SoundCardParameters(sysType); SoundCardParameters soundCardParameters = new SoundCardParameters(sysType);
private AudioFormat audioFormat; private AudioFormat audioFormat;
private AudioDataQueue newDataList; private AudioDataQueue newDataList;
private volatile boolean stopCapture; private volatile boolean stopCapture;
private AcquisitionControl acquisitionControl; private AcquisitionControl acquisitionControl;
private int rawBufferSizeInBytes; private int rawBufferSizeInBytes;
// Might need this to be more flexible // Might need this to be more flexible
private int sampleSizeInBytes = 2; private int sampleSizeInBytes = 2;
private double sampleMax = 32768; private double sampleMax = 32768;
private int daqChannels; private int daqChannels;
private TargetDataLine targetDataLine; private TargetDataLine targetDataLine;
private PlaybackSystem soundCardPlayback; private PlaybackSystem soundCardPlayback;
@ -66,34 +66,34 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
private int dataUnitSamples; private int dataUnitSamples;
private ByteConverter byteConverter; private ByteConverter byteConverter;
/** /**
* JavaFX settings pane for sound card settings * JavaFX settings pane for sound card settings
*/ */
private SoundCardDAQPane soundCardSettingsPane; private SoundCardDAQPane soundCardSettingsPane;
public SoundCardSystem (AcquisitionControl daqControl) { public SoundCardSystem (AcquisitionControl daqControl) {
this.acquisitionControl = daqControl; this.acquisitionControl = daqControl;
PamSettingManager.getInstance().registerSettings(this); PamSettingManager.getInstance().registerSettings(this);
soundCardPlayback = new SoundCardPlayback(this); soundCardPlayback = new SoundCardPlayback(this);
} }
@Override @Override
public boolean prepareSystem(AcquisitionControl daqControl) { public boolean prepareSystem(AcquisitionControl daqControl) {
this.acquisitionControl = daqControl; this.acquisitionControl = daqControl;
// keep a reference to where data will be put. // keep a reference to where data will be put.
this.newDataList = daqControl.getDaqProcess().getNewDataQueue(); this.newDataList = daqControl.getDaqProcess().getNewDataQueue();
if (this.newDataList == null) return false; if (this.newDataList == null) return false;
daqChannels = daqControl.acquisitionParameters.nChannels; daqChannels = daqControl.acquisitionParameters.nChannels;
float sampleRate = daqControl.acquisitionParameters.sampleRate; float sampleRate = daqControl.acquisitionParameters.sampleRate;
audioFormat = new AudioFormat(sampleRate, 16, daqChannels, true, true); audioFormat = new AudioFormat(sampleRate, 16, daqChannels, true, true);
dataUnitSamples = (int) (acquisitionControl.acquisitionParameters.sampleRate / 10); dataUnitSamples = (int) (acquisitionControl.acquisitionParameters.sampleRate / 10);
dataUnitSamples = Math.max(dataUnitSamples, 1000); dataUnitSamples = Math.max(dataUnitSamples, 1000);
ArrayList<Mixer.Info> mixerinfos = getInputMixerList(); ArrayList<Mixer.Info> mixerinfos = getInputMixerList();
//System.out.println("soundCardParameters.deviceNumber:"+soundCardParameters.deviceNumber); //System.out.println("soundCardParameters.deviceNumber:"+soundCardParameters.deviceNumber);
if (soundCardParameters.deviceNumber < 0 || soundCardParameters.deviceNumber >= mixerinfos.size()) { if (soundCardParameters.deviceNumber < 0 || soundCardParameters.deviceNumber >= mixerinfos.size()) {
@ -106,7 +106,7 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
thisMixer.getLineInfo(); thisMixer.getLineInfo();
return false; return false;
} }
try { try {
// try to get the device of choice ... // try to get the device of choice ...
targetDataLine = (TargetDataLine) thisMixer.getLine(thisMixer.getTargetLineInfo()[0]); targetDataLine = (TargetDataLine) thisMixer.getLine(thisMixer.getTargetLineInfo()[0]);
@ -118,7 +118,7 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
boolean lineOk = false; boolean lineOk = false;
// audioFormat = new AudioFormat(sampleRate, 24, daqChannels, true, true); // audioFormat = new AudioFormat(sampleRate, 24, daqChannels, true, true);
// // first try to open input for 24 bit recording, // // first try to open input for 24 bit recording,
// try { // try {
// targetDataLine.open(audioFormat); // targetDataLine.open(audioFormat);
// sampleSizeInBytes = 3; // sampleSizeInBytes = 3;
@ -128,8 +128,8 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
// } catch (LineUnavailableException Ex) { // } catch (LineUnavailableException Ex) {
// lineOk = false; // lineOk = false;
// } // }
// if the 24 bit recording failed, then try to open for 16 bit recording. // if the 24 bit recording failed, then try to open for 16 bit recording.
if (lineOk == false) { if (!lineOk) {
audioFormat = new AudioFormat(sampleRate, 16, daqChannels, true, true); audioFormat = new AudioFormat(sampleRate, 16, daqChannels, true, true);
try { try {
targetDataLine.open(audioFormat); targetDataLine.open(audioFormat);
@ -142,14 +142,14 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
} }
byteConverter = ByteConverter.createByteConverter(audioFormat); byteConverter = ByteConverter.createByteConverter(audioFormat);
// Buffer size to hold 1/10th of a second // Buffer size to hold 1/10th of a second
rawBufferSizeInBytes = dataUnitSamples * daqChannels * sampleSizeInBytes; rawBufferSizeInBytes = dataUnitSamples * daqChannels * sampleSizeInBytes;
return true; return true;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see Acquisition.DaqSystem#getDataUnitSamples() * @see Acquisition.DaqSystem#getDataUnitSamples()
@ -161,20 +161,20 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
@Override @Override
public boolean startSystem(AcquisitionControl daqControl) { public boolean startSystem(AcquisitionControl daqControl) {
if (targetDataLine == null) return false; if (targetDataLine == null) return false;
// Create a thread to capture the sound card input // Create a thread to capture the sound card input
// and start it running. // and start it running.
Thread captureThread = new Thread(new CaptureThread()); Thread captureThread = new Thread(new CaptureThread());
captureThread.start(); captureThread.start();
// then start the device // then start the device
targetDataLine.start(); targetDataLine.start();
setStreamStatus(STREAM_RUNNING); setStreamStatus(STREAM_RUNNING);
return true; return true;
} }
@Override @Override
@ -207,70 +207,70 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
if (daqDialog == null) { if (daqDialog == null) {
daqDialog = createDaqDialogPanel(); daqDialog = createDaqDialogPanel();
} }
return daqDialog; return daqDialog;
} }
private JPanel createDaqDialogPanel() { private JPanel createDaqDialogPanel() {
JPanel p = new JPanel(); JPanel p = new JPanel();
p.setBorder(new TitledBorder("Select audio line")); p.setBorder(new TitledBorder("Select audio line"));
p.setLayout(new BorderLayout()); p.setLayout(new BorderLayout());
p.add(BorderLayout.CENTER, audioDevices = new JComboBox()); p.add(BorderLayout.CENTER, audioDevices = new JComboBox());
return p; return p;
} }
public static ArrayList<Mixer.Info> getInputMixerList() { public static ArrayList<Mixer.Info> getInputMixerList() {
ArrayList<Mixer.Info> mixers = new ArrayList<Mixer.Info>(); ArrayList<Mixer.Info> mixers = new ArrayList<>();
AudioSystem.getMixerInfo(); AudioSystem.getMixerInfo();
Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo(); Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
Mixer mixer; Mixer mixer;
for (int i = 0; i < mixerInfo.length; i++) { for (Info element : mixerInfo) {
mixer = AudioSystem.getMixer(mixerInfo[i]); mixer = AudioSystem.getMixer(element);
//System.out.println("mixer:"+mixer); //System.out.println("mixer:"+mixer);
//System.out.println(mixer.getClass().getName()); //System.out.println(mixer.getClass().getName());
//System.out.println("mixer info:"+mixerInfo[i]); //System.out.println("mixer info:"+mixerInfo[i]);
//extra bit for Mac's where "Line In" is under mixer "Built-in Line Input" //extra bit for Mac's where "Line In" is under mixer "Built-in Line Input"
//which is com.sun.media.sound.SimpleInputDevice //which is com.sun.media.sound.SimpleInputDevice
//cjb 2009-01-05 //cjb 2009-01-05
if (mixer.getTargetLineInfo().length > 0){ if (mixer.getTargetLineInfo().length > 0){
if ( (mixer.getClass().getName().equals("com.sun.media.sound.DirectAudioDevice")) || if ( (mixer.getClass().getName().equals("com.sun.media.sound.DirectAudioDevice")) ||
(mixer.getClass().getName().equals("com.sun.media.sound.SimpleInputDevice"))) { (mixer.getClass().getName().equals("com.sun.media.sound.SimpleInputDevice"))) {
//System.out.println("Adding to input mixer list:"+mixer.getClass().getName()); //System.out.println("Adding to input mixer list:"+mixer.getClass().getName());
mixers.add(mixerInfo[i]); mixers.add(element);
} }
} }
} }
return mixers; return mixers;
} }
public static ArrayList<Mixer.Info> getOutputMixerList() { public static ArrayList<Mixer.Info> getOutputMixerList() {
ArrayList<Mixer.Info> mixers = new ArrayList<Mixer.Info>(); ArrayList<Mixer.Info> mixers = new ArrayList<>();
AudioSystem.getMixerInfo(); AudioSystem.getMixerInfo();
Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo(); Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
Mixer mixer; Mixer mixer;
for (int i = 0; i < mixerInfo.length; i++) { for (Info element : mixerInfo) {
try { try {
mixer = AudioSystem.getMixer(mixerInfo[i]); mixer = AudioSystem.getMixer(element);
} }
catch (Exception e) { catch (Exception e) {
continue; continue;
} }
//System.out.println("Output mixer list:" + mixer); //System.out.println("Output mixer list:" + mixer);
//System.out.println("Output mixer list:" + mixer.getClass().getName()); //System.out.println("Output mixer list:" + mixer.getClass().getName());
//extra bit for Mac's where "Line Out" is under mixer "Built-in Line Input" //extra bit for Mac's where "Line Out" is under mixer "Built-in Line Input"
//which gives 0 length array for getSourceLineInfo() //which gives 0 length array for getSourceLineInfo()
//cjb 2009-01-05 //cjb 2009-01-05
if (mixer.getSourceLineInfo().length > 0){ if (mixer.getSourceLineInfo().length > 0){
if ((mixer.getClass().getName().equals("com.sun.media.sound.DirectAudioDevice")) || if ((mixer.getClass().getName().equals("com.sun.media.sound.DirectAudioDevice")) ||
(mixer.getClass().getName().equals("com.sun.media.sound.HeadspaceMixer"))) { (mixer.getClass().getName().equals("com.sun.media.sound.HeadspaceMixer"))) {
//System.out.println(mixer.getClass().getName()); //System.out.println(mixer.getClass().getName());
mixers.add(mixerInfo[i]); mixers.add(element);
// Debug.out.printf("Use mixer %d, %s\n", i, mixerInfo[i].getName()); // Debug.out.printf("Use mixer %d, %s\n", i, mixerInfo[i].getName());
} }
// else { // else {
// Debug.out.printf("Don't Use mixer %d, %s\n", i, mixerInfo[i].getName()); // Debug.out.printf("Don't Use mixer %d, %s\n", i, mixerInfo[i].getName());
// } // }
@ -281,9 +281,9 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
} }
return mixers; return mixers;
} }
public static ArrayList<String> getDevicesList() { public static ArrayList<String> getDevicesList() {
ArrayList<String> devices = new ArrayList<String>(); ArrayList<String> devices = new ArrayList<>();
ArrayList<Mixer.Info> mixers = getInputMixerList(); ArrayList<Mixer.Info> mixers = getInputMixerList();
for (int i = 0; i < mixers.size(); i++) { for (int i = 0; i < mixers.size(); i++) {
//System.out.println("Adding Device:"+mixers.get(i).getName()); //System.out.println("Adding Device:"+mixers.get(i).getName());
@ -291,9 +291,9 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
} }
return devices; return devices;
} }
@Override @Override
public void dialogSetParams() { public void dialogSetParams() {
// do a quick check to see if the system type is stored in the parameters. This field was added // do a quick check to see if the system type is stored in the parameters. This field was added
@ -304,32 +304,32 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
ArrayList<String> devices = getDevicesList(); ArrayList<String> devices = getDevicesList();
audioDevices.removeAllItems(); audioDevices.removeAllItems();
for (int i = 0; i < devices.size(); i++) { for (String element : devices) {
//System.out.println("Adding to audio device:"+devices.get(i)); //System.out.println("Adding to audio device:"+devices.get(i));
audioDevices.addItem(devices.get(i)); audioDevices.addItem(element);
} }
soundCardParameters.deviceNumber = Math.max(Math.min(devices.size()-1, soundCardParameters.deviceNumber), 0); soundCardParameters.deviceNumber = Math.max(Math.min(devices.size()-1, soundCardParameters.deviceNumber), 0);
if (devices.size() > 0) { if (devices.size() > 0) {
audioDevices.setSelectedIndex(soundCardParameters.deviceNumber); audioDevices.setSelectedIndex(soundCardParameters.deviceNumber);
} }
} }
@Override @Override
public boolean dialogGetParams() { public boolean dialogGetParams() {
//System.out.println("soundCardParameters: " + soundCardParameters + "audioDevices: " + audioDevices); //System.out.println("soundCardParameters: " + soundCardParameters + "audioDevices: " + audioDevices);
if (audioDevices!=null) soundCardParameters.deviceNumber = audioDevices.getSelectedIndex(); if (audioDevices!=null) soundCardParameters.deviceNumber = audioDevices.getSelectedIndex();
return true; return true;
} }
@Override @Override
public String getSystemType() { public String getSystemType() {
return sysType; return sysType;
} }
@Override @Override
public String getSystemName() { public String getSystemName() {
// return the name of the sound card. // return the name of the sound card.
@ -356,7 +356,7 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
//javax.sound only seems to support upto 2 channels //javax.sound only seems to support upto 2 channels
//i.e. option of 1 or 2 - mono or stereo //i.e. option of 1 or 2 - mono or stereo
//even though API reading API can make one think //even though API reading API can make one think
//could have more... cjb 2010-04-28 //could have more... cjb 2010-04-28
return 2; return 2;
} }
@ -364,7 +364,7 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
public int getMaxSampleRate() { public int getMaxSampleRate() {
return PARAMETER_UNKNOWN; return PARAMETER_UNKNOWN;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see Acquisition.DaqSystem#getPeak2PeakVoltage() * @see Acquisition.DaqSystem#getPeak2PeakVoltage()
*/ */
@ -396,24 +396,29 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
return PARAMETER_UNKNOWN; return PARAMETER_UNKNOWN;
} }
@Override
public Serializable getSettingsReference() { public Serializable getSettingsReference() {
return soundCardParameters; return soundCardParameters;
} }
@Override
public long getSettingsVersion() { public long getSettingsVersion() {
return SoundCardParameters.serialVersionUID; return SoundCardParameters.serialVersionUID;
} }
@Override
public String getUnitName() { public String getUnitName() {
// return "Sound Card System"; // return "Sound Card System";
return acquisitionControl.getUnitName(); return acquisitionControl.getUnitName();
} }
@Override
public String getUnitType() { public String getUnitType() {
// return "Acquisition System"; // return "Acquisition System";
return "Sound Card System"; return "Sound Card System";
} }
@Override
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) { public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
// if (PamSettingManager.getInstance().isSettingsUnit(this, pamControlledUnitSettings)) { // if (PamSettingManager.getInstance().isSettingsUnit(this, pamControlledUnitSettings)) {
try { try {
@ -428,7 +433,7 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
private volatile boolean captureRunning; private volatile boolean captureRunning;
// /** // /**
// * Unpack the byte data into a sensible number. // * Unpack the byte data into a sensible number.
// * @param buffer // * @param buffer
@ -446,7 +451,8 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
// } // }
class CaptureThread implements Runnable { class CaptureThread implements Runnable {
@Override
public void run() { public void run() {
stopCapture = false; stopCapture = false;
captureRunning = true; captureRunning = true;
@ -472,10 +478,10 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
count++; count++;
// Read data from the internal // Read data from the internal
// buffer of the data line. // buffer of the data line.
int bytesRead = targetDataLine.read(tempBuffer, 0, int bytesRead = targetDataLine.read(tempBuffer, 0,
tempBuffer.length); tempBuffer.length);
// System.out.println("Read in :" + bytesRead + " bytes"); // System.out.println("Read in :" + bytesRead + " bytes");
/* /*
* Much better to create the PamDataUnits here, since the * Much better to create the PamDataUnits here, since the
@ -483,11 +489,11 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
* this. The main thread then just has to add the references * this. The main thread then just has to add the references
* to the PamDataBlocks to theoutput data block. * to the PamDataBlocks to theoutput data block.
*/ */
if (bytesRead > 0) { if (bytesRead > 0) {
// convert byte array to set of double arrays, one per // convert byte array to set of double arrays, one per
// channel e.g. framesize = 1 for 8 bit sound // channel e.g. framesize = 1 for 8 bit sound
// Framesize is bytecost per Sample in time. ie chanels x sampledepth in bygtes // Framesize is bytecost per Sample in time. ie chanels x sampledepth in bygtes
newSamplesPerChannel = bytesRead / audioFormat.getFrameSize(); newSamplesPerChannel = bytesRead / audioFormat.getFrameSize();
double[][] doubleData = new double[daqChannels][newSamplesPerChannel]; double[][] doubleData = new double[daqChannels][newSamplesPerChannel];
@ -519,7 +525,7 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
}// end while }// end while
} catch (Exception e) { } catch (Exception e) {
System.out.println(e); System.out.println(e);
@ -529,30 +535,30 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
stopCapture = false; stopCapture = false;
captureRunning = false; captureRunning = false;
setStreamStatus(STREAM_ENDED); setStreamStatus(STREAM_ENDED);
}// end run }// end run
}// end inner class CaptureThread }// end inner class CaptureThread
@Override @Override
public void daqHasEnded() { public void daqHasEnded() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override @Override
public String getDeviceName() { public String getDeviceName() {
return String.format("%d", soundCardParameters.deviceNumber); return String.format("%d", soundCardParameters.deviceNumber);
} }
@Override @Override
public DAQSettingsPane getDAQSpecificPane(AcquisitionPaneFX acquisitionPaneFX) { public DAQSettingsPane getDAQSpecificPane(AcquisitionPaneFX acquisitionPaneFX) {
if (soundCardSettingsPane==null) { if (soundCardSettingsPane==null) {
soundCardSettingsPane = new SoundCardDAQPane(this); soundCardSettingsPane = new SoundCardDAQPane(this);
} }
return soundCardSettingsPane; return soundCardSettingsPane;
} }
/** /**
* Get the parameters for the sound card system. * Get the parameters for the sound card system.
* @return the parameters for the sound card system * @return the parameters for the sound card system
*/ */
public SoundCardParameters getSoundCardParameters() { public SoundCardParameters getSoundCardParameters() {

View File

@ -18,10 +18,10 @@ public class StandardChannelListPanel implements ChannelListPanel {
// public int channelList[] = new int[PamConstants.MAX_CHANNELS]; // public int channelList[] = new int[PamConstants.MAX_CHANNELS];
private JLabel panelChannelLabel[] = new JLabel[PamConstants.MAX_CHANNELS]; private JLabel panelChannelLabel[] = new JLabel[PamConstants.MAX_CHANNELS];
private JComboBox panelChannelList[] = new JComboBox[PamConstants.MAX_CHANNELS]; private JComboBox panelChannelList[] = new JComboBox[PamConstants.MAX_CHANNELS];
private JPanel panel; private JPanel panel;
int nChannels = 0; int nChannels = 0;
public StandardChannelListPanel() { public StandardChannelListPanel() {
super(); super();
panel = createStandardChannelListPanel(); panel = createStandardChannelListPanel();
@ -47,23 +47,23 @@ public class StandardChannelListPanel implements ChannelListPanel {
@Override @Override
public void setNumChannels(int nChannels) { public void setNumChannels(int nChannels) {
nChannels = Math.min(nChannels, panelChannelList.length); nChannels = Math.min(nChannels, panelChannelList.length);
this.nChannels = nChannels; this.nChannels = nChannels;
for (int i = 0; i < PamConstants.MAX_CHANNELS; i++) { for (int i = 0; i < PamConstants.MAX_CHANNELS; i++) {
panelChannelLabel[i].setVisible(i < nChannels); panelChannelLabel[i].setVisible(i < nChannels);
panelChannelList[i].setVisible(i < nChannels); panelChannelList[i].setVisible(i < nChannels);
} }
// //
// for (int iL = 0; iL < nChannels; iL++) { // for (int iL = 0; iL < nChannels; iL++) {
// panelChannelList[iL].removeAllItems(); // panelChannelList[iL].removeAllItems();
// for (int i = 0; i < PamConstants.MAX_CHANNELS; i++) { // for (int i = 0; i < PamConstants.MAX_CHANNELS; i++) {
// panelChannelList[iL].addItem(i); // panelChannelList[iL].addItem(i);
// } // }
// //
// } // }
} }
@ -75,23 +75,23 @@ public class StandardChannelListPanel implements ChannelListPanel {
} }
for (int i = 0; i < Math.min(panelChannelList.length, channelList.length); i++){ for (int i = 0; i < Math.min(panelChannelList.length, channelList.length); i++){
panelChannelList[i].setSelectedIndex(channelList[i]); panelChannelList[i].setSelectedIndex(channelList[i]);
// System.out.println(String.format("%s Set box %d to item %d and get %d", // System.out.println(String.format("%s Set box %d to item %d and get %d",
// this.toString(), i, channelList[i], panelChannelList[i].getSelectedItem())); // this.toString(), i, channelList[i], panelChannelList[i].getSelectedItem()));
} }
} }
@Override @Override
public boolean isDataOk() { public boolean isDataOk() {
// now check for repeat combinations. // now check for repeat combinations.
for (int i = 0; i < nChannels-1; i++) { for (int i = 0; i < nChannels-1; i++) {
for (int j = i+1; j < nChannels; j++) { for (int j = i+1; j < nChannels; j++) {
if (panelChannelList[i].getSelectedIndex() == panelChannelList[j].getSelectedIndex()) { if (panelChannelList[i].getSelectedIndex() == panelChannelList[j].getSelectedIndex()) {
String w = String.format("Channel %d is used twice\n"+ String w = String.format("Channel %d is used twice\n"+
"only use each channel once on each device", "only use each channel once on each device",
panelChannelList[i].getSelectedIndex()); panelChannelList[i].getSelectedIndex());
JOptionPane.showConfirmDialog(null, w, JOptionPane.showConfirmDialog(null, w,
"Error", JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE); "Error", JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE);
return false; return false;
} }
} }
} }
@ -103,9 +103,9 @@ public class StandardChannelListPanel implements ChannelListPanel {
/* code for select channel */ /* code for select channel */
/* /*
* put this in a separate panel so it can be hidden if * put this in a separate panel so it can be hidden if
* it's not possible to change these parameters. * it's not possible to change these parameters.
* *
* Text information updated DG & JG 12/8/08 * Text information updated DG & JG 12/8/08
*/ */
JPanel cP; JPanel cP;
@ -125,7 +125,7 @@ public class StandardChannelListPanel implements ChannelListPanel {
s += "<br>So be aware. If you've put a plug into socket 1, <br>you probably want to select channel 0, etc.</html>"; s += "<br>So be aware. If you've put a plug into socket 1, <br>you probably want to select channel 0, etc.</html>";
for (int i = 0; i < PamConstants.MAX_CHANNELS; i++){ //Xiao Yan Deng for (int i = 0; i < PamConstants.MAX_CHANNELS; i++){ //Xiao Yan Deng
//for (int i = 0; i < getNumChannels(); i++){ //for (int i = 0; i < getNumChannels(); i++){
if (i%2 ==0){ if (i%2 ==0){
c2.gridx = 0; c2.gridx = 0;
c2.gridy ++; c2.gridy ++;
@ -140,19 +140,19 @@ public class StandardChannelListPanel implements ChannelListPanel {
else { else {
spaceStr = ""; spaceStr = "";
} }
PamDialog.addComponent(cP, panelChannelLabel[i] = PamDialog.addComponent(cP, panelChannelLabel[i] =
new JLabel(spaceStr + " SW Ch " + i + " = HW Ch "), c2); new JLabel(spaceStr + " SW Ch " + i + " = HW Ch "), c2);
c2.gridx ++; c2.gridx ++;
//constraints.gridwidth = 2; //constraints.gridwidth = 2;
PamDialog.addComponent(cP, panelChannelList[i] = new JComboBox(), c2); PamDialog.addComponent(cP, panelChannelList[i] = new JComboBox(), c2);
panelChannelLabel[i].setToolTipText(s); panelChannelLabel[i].setToolTipText(s);
panelChannelList[i].setToolTipText(s); panelChannelList[i].setToolTipText(s);
// System.out.println(String.format("Fill channel list %d", i)); // System.out.println(String.format("Fill channel list %d", i));
for (int iC = 0; iC < PamConstants.MAX_CHANNELS; iC++) { for (int iC = 0; iC < PamConstants.MAX_CHANNELS; iC++) {
panelChannelList[i].addItem(iC); panelChannelList[i].addItem(iC);
} }
} }
return cP; return cP;
} }
@ -162,6 +162,6 @@ public class StandardChannelListPanel implements ChannelListPanel {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
} }

View File

@ -1,7 +1,7 @@
package Acquisition; package Acquisition;
public class WavChunkData { public class WavChunkData {
static final byte RIFF[] = {'R','I','F','F'}; static final byte RIFF[] = {'R','I','F','F'};
static final byte WAVE[] = {'W','A','V','E'}; static final byte WAVE[] = {'W','A','V','E'};
static final byte FMT[] = {'f','m','t',' '}; static final byte FMT[] = {'f','m','t',' '};
@ -10,7 +10,7 @@ public class WavChunkData {
static final byte ICOP[] = {'I','C','O','P'}; static final byte ICOP[] = {'I','C','O','P'};
static final byte ICRD[] = {'I','C','R','D'}; static final byte ICRD[] = {'I','C','R','D'};
static final byte DATA[] = {'d','a','t','a'}; static final byte DATA[] = {'d','a','t','a'};
static public final int CHUNK_OTHER = 0; static public final int CHUNK_OTHER = 0;
static public final int CHUNK_RIFF = 1; static public final int CHUNK_RIFF = 1;
static public final int CHUNK_WAVE = 2; static public final int CHUNK_WAVE = 2;
@ -19,7 +19,7 @@ public class WavChunkData {
static public final int CHUNK_INFO = 5; static public final int CHUNK_INFO = 5;
static public final int CHUNK_ICOP = 6; static public final int CHUNK_ICOP = 6;
static public final int CHUNK_ICRD = 7; static public final int CHUNK_ICRD = 7;
int chunkSize; int chunkSize;
long fileOffset; long fileOffset;
byte[] chunkId; byte[] chunkId;
@ -36,7 +36,7 @@ public class WavChunkData {
// String str = new String(chunkData); // String str = new String(chunkData);
// System.out.println(new String(chunkId) + " " + str); // System.out.println(new String(chunkId) + " " + str);
} }
public int getType() { public int getType() {
return chunkType; return chunkType;
} }

View File

@ -24,7 +24,7 @@ public class WavFileFuncs extends AudioFileFuncs {
e.printStackTrace(); e.printStackTrace();
} }
if (wavHead.checkSizes(aFile.length()) == false) { if (!wavHead.checkSizes(aFile.length())) {
wavHead.repairSizes(aFile.length()); wavHead.repairSizes(aFile.length());
return writeNewSizes(wavHead, aFile); return writeNewSizes(wavHead, aFile);
} }
@ -106,7 +106,7 @@ public class WavFileFuncs extends AudioFileFuncs {
private static byte[] readChunkId(WindowsFile file) { private static byte[] readChunkId(WindowsFile file) {
byte[] chunkId = new byte[4]; byte[] chunkId = new byte[4];
try { try {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
chunkId[i] = file.readByte(); chunkId[i] = file.readByte();

View File

@ -28,7 +28,7 @@ public class WavHeader {
public void addChunkData(WavChunkData chunkData) { public void addChunkData(WavChunkData chunkData) {
if (otherChunks == null) { if (otherChunks == null) {
otherChunks = new ArrayList<WavChunkData>(); otherChunks = new ArrayList<>();
} }
otherChunks.add(chunkData); otherChunks.add(chunkData);
int t = chunkData.getType(); int t = chunkData.getType();
@ -39,12 +39,12 @@ public class WavHeader {
} }
private boolean unpackFmtData(WavChunkData chunkData) { private boolean unpackFmtData(WavChunkData chunkData) {
// read the 12 bytes of data from the byte array. // read the 12 bytes of data from the byte array.
if (chunkData.chunkSize < 12) { if (chunkData.chunkSize < 12) {
return false; return false;
} }
WindowsBuffer winBuff = new WindowsBuffer(chunkData.chunkData); WindowsBuffer winBuff = new WindowsBuffer(chunkData.chunkData);
try { try {
this.audioformat = winBuff.readWinShort(); this.audioformat = winBuff.readWinShort();
this.nChannels = winBuff.readWinShort(); this.nChannels = winBuff.readWinShort();
@ -61,11 +61,11 @@ public class WavHeader {
} }
/** /**
* Check the two size informations in the wav file. * Check the two size informations in the wav file.
* The first in the second 4 bytes in the RIFF chunk * The first in the second 4 bytes in the RIFF chunk
* which should be equal to the number of bytes in the file - 4 * which should be equal to the number of bytes in the file - 4
* The second is the data length, which should be equal to the * The second is the data length, which should be equal to the
* length of the file - the data start point. * length of the file - the data start point.
* @param length * @param length
*/ */
public boolean checkSizes(long length) { public boolean checkSizes(long length) {
@ -80,10 +80,10 @@ public class WavHeader {
} }
return ok; return ok;
} }
/** /**
* Write the correct sizes into the file data. * Write the correct sizes into the file data.
* @param length total length of file in bytes. * @param length total length of file in bytes.
*/ */
public void repairSizes(long length) { public void repairSizes(long length) {
riffChunkSize = length - 8; riffChunkSize = length - 8;

File diff suppressed because it is too large Load Diff

View File

@ -19,32 +19,35 @@ import PamController.positionreference.PositionReference;
public class AirgunControl extends PamControlledUnit implements PamSettings, PositionReference { public class AirgunControl extends PamControlledUnit implements PamSettings, PositionReference {
AirgunParameters airgunParameters; AirgunParameters airgunParameters;
AirgunProcess airgunProcess; AirgunProcess airgunProcess;
protected boolean initialisationComplete; protected boolean initialisationComplete;
public AirgunControl(String unitName) { public AirgunControl(String unitName) {
super("Airgun Display", unitName); super("Airgun Display", unitName);
airgunParameters = new AirgunParameters(); airgunParameters = new AirgunParameters();
addPamProcess(airgunProcess = new AirgunProcess(this)); addPamProcess(airgunProcess = new AirgunProcess(this));
PamSettingManager.getInstance().registerSettings(this); PamSettingManager.getInstance().registerSettings(this);
airgunProcess.findSourceData(); airgunProcess.findSourceData();
} }
@Override
public Serializable getSettingsReference() { public Serializable getSettingsReference() {
return airgunParameters; return airgunParameters;
} }
@Override
public long getSettingsVersion() { public long getSettingsVersion() {
return AirgunParameters.serialVersionUID; return AirgunParameters.serialVersionUID;
} }
@Override
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) { public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
if (pamControlledUnitSettings.getVersionNo() != AirgunParameters.serialVersionUID) { if (pamControlledUnitSettings.getVersionNo() != AirgunParameters.serialVersionUID) {
return false; return false;
@ -60,15 +63,16 @@ public class AirgunControl extends PamControlledUnit implements PamSettings, Pos
menuItem.addActionListener(new AirgunDisplayOptions(parentFrame)); menuItem.addActionListener(new AirgunDisplayOptions(parentFrame));
return menuItem; return menuItem;
} }
private class AirgunDisplayOptions implements ActionListener { private class AirgunDisplayOptions implements ActionListener {
Frame frame; Frame frame;
public AirgunDisplayOptions(Frame frame) { public AirgunDisplayOptions(Frame frame) {
this.frame = frame; this.frame = frame;
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
AirgunParameters newParams = AirgunParametersDialog.showDialog(frame, airgunParameters); AirgunParameters newParams = AirgunParametersDialog.showDialog(frame, airgunParameters);
@ -76,8 +80,8 @@ public class AirgunControl extends PamControlledUnit implements PamSettings, Pos
airgunParameters = newParams.clone(); airgunParameters = newParams.clone();
airgunProcess.findSourceData(); airgunProcess.findSourceData();
} }
} }
} }
@Override @Override
@ -87,11 +91,11 @@ public class AirgunControl extends PamControlledUnit implements PamSettings, Pos
switch (changeType) { switch (changeType) {
case PamControllerInterface.INITIALIZATION_COMPLETE: case PamControllerInterface.INITIALIZATION_COMPLETE:
initialisationComplete = true; initialisationComplete = true;
airgunProcess.findSourceData(); airgunProcess.findSourceData();
break; break;
case PamControllerInterface.ADD_CONTROLLEDUNIT: case PamControllerInterface.ADD_CONTROLLEDUNIT:
if (initialisationComplete) { if (initialisationComplete) {
airgunProcess.findSourceData(); airgunProcess.findSourceData();
} }
break; break;
case PamControllerInterface.NEW_SCROLL_TIME: case PamControllerInterface.NEW_SCROLL_TIME:

View File

@ -13,9 +13,9 @@ public class AirgunDimensionsDrawing extends ShipDimensionsDrawing {
private double dimE = 0.1; private double dimE = 0.1;
static private double dimF = 0.5; static private double dimF = 0.5;
PamSymbol airgunSymbol; PamSymbol airgunSymbol;
public AirgunDimensionsDrawing() throws HeadlessException { public AirgunDimensionsDrawing() throws HeadlessException {
super(); super();
airgunSymbol = new PamSymbol(PamSymbolType.SYMBOL_HEXAGRAM, 10, 10, false, Color.BLUE, Color.BLUE); airgunSymbol = new PamSymbol(PamSymbolType.SYMBOL_HEXAGRAM, 10, 10, false, Color.BLUE, Color.BLUE);

View File

@ -14,21 +14,21 @@ import PamUtils.Coordinate3d;
import PamUtils.LatLong; import PamUtils.LatLong;
import PamView.BasicKeyItem; import PamView.BasicKeyItem;
import PamView.GeneralProjector; import PamView.GeneralProjector;
import PamView.GeneralProjector.ParameterType;
import PamView.GeneralProjector.ParameterUnits;
import PamView.PamKeyItem; import PamView.PamKeyItem;
import PamView.PamSymbol; import PamView.PamSymbol;
import PamView.PamSymbolType; import PamView.PamSymbolType;
import PamView.PanelOverlayDraw; import PamView.PanelOverlayDraw;
import PamView.GeneralProjector.ParameterType;
import PamView.GeneralProjector.ParameterUnits;
import PamView.symbol.SymbolData; import PamView.symbol.SymbolData;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;
public class AirgunGraphics extends PanelOverlayDraw { public class AirgunGraphics extends PanelOverlayDraw {
AirgunControl airgunControl; AirgunControl airgunControl;
// PamSymbol gunsSymbol; // PamSymbol gunsSymbol;
public static final SymbolData defaultSymbol = new SymbolData(PamSymbolType.SYMBOL_CIRCLE, 6, 6, true, Color.RED, Color.RED); public static final SymbolData defaultSymbol = new SymbolData(PamSymbolType.SYMBOL_CIRCLE, 6, 6, true, Color.RED, Color.RED);
public AirgunGraphics(AirgunControl airgunControl) { public AirgunGraphics(AirgunControl airgunControl) {
@ -39,18 +39,20 @@ public class AirgunGraphics extends PanelOverlayDraw {
@Override @Override
public boolean canDraw(ParameterType[] parameterTypes, ParameterUnits[] parameterUnits) { public boolean canDraw(ParameterType[] parameterTypes, ParameterUnits[] parameterUnits) {
return (parameterTypes[0] == GeneralProjector.ParameterType.LATITUDE && return (parameterTypes[0] == GeneralProjector.ParameterType.LATITUDE &&
parameterTypes[1] == GeneralProjector.ParameterType.LONGITUDE); parameterTypes[1] == GeneralProjector.ParameterType.LONGITUDE);
} }
@Override
public PamKeyItem createKeyItem(GeneralProjector generalProjector,int keyType) { public PamKeyItem createKeyItem(GeneralProjector generalProjector,int keyType) {
return new BasicKeyItem(getPamSymbol(null, generalProjector), airgunControl.getUnitName()); return new BasicKeyItem(getPamSymbol(null, generalProjector), airgunControl.getUnitName());
} }
@Override
public Rectangle drawDataUnit(Graphics g, PamDataUnit pamDataUnit, GeneralProjector generalProjector) { public Rectangle drawDataUnit(Graphics g, PamDataUnit pamDataUnit, GeneralProjector generalProjector) {
AirgunDataUnit airgunDataUnit = (AirgunDataUnit) pamDataUnit; AirgunDataUnit airgunDataUnit = (AirgunDataUnit) pamDataUnit;
double verticalRotation = 0.; double verticalRotation = 0.;
@ -66,7 +68,7 @@ public class AirgunGraphics extends PanelOverlayDraw {
return drawRotatedMap(g, airgunDataUnit, generalProjector); return drawRotatedMap(g, airgunDataUnit, generalProjector);
// } // }
} }
public Rectangle drawRotatedMap(Graphics g, AirgunDataUnit airgunDataUnit, GeneralProjector generalProjector) { public Rectangle drawRotatedMap(Graphics g, AirgunDataUnit airgunDataUnit, GeneralProjector generalProjector) {
GpsData gpsData = airgunDataUnit.getGpsData(); GpsData gpsData = airgunDataUnit.getGpsData();
MapRectProjector mapProj = (MapRectProjector) generalProjector; MapRectProjector mapProj = (MapRectProjector) generalProjector;
@ -74,156 +76,157 @@ public class AirgunGraphics extends PanelOverlayDraw {
double yScale = Math.cos(Math.toRadians(verticalRotation)); double yScale = Math.cos(Math.toRadians(verticalRotation));
double radiusX = mapProj.getPixelsPerMetre()*airgunControl.airgunParameters.exclusionRadius; double radiusX = mapProj.getPixelsPerMetre()*airgunControl.airgunParameters.exclusionRadius;
double radiusY = Math.max(radiusX * yScale, 0); double radiusY = Math.max(radiusX * yScale, 0);
double gunZ = -airgunControl.airgunParameters.gunDepth; double gunZ = -airgunControl.airgunParameters.gunDepth;
// need to move from the gps position to the gund position. // need to move from the gps position to the gund position.
LatLong gunsGps = gpsData.travelDistanceMeters(gpsData.getCourseOverGround() + 90, LatLong gunsGps = gpsData.travelDistanceMeters(gpsData.getCourseOverGround() + 90,
airgunControl.airgunParameters.dimF); airgunControl.airgunParameters.dimF);
gunsGps = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround() + 180, gunsGps = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround() + 180,
airgunControl.airgunParameters.dimE); airgunControl.airgunParameters.dimE);
// int mitigationRadius = airgunControl.airgunParameters.exclusionRadius; // int mitigationRadius = airgunControl.airgunParameters.exclusionRadius;
Coordinate3d gunsCentre = generalProjector.getCoord3d(gunsGps.getLatitude(), gunsGps.getLongitude(), gunZ); Coordinate3d gunsCentre = generalProjector.getCoord3d(gunsGps.getLatitude(), gunsGps.getLongitude(), gunZ);
// draw the guns // draw the guns
Point gc = gunsCentre.getXYPoint(); Point gc = gunsCentre.getXYPoint();
PamSymbol gunsSymbol = getPamSymbol(airgunDataUnit, generalProjector); PamSymbol gunsSymbol = getPamSymbol(airgunDataUnit, generalProjector);
gunsSymbol.setFillColor(airgunControl.airgunParameters.exclusionColor); gunsSymbol.setFillColor(airgunControl.airgunParameters.exclusionColor);
gunsSymbol.setLineColor(airgunControl.airgunParameters.exclusionColor); gunsSymbol.setLineColor(airgunControl.airgunParameters.exclusionColor);
gunsSymbol.draw(g, gc); gunsSymbol.draw(g, gc);
generalProjector.addHoverData(gunsCentre, airgunDataUnit); generalProjector.addHoverData(gunsCentre, airgunDataUnit);
if (airgunControl.airgunParameters.showExclusionZone) { if (airgunControl.airgunParameters.showExclusionZone) {
// LatLong rEnd = gunsGps.addDistanceMeters(mitigationRadius, 0); // LatLong rEnd = gunsGps.addDistanceMeters(mitigationRadius, 0);
// //
// Coordinate3d gunsCirc = generalProjector.getCoord3d(rEnd.getLatitude(), rEnd.getLongitude(), 0); // Coordinate3d gunsCirc = generalProjector.getCoord3d(rEnd.getLatitude(), rEnd.getLongitude(), 0);
// double radius = Math.pow(gunsCentre.x-gunsCirc.x, 2) + // double radius = Math.pow(gunsCentre.x-gunsCirc.x, 2) +
// Math.pow(gunsCentre.y-gunsCirc.y, 2); // Math.pow(gunsCentre.y-gunsCirc.y, 2);
if (radiusX > 5) { if (radiusX > 5) {
g.drawOval((int) (gunsCentre.x - radiusX), (int) (gunsCentre.y - radiusY), g.drawOval((int) (gunsCentre.x - radiusX), (int) (gunsCentre.y - radiusY),
(int) (2*radiusX), (int) (2*radiusY)); (int) (2*radiusX), (int) (2*radiusY));
} }
if (airgunControl.airgunParameters.predictAhead) { if (airgunControl.airgunParameters.predictAhead) {
double mapAngle = (int) (90 - gpsData.getCourseOverGround() - 90) - mapProj.getMapRotationDegrees(); double mapAngle = (int) (90 - gpsData.getCourseOverGround() - 90) - mapProj.getMapRotationDegrees();
double predictionLengthMiles = airgunControl.airgunParameters.secondsAhead * double predictionLengthMiles = airgunControl.airgunParameters.secondsAhead *
gpsData.getSpeed() / 3600; gpsData.getSpeed() / 3600;
LatLong predictedPos = gunsGps.TravelDistanceMiles(gpsData.getCourseOverGround(), predictionLengthMiles); LatLong predictedPos = gunsGps.TravelDistanceMiles(gpsData.getCourseOverGround(), predictionLengthMiles);
Coordinate3d pCirc = generalProjector.getCoord3d(predictedPos.getLatitude(), predictedPos.getLongitude(), gunZ); Coordinate3d pCirc = generalProjector.getCoord3d(predictedPos.getLatitude(), predictedPos.getLongitude(), gunZ);
// int a1 = 90 - gpsData.getTrueCourse() + 90; // int a1 = 90 - gpsData.getTrueCourse() + 90;
// g.drawArc((int) (pCirc.x - radius), (int) (pCirc.y - radius), (int) radius*2, (int) radius*2, // g.drawArc((int) (pCirc.x - radius), (int) (pCirc.y - radius), (int) radius*2, (int) radius*2,
// 50, 180); // 50, 180);
float[] dashes = {2, 6}; float[] dashes = {2, 6};
((Graphics2D) g).setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dashes, 0)); ((Graphics2D) g).setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dashes, 0));
g.drawOval((int) (pCirc.x - radiusX), (int) (pCirc.y - radiusY), g.drawOval((int) (pCirc.x - radiusX), (int) (pCirc.y - radiusY),
(int) (2*radiusX), (int) (2*radiusY)); (int) (2*radiusX), (int) (2*radiusY));
// g.drawArc((int) (pCirc.x - radiusX), (int) (pCirc.y - radiusY), (int) radiusX*2, (int) ((int) 2*radiusY), // g.drawArc((int) (pCirc.x - radiusX), (int) (pCirc.y - radiusY), (int) radiusX*2, (int) ((int) 2*radiusY),
// (int) mapAngle, 180); // (int) mapAngle, 180);
// now need to find the edge points of all this to link up to other circle // now need to find the edge points of all this to link up to other circle
LatLong ll1, ll2; LatLong ll1, ll2;
Coordinate3d p1, p2; Coordinate3d p1, p2;
ll1 = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround()+90, ll1 = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround()+90,
airgunControl.airgunParameters.exclusionRadius); airgunControl.airgunParameters.exclusionRadius);
ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()+90, ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()+90,
airgunControl.airgunParameters.exclusionRadius); airgunControl.airgunParameters.exclusionRadius);
p1 = generalProjector.getCoord3d(ll1.getLatitude(), ll1.getLongitude(), gunZ); p1 = generalProjector.getCoord3d(ll1.getLatitude(), ll1.getLongitude(), gunZ);
p2 = generalProjector.getCoord3d(ll2.getLatitude(), ll2.getLongitude(), gunZ); p2 = generalProjector.getCoord3d(ll2.getLatitude(), ll2.getLongitude(), gunZ);
g.drawLine((int) p1.x, (int) p1.y, (int) p2.x, (int) p2.y); g.drawLine((int) p1.x, (int) p1.y, (int) p2.x, (int) p2.y);
ll1 = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround()-90, ll1 = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround()-90,
airgunControl.airgunParameters.exclusionRadius); airgunControl.airgunParameters.exclusionRadius);
ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()-90, ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()-90,
airgunControl.airgunParameters.exclusionRadius); airgunControl.airgunParameters.exclusionRadius);
p1 = generalProjector.getCoord3d(ll1.getLatitude(), ll1.getLongitude(), gunZ); p1 = generalProjector.getCoord3d(ll1.getLatitude(), ll1.getLongitude(), gunZ);
p2 = generalProjector.getCoord3d(ll2.getLatitude(), ll2.getLongitude(), gunZ); p2 = generalProjector.getCoord3d(ll2.getLatitude(), ll2.getLongitude(), gunZ);
g.drawLine((int) p1.x, (int) p1.y, (int) p2.x, (int) p2.y); g.drawLine((int) p1.x, (int) p1.y, (int) p2.x, (int) p2.y);
// g.setColor(Color.RED); // g.setColor(Color.RED);
// g.drawOval((int) (pCirc.x - radius), (int) (pCirc.y - radius), // g.drawOval((int) (pCirc.x - radius), (int) (pCirc.y - radius),
// (int) (2*radius), (int) (2*radius)); // (int) (2*radius), (int) (2*radius));
// put it back to a solid line, otherwise the next drawn object will be dashed ! // put it back to a solid line, otherwise the next drawn object will be dashed !
((Graphics2D) g).setStroke(new BasicStroke(1)); ((Graphics2D) g).setStroke(new BasicStroke(1));
} }
} }
return null; return null;
} }
public Rectangle drawFlatMap(Graphics g, AirgunDataUnit airgunDataUnit, GeneralProjector generalProjector) { public Rectangle drawFlatMap(Graphics g, AirgunDataUnit airgunDataUnit, GeneralProjector generalProjector) {
GpsData gpsData = airgunDataUnit.getGpsData(); GpsData gpsData = airgunDataUnit.getGpsData();
// need to move from the gps position to the gund position. // need to move from the gps position to the gund position.
LatLong gunsGps = gpsData.travelDistanceMeters(gpsData.getCourseOverGround() + 90, LatLong gunsGps = gpsData.travelDistanceMeters(gpsData.getCourseOverGround() + 90,
airgunControl.airgunParameters.dimF); airgunControl.airgunParameters.dimF);
gunsGps = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround() + 180, gunsGps = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround() + 180,
airgunControl.airgunParameters.dimE); airgunControl.airgunParameters.dimE);
int mitigationRadius = airgunControl.airgunParameters.exclusionRadius; int mitigationRadius = airgunControl.airgunParameters.exclusionRadius;
Coordinate3d gunsCentre = generalProjector.getCoord3d(gunsGps.getLatitude(), gunsGps.getLongitude(), 0); Coordinate3d gunsCentre = generalProjector.getCoord3d(gunsGps.getLatitude(), gunsGps.getLongitude(), 0);
// draw the guns // draw the guns
Point gc = gunsCentre.getXYPoint(); Point gc = gunsCentre.getXYPoint();
PamSymbol gunsSymbol = getPamSymbol(airgunDataUnit, generalProjector); PamSymbol gunsSymbol = getPamSymbol(airgunDataUnit, generalProjector);
gunsSymbol.setFillColor(airgunControl.airgunParameters.exclusionColor); gunsSymbol.setFillColor(airgunControl.airgunParameters.exclusionColor);
gunsSymbol.setLineColor(airgunControl.airgunParameters.exclusionColor); gunsSymbol.setLineColor(airgunControl.airgunParameters.exclusionColor);
gunsSymbol.draw(g, gc); gunsSymbol.draw(g, gc);
generalProjector.addHoverData(gunsCentre, airgunDataUnit); generalProjector.addHoverData(gunsCentre, airgunDataUnit);
if (airgunControl.airgunParameters.showExclusionZone) { if (airgunControl.airgunParameters.showExclusionZone) {
LatLong rEnd = gunsGps.addDistanceMeters(mitigationRadius, 0); LatLong rEnd = gunsGps.addDistanceMeters(mitigationRadius, 0);
Coordinate3d gunsCirc = generalProjector.getCoord3d(rEnd.getLatitude(), rEnd.getLongitude(), 0); Coordinate3d gunsCirc = generalProjector.getCoord3d(rEnd.getLatitude(), rEnd.getLongitude(), 0);
double radius = Math.pow(gunsCentre.x-gunsCirc.x, 2) + double radius = Math.pow(gunsCentre.x-gunsCirc.x, 2) +
Math.pow(gunsCentre.y-gunsCirc.y, 2); Math.pow(gunsCentre.y-gunsCirc.y, 2);
if (radius > 25) { if (radius > 25) {
radius = Math.sqrt(radius); radius = Math.sqrt(radius);
g.drawOval((int) (gunsCentre.x - radius), (int) (gunsCentre.y - radius), g.drawOval((int) (gunsCentre.x - radius), (int) (gunsCentre.y - radius),
(int) (2*radius), (int) (2*radius)); (int) (2*radius), (int) (2*radius));
} }
if (airgunControl.airgunParameters.predictAhead) { if (airgunControl.airgunParameters.predictAhead) {
double predictionLengthMiles = airgunControl.airgunParameters.secondsAhead * double predictionLengthMiles = airgunControl.airgunParameters.secondsAhead *
gpsData.getSpeed() / 3600; gpsData.getSpeed() / 3600;
LatLong predictedPos = gunsGps.TravelDistanceMiles(gpsData.getCourseOverGround(), predictionLengthMiles); LatLong predictedPos = gunsGps.TravelDistanceMiles(gpsData.getCourseOverGround(), predictionLengthMiles);
Coordinate3d pCirc = generalProjector.getCoord3d(predictedPos.getLatitude(), predictedPos.getLongitude(), 0); Coordinate3d pCirc = generalProjector.getCoord3d(predictedPos.getLatitude(), predictedPos.getLongitude(), 0);
// int a1 = 90 - gpsData.getTrueCourse() + 90; // int a1 = 90 - gpsData.getTrueCourse() + 90;
// g.drawArc((int) (pCirc.x - radius), (int) (pCirc.y - radius), (int) radius*2, (int) radius*2, // g.drawArc((int) (pCirc.x - radius), (int) (pCirc.y - radius), (int) radius*2, (int) radius*2,
// 50, 180); // 50, 180);
float[] dashes = {2, 6}; float[] dashes = {2, 6};
((Graphics2D) g).setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dashes, 0)); ((Graphics2D) g).setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dashes, 0));
g.drawArc((int) (pCirc.x - radius), (int) (pCirc.y - radius), (int) radius*2, (int) radius*2, g.drawArc((int) (pCirc.x - radius), (int) (pCirc.y - radius), (int) radius*2, (int) radius*2,
(int) (90 - gpsData.getCourseOverGround() - 90), (int) (90 - gpsData.getCourseOverGround() - 90),
180); 180);
// now need to find the edge points of all this to link up to other circle // now need to find the edge points of all this to link up to other circle
LatLong ll1, ll2; LatLong ll1, ll2;
Coordinate3d p1, p2; Coordinate3d p1, p2;
ll1 = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround()+90, ll1 = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround()+90,
airgunControl.airgunParameters.exclusionRadius); airgunControl.airgunParameters.exclusionRadius);
ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()+90, ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()+90,
airgunControl.airgunParameters.exclusionRadius); airgunControl.airgunParameters.exclusionRadius);
p1 = generalProjector.getCoord3d(ll1.getLatitude(), ll1.getLongitude(), 0); p1 = generalProjector.getCoord3d(ll1.getLatitude(), ll1.getLongitude(), 0);
p2 = generalProjector.getCoord3d(ll2.getLatitude(), ll2.getLongitude(), 0); p2 = generalProjector.getCoord3d(ll2.getLatitude(), ll2.getLongitude(), 0);
g.drawLine((int) p1.x, (int) p1.y, (int) p2.x, (int) p2.y); g.drawLine((int) p1.x, (int) p1.y, (int) p2.x, (int) p2.y);
ll1 = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround()-90, ll1 = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround()-90,
airgunControl.airgunParameters.exclusionRadius); airgunControl.airgunParameters.exclusionRadius);
ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()-90, ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()-90,
airgunControl.airgunParameters.exclusionRadius); airgunControl.airgunParameters.exclusionRadius);
p1 = generalProjector.getCoord3d(ll1.getLatitude(), ll1.getLongitude(), 0); p1 = generalProjector.getCoord3d(ll1.getLatitude(), ll1.getLongitude(), 0);
p2 = generalProjector.getCoord3d(ll2.getLatitude(), ll2.getLongitude(), 0); p2 = generalProjector.getCoord3d(ll2.getLatitude(), ll2.getLongitude(), 0);
g.drawLine((int) p1.x, (int) p1.y, (int) p2.x, (int) p2.y); g.drawLine((int) p1.x, (int) p1.y, (int) p2.x, (int) p2.y);
// g.setColor(Color.RED); // g.setColor(Color.RED);
// g.drawOval((int) (pCirc.x - radius), (int) (pCirc.y - radius), // g.drawOval((int) (pCirc.x - radius), (int) (pCirc.y - radius),
// (int) (2*radius), (int) (2*radius)); // (int) (2*radius), (int) (2*radius));
// put it back to a solid line, otherwise the next drawn object will be dashed ! // put it back to a solid line, otherwise the next drawn object will be dashed !
((Graphics2D) g).setStroke(new BasicStroke(1)); ((Graphics2D) g).setStroke(new BasicStroke(1));
} }
} }
return null; return null;
} }
@Override
public String getHoverText(GeneralProjector generalProjector, PamDataUnit dataUnit, int iSide) { public String getHoverText(GeneralProjector generalProjector, PamDataUnit dataUnit, int iSide) {
String str = "<html>" + airgunControl.getUnitName(); String str = "<html>" + airgunControl.getUnitName();
if (airgunControl.airgunParameters.showExclusionZone) { if (airgunControl.airgunParameters.showExclusionZone) {
@ -242,5 +245,5 @@ public class AirgunGraphics extends PanelOverlayDraw {
public boolean showOptions(Window parentWindow, public boolean showOptions(Window parentWindow,
GeneralProjector generalProjector) { GeneralProjector generalProjector) {
return false; return false;
} }
} }

View File

@ -17,15 +17,15 @@ public class AirgunParameters implements Serializable, Cloneable, ManagedParamet
public static final int GUNS_FIXEDPOSITION = 2; public static final int GUNS_FIXEDPOSITION = 2;
static public final long serialVersionUID = 1; static public final long serialVersionUID = 1;
/** /**
* True if guns are on this vessel * True if guns are on this vessel
*/ */
private boolean gunsThisVessel = true; private boolean gunsThisVessel = true;
public int gunsReferencePosition = GUNS_THIS_VESSEL; public int gunsReferencePosition = GUNS_THIS_VESSEL;
private boolean hasGunsReferencePosition = false; private boolean hasGunsReferencePosition = false;
/** /**
* mmsi number of vessel if guns are on another vessel * mmsi number of vessel if guns are on another vessel
*/ */
@ -35,54 +35,54 @@ public class AirgunParameters implements Serializable, Cloneable, ManagedParamet
* distance in m towards the stern from the vessels GPS receiver * distance in m towards the stern from the vessels GPS receiver
*/ */
double dimE = 20; double dimE = 20;
/** /**
* distance in m towards the starboard side from the vessels GPS receiver * distance in m towards the starboard side from the vessels GPS receiver
*/ */
double dimF = 0; double dimF = 0;
/** /**
* Gun depth in metres. * Gun depth in metres.
*/ */
double gunDepth = 0; double gunDepth = 0;
/** /**
* Show exclusion zone on the map * Show exclusion zone on the map
*/ */
boolean showExclusionZone = true; boolean showExclusionZone = true;
/** /**
* radius of exclusion xone in m * radius of exclusion xone in m
*/ */
int exclusionRadius = 500; int exclusionRadius = 500;
/** /**
* Colour for exclusion zone on map. * Colour for exclusion zone on map.
*/ */
Color exclusionColor = Color.RED; Color exclusionColor = Color.RED;
/** /**
* predict where we'll be in a certain time * predict where we'll be in a certain time
*/ */
boolean predictAhead = false; boolean predictAhead = false;
/** /**
* prediction time in seconds * prediction time in seconds
*/ */
int secondsAhead = 600; int secondsAhead = 600;
public LatLong fixedPosition; public LatLong fixedPosition;
@Override @Override
public AirgunParameters clone() { public AirgunParameters clone() {
try { try {
AirgunParameters np = (AirgunParameters) super.clone(); AirgunParameters np = (AirgunParameters) super.clone();
if (np.hasGunsReferencePosition == false) { if (!np.hasGunsReferencePosition) {
// sort out what happens if old boolean ref was used // sort out what happens if old boolean ref was used
// instead of new int type. // instead of new int type.
np.hasGunsReferencePosition = true; np.hasGunsReferencePosition = true;
if (np.gunsThisVessel == false) { if (!np.gunsThisVessel) {
np.gunsReferencePosition = GUNS_AIS_VESSEL; np.gunsReferencePosition = GUNS_AIS_VESSEL;
} }
} }
@ -93,7 +93,7 @@ public class AirgunParameters implements Serializable, Cloneable, ManagedParamet
} }
return null; return null;
} }
@Override @Override
public PamParameterSet getParameterSet() { public PamParameterSet getParameterSet() {
PamParameterSet ps = PamParameterSet.autoGenerate(this, ParameterSetType.DISPLAY); PamParameterSet ps = PamParameterSet.autoGenerate(this, ParameterSetType.DISPLAY);

View File

@ -17,6 +17,7 @@ import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JRadioButton; import javax.swing.JRadioButton;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.BevelBorder; import javax.swing.border.BevelBorder;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
@ -29,19 +30,19 @@ import PamView.dialog.PamDialog;
public class AirgunParametersDialog extends PamDialog { public class AirgunParametersDialog extends PamDialog {
private static AirgunParametersDialog airgunParametersDialog; private static AirgunParametersDialog airgunParametersDialog;
private AirgunParameters airgunParameters; private AirgunParameters airgunParameters;
private ShipDimensionsPanel shipDrawing; private ShipDimensionsPanel shipDrawing;
private ShipDimensionsFields shipDimensionsFields; private ShipDimensionsFields shipDimensionsFields;
private ShipIDPanel shipIDPanel; private ShipIDPanel shipIDPanel;
private ExclusionPanel exclusionPanel; private ExclusionPanel exclusionPanel;
private String[] fieldNames = {"E","F","Depth"}; private String[] fieldNames = {"E","F","Depth"};
public AirgunParametersDialog(Frame parentFrame) { public AirgunParametersDialog(Frame parentFrame) {
super(parentFrame, "Airgun display parameters", false); super(parentFrame, "Airgun display parameters", false);
JPanel p = new JPanel(); JPanel p = new JPanel();
@ -49,7 +50,7 @@ public class AirgunParametersDialog extends PamDialog {
AirgunDimensionsDrawing ad = new AirgunDimensionsDrawing(); AirgunDimensionsDrawing ad = new AirgunDimensionsDrawing();
p.add(shipDrawing = new ShipDimensionsPanel(ad, p.add(shipDrawing = new ShipDimensionsPanel(ad,
shipDimensionsFields = new ShipDimensionsFields(fieldNames))); shipDimensionsFields = new ShipDimensionsFields(fieldNames)));
JPanel q = new JPanel(); JPanel q = new JPanel();
q.setLayout(new BoxLayout(q, BoxLayout.Y_AXIS)); q.setLayout(new BoxLayout(q, BoxLayout.Y_AXIS));
q.add(shipIDPanel = new ShipIDPanel()); q.add(shipIDPanel = new ShipIDPanel());
@ -58,7 +59,7 @@ public class AirgunParametersDialog extends PamDialog {
setDialogComponent(p); setDialogComponent(p);
// setModal(true); // setModal(true);
} }
public static AirgunParameters showDialog(Frame parentFrame, AirgunParameters airgunParameters) { public static AirgunParameters showDialog(Frame parentFrame, AirgunParameters airgunParameters) {
if (airgunParametersDialog == null || airgunParametersDialog.getParent() != parentFrame) { if (airgunParametersDialog == null || airgunParametersDialog.getParent() != parentFrame) {
airgunParametersDialog = new AirgunParametersDialog(parentFrame); airgunParametersDialog = new AirgunParametersDialog(parentFrame);
@ -66,16 +67,16 @@ public class AirgunParametersDialog extends PamDialog {
airgunParametersDialog.airgunParameters = airgunParameters.clone(); airgunParametersDialog.airgunParameters = airgunParameters.clone();
airgunParametersDialog.setParams(); airgunParametersDialog.setParams();
airgunParametersDialog.setVisible(true); airgunParametersDialog.setVisible(true);
return airgunParametersDialog.airgunParameters; return airgunParametersDialog.airgunParameters;
} }
@Override @Override
public void cancelButtonPressed() { public void cancelButtonPressed() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
public void setParams() { public void setParams() {
double[] dim = new double[3]; double[] dim = new double[3];
dim[0] = airgunParameters.dimE; dim[0] = airgunParameters.dimE;
@ -84,9 +85,9 @@ public class AirgunParametersDialog extends PamDialog {
shipDimensionsFields.setDimensions(dim); shipDimensionsFields.setDimensions(dim);
shipIDPanel.setParams(); shipIDPanel.setParams();
exclusionPanel.setParams(); exclusionPanel.setParams();
} }
@Override @Override
public boolean getParams() { public boolean getParams() {
double[] dim = shipDimensionsFields.getDimensions(); double[] dim = shipDimensionsFields.getDimensions();
@ -94,23 +95,22 @@ public class AirgunParametersDialog extends PamDialog {
airgunParameters.dimE = dim[0]; airgunParameters.dimE = dim[0];
airgunParameters.dimF = dim[1]; airgunParameters.dimF = dim[1];
airgunParameters.gunDepth = dim[2]; airgunParameters.gunDepth = dim[2];
if (shipIDPanel.getParams() == false) return false; if (!shipIDPanel.getParams() || !exclusionPanel.getParams()) return false;
if (exclusionPanel.getParams() == false) return false;
return true; return true;
} }
@Override @Override
public void restoreDefaultSettings() { public void restoreDefaultSettings() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
class ShipIDPanel extends JPanel implements ActionListener { class ShipIDPanel extends JPanel implements ActionListener {
private JRadioButton thisVessel, otherVessel, fixedLocation; private JRadioButton thisVessel, otherVessel, fixedLocation;
private JTextField mmsiNumber; private JTextField mmsiNumber;
private LatLongEditableDialogStrip llStrip; private LatLongEditableDialogStrip llStrip;
public ShipIDPanel() { public ShipIDPanel() {
super(); super();
setBorder(new TitledBorder("Source Vessel Identification")); setBorder(new TitledBorder("Source Vessel Identification"));
@ -131,7 +131,7 @@ public class AirgunParametersDialog extends PamDialog {
c.gridy++; c.gridy++;
c.gridx = 0; c.gridx = 0;
c.gridwidth = 1; c.gridwidth = 1;
addComponent(this, new JLabel("Source vessel mmsi number ", JLabel.RIGHT), c); addComponent(this, new JLabel("Source vessel mmsi number ", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
addComponent(this, mmsiNumber = new JTextField(7), c); addComponent(this, mmsiNumber = new JTextField(7), c);
c.gridx = 0; c.gridx = 0;
@ -144,18 +144,19 @@ public class AirgunParametersDialog extends PamDialog {
addComponent(this, llStrip.getDialogComponent(), c); addComponent(this, llStrip.getDialogComponent(), c);
bg.add(fixedLocation); bg.add(fixedLocation);
fixedLocation.addActionListener(this); fixedLocation.addActionListener(this);
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
enableControls(); enableControls();
} }
public void enableControls() { public void enableControls() {
mmsiNumber.setEnabled(otherVessel.isSelected()); mmsiNumber.setEnabled(otherVessel.isSelected());
llStrip.enableControls(fixedLocation.isSelected()); llStrip.enableControls(fixedLocation.isSelected());
} }
public void setParams() { public void setParams() {
thisVessel.setSelected(airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_THIS_VESSEL); thisVessel.setSelected(airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_THIS_VESSEL);
otherVessel.setSelected(airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_AIS_VESSEL); otherVessel.setSelected(airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_AIS_VESSEL);
@ -164,7 +165,7 @@ public class AirgunParametersDialog extends PamDialog {
llStrip.setLatLong(airgunParameters.fixedPosition); llStrip.setLatLong(airgunParameters.fixedPosition);
enableControls(); enableControls();
} }
public boolean getParams() { public boolean getParams() {
if (thisVessel.isSelected()) { if (thisVessel.isSelected()) {
airgunParameters.gunsReferencePosition = AirgunParameters.GUNS_THIS_VESSEL; airgunParameters.gunsReferencePosition = AirgunParameters.GUNS_THIS_VESSEL;
@ -192,22 +193,22 @@ public class AirgunParametersDialog extends PamDialog {
} }
return true; return true;
} }
} }
class ExclusionPanel extends JPanel implements ActionListener { class ExclusionPanel extends JPanel implements ActionListener {
JTextField exRadius; JTextField exRadius;
JCheckBox showExclusion; JCheckBox showExclusion;
JPanel exPanel; JPanel exPanel;
JButton exButton; JButton exButton;
JCheckBox predictAhead; JCheckBox predictAhead;
JTextField predictionTime; JTextField predictionTime;
public ExclusionPanel() { public ExclusionPanel() {
super(); super();
setBorder(new TitledBorder("Guns mitigation zone")); setBorder(new TitledBorder("Guns mitigation zone"));
@ -229,7 +230,7 @@ public class AirgunParametersDialog extends PamDialog {
addComponent(this, exRadius = new JTextField(6), c); addComponent(this, exRadius = new JTextField(6), c);
c.gridx++; c.gridx++;
addComponent(this, new JLabel(" m"), c); addComponent(this, new JLabel(" m"), c);
c.gridwidth = 1; c.gridwidth = 1;
c.gridy++; c.gridy++;
c.gridx = 0; c.gridx = 0;
@ -239,7 +240,7 @@ public class AirgunParametersDialog extends PamDialog {
c.gridx++; c.gridx++;
addComponent(this, exButton = new JButton("Colour"), c); addComponent(this, exButton = new JButton("Colour"), c);
exButton.addActionListener(this); exButton.addActionListener(this);
c.gridx = 0; c.gridx = 0;
c.gridy ++; c.gridy ++;
c.gridwidth = 3; c.gridwidth = 3;
@ -248,13 +249,13 @@ public class AirgunParametersDialog extends PamDialog {
c.gridx = 0; c.gridx = 0;
c.gridy ++; c.gridy ++;
c.gridwidth = 1; c.gridwidth = 1;
addComponent(this, new JLabel("Predict ahead for ", JLabel.RIGHT), c); addComponent(this, new JLabel("Predict ahead for ", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
addComponent(this, predictionTime = new JTextField(6), c); addComponent(this, predictionTime = new JTextField(6), c);
c.gridx++; c.gridx++;
addComponent(this, new JLabel(" seconds ", JLabel.LEFT), c); addComponent(this, new JLabel(" seconds ", SwingConstants.LEFT), c);
} }
public void setParams() { public void setParams() {
showExclusion.setSelected(airgunParameters.showExclusionZone); showExclusion.setSelected(airgunParameters.showExclusionZone);
@ -282,9 +283,10 @@ public class AirgunParametersDialog extends PamDialog {
} }
return true; return true;
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (e.getSource() == exButton) { if (e.getSource() == exButton) {
Color newColor = JColorChooser.showDialog(this, "Mitigation zone colour", Color newColor = JColorChooser.showDialog(this, "Mitigation zone colour",
airgunParameters.exclusionColor); airgunParameters.exclusionColor);
if (newColor != null) { if (newColor != null) {
setColour(newColor); setColour(newColor);
@ -296,7 +298,7 @@ public class AirgunParametersDialog extends PamDialog {
else if (e.getSource() == predictAhead) { else if (e.getSource() == predictAhead) {
enableControls(); enableControls();
} }
} }
private void enableControls() { private void enableControls() {
predictAhead.setEnabled(showExclusion.isSelected()); predictAhead.setEnabled(showExclusion.isSelected());
@ -305,5 +307,5 @@ public class AirgunParametersDialog extends PamDialog {
predictionTime.setEnabled(predictAhead.isSelected() && showExclusion.isSelected()); predictionTime.setEnabled(predictAhead.isSelected() && showExclusion.isSelected());
} }
} }
} }

View File

@ -7,11 +7,9 @@ import AIS.AISDataUnit;
import AIS.AISPositionReport; import AIS.AISPositionReport;
import GPS.GpsData; import GPS.GpsData;
import GPS.GpsDataUnit; import GPS.GpsDataUnit;
import Map.MapCommentOverlayGraphics;
import PamController.PamController; import PamController.PamController;
import PamUtils.LatLong; import PamUtils.LatLong;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
import PamView.symbol.PamSymbolManager;
import PamView.symbol.StandardSymbolManager; import PamView.symbol.StandardSymbolManager;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;
@ -22,11 +20,11 @@ import PamguardMVC.SingletonDataBlock;
public class AirgunProcess extends PamProcess { public class AirgunProcess extends PamProcess {
AirgunControl airgunControl; AirgunControl airgunControl;
PamDataBlock<GpsDataUnit> gpsDataBlock; PamDataBlock<GpsDataUnit> gpsDataBlock;
AISDataBlock aisDataBlock; AISDataBlock aisDataBlock;
PamDataBlock<AirgunDataUnit> outputDataBlock; PamDataBlock<AirgunDataUnit> outputDataBlock;
public AirgunProcess(AirgunControl airgunControl) { public AirgunProcess(AirgunControl airgunControl) {
super(airgunControl, null); super(airgunControl, null);
this.airgunControl = airgunControl; this.airgunControl = airgunControl;
@ -53,10 +51,10 @@ public class AirgunProcess extends PamProcess {
public void newData(PamObservable o, PamDataUnit arg) { public void newData(PamObservable o, PamDataUnit arg) {
useData(o, arg); useData(o, arg);
} }
/** /**
* AIS data are generally updated rather than created new, so * AIS data are generally updated rather than created new, so
* use newData and updateData in the same way, * use newData and updateData in the same way,
* @param o PamObservable sent to updateData or newData * @param o PamObservable sent to updateData or newData
* @param arg PamDataUnit sent to updateData or newData * @param arg PamDataUnit sent to updateData or newData
*/ */
@ -72,7 +70,7 @@ public class AirgunProcess extends PamProcess {
useAisData((PamDataBlock) o, (AISDataUnit) arg); useAisData((PamDataBlock) o, (AISDataUnit) arg);
} }
} }
private void useGpsData(PamDataBlock dataBlock, GpsDataUnit gpsDataUnit) { private void useGpsData(PamDataBlock dataBlock, GpsDataUnit gpsDataUnit) {
if (gpsDataUnit == null) { if (gpsDataUnit == null) {
return; return;
@ -80,7 +78,7 @@ public class AirgunProcess extends PamProcess {
GpsData gpsData = gpsDataUnit.getGpsData(); GpsData gpsData = gpsDataUnit.getGpsData();
createAirgunData(gpsData); createAirgunData(gpsData);
} }
private void useAisData(PamDataBlock dataBlock, AISDataUnit aisDataUnit) { private void useAisData(PamDataBlock dataBlock, AISDataUnit aisDataUnit) {
if (aisDataUnit.mmsiNumber != airgunControl.airgunParameters.gunsMMSIVessel) return; if (aisDataUnit.mmsiNumber != airgunControl.airgunParameters.gunsMMSIVessel) return;
// if (aisDataUnit.isComplete() == false) { // if (aisDataUnit.isComplete() == false) {
@ -104,29 +102,29 @@ public class AirgunProcess extends PamProcess {
gpsData.setTimeInMillis(aisDataUnit.getTimeMilliseconds()); gpsData.setTimeInMillis(aisDataUnit.getTimeMilliseconds());
createAirgunData(gpsData); createAirgunData(gpsData);
} }
private void createAirgunData(GpsData gpsData) { private void createAirgunData(GpsData gpsData) {
// PamDataUnit nU = outputDataBlock.getNewUnit(0,0,0); // PamDataUnit nU = outputDataBlock.getNewUnit(0,0,0);
AirgunDataUnit nU = new AirgunDataUnit(PamCalendar.getTimeInMillis(), gpsData); AirgunDataUnit nU = new AirgunDataUnit(PamCalendar.getTimeInMillis(), gpsData);
outputDataBlock.addPamData(nU); outputDataBlock.addPamData(nU);
} }
@Override @Override
public void noteNewSettings() { public void noteNewSettings() {
// super.noteNewSettings(); // super.noteNewSettings();
findSourceData(); findSourceData();
} }
synchronized public void findSourceData(){ synchronized public void findSourceData(){
PamDataBlock newDataBlock = null; PamDataBlock newDataBlock = null;
if (airgunControl.airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_THIS_VESSEL) { if (airgunControl.airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_THIS_VESSEL) {
aisDataBlock = null; aisDataBlock = null;
// find and subscribe to the GPS data block // find and subscribe to the GPS data block
/* /*
* 4/3/13 Change this to ensure it get's the correct GPS data block. In past it was picking up itself if the * 4/3/13 Change this to ensure it get's the correct GPS data block. In past it was picking up itself if the
* airgun unit was before the GPS unit since the airgun data unit is a subclass of GPSDataUnit. Should now get * airgun unit was before the GPS unit since the airgun data unit is a subclass of GPSDataUnit. Should now get
* the correct GPS data. * the correct GPS data.
*/ */
// newDataBlock = PamController.getInstance().getDataBlock(GpsDataUnit.class, 0); // newDataBlock = PamController.getInstance().getDataBlock(GpsDataUnit.class, 0);
ArrayList<PamDataBlock> gpsBlocks = PamController.getInstance().getDataBlocks(GpsDataUnit.class, false); ArrayList<PamDataBlock> gpsBlocks = PamController.getInstance().getDataBlocks(GpsDataUnit.class, false);
@ -149,7 +147,7 @@ public class AirgunProcess extends PamProcess {
setParentDataBlock(aisDataBlock); setParentDataBlock(aisDataBlock);
} }
else { else {
System.out.println("Unable to find AIS data block for airgun display"); System.out.println("Unable to find AIS data block for airgun display");
} }
} }
@ -158,10 +156,10 @@ public class AirgunProcess extends PamProcess {
} }
} }
/** /**
* Called when view times change so that the display can update it's * Called when view times change so that the display can update it's
* location based on the new time. * location based on the new time.
*/ */
protected void newViewTime(){ protected void newViewTime(){
if (airgunControl.airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_THIS_VESSEL) { if (airgunControl.airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_THIS_VESSEL) {
@ -195,18 +193,18 @@ public class AirgunProcess extends PamProcess {
@Override @Override
public void pamStart() { public void pamStart() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override @Override
public void pamStop() { public void pamStop() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
/** /**
* Implementation of PositionReference. Will try to return a ref position * Implementation of PositionReference. Will try to return a ref position
* for a given time. * for a given time.
* @param timeMillis * @param timeMillis
* @return * @return
*/ */
@ -220,7 +218,7 @@ public class AirgunProcess extends PamProcess {
if (airgunControl.airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_FIXEDPOSITION){ if (airgunControl.airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_FIXEDPOSITION){
return getFixedPosition(timeMillis); return getFixedPosition(timeMillis);
} }
return null; return null;
} }
@ -237,9 +235,9 @@ public class AirgunProcess extends PamProcess {
return null; return null;
} }
GpsData gpsData = gpsDataUnit.getGpsData(); GpsData gpsData = gpsDataUnit.getGpsData();
LatLong gunPos = gpsData.travelDistanceMeters(gpsData.getHeading() + 180, LatLong gunPos = gpsData.travelDistanceMeters(gpsData.getHeading() + 180,
airgunControl.airgunParameters.dimE); airgunControl.airgunParameters.dimE);
gunPos = gunPos.travelDistanceMeters(gpsData.getHeading() + 90, gunPos = gunPos.travelDistanceMeters(gpsData.getHeading() + 90,
airgunControl.airgunParameters.dimF); airgunControl.airgunParameters.dimF);
GpsData gunGPS = gpsData.clone(); GpsData gunGPS = gpsData.clone();
gunGPS.setLatitude(gunPos.getLatitude()); gunGPS.setLatitude(gunPos.getLatitude());
@ -247,7 +245,7 @@ public class AirgunProcess extends PamProcess {
return gunGPS; return gunGPS;
} }
private GpsData getAISBasedPosition(long timeMillis) { private GpsData getAISBasedPosition(long timeMillis) {
if (aisDataBlock == null) { if (aisDataBlock == null) {
return null; return null;
} }
@ -260,9 +258,9 @@ public class AirgunProcess extends PamProcess {
return null; return null;
} }
LatLong gunPos = aisPositionReport.latLong; LatLong gunPos = aisPositionReport.latLong;
gunPos = gunPos.travelDistanceMeters(aisPositionReport.courseOverGround + 180, gunPos = gunPos.travelDistanceMeters(aisPositionReport.courseOverGround + 180,
airgunControl.airgunParameters.dimE); airgunControl.airgunParameters.dimE);
gunPos = gunPos.travelDistanceMeters(aisPositionReport.courseOverGround + 90, gunPos = gunPos.travelDistanceMeters(aisPositionReport.courseOverGround + 90,
airgunControl.airgunParameters.dimF); airgunControl.airgunParameters.dimF);
GpsData gunGPS = new GpsData(gunPos); GpsData gunGPS = new GpsData(gunPos);
gunGPS.setCourseOverGround(aisPositionReport.courseOverGround); gunGPS.setCourseOverGround(aisPositionReport.courseOverGround);

View File

@ -8,6 +8,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
@ -16,6 +17,7 @@ import javax.swing.JPanel;
import javax.swing.JSplitPane; import javax.swing.JSplitPane;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileFilter;
import Acquisition.AcquisitionControl; import Acquisition.AcquisitionControl;
import Acquisition.AcquisitionParameters; import Acquisition.AcquisitionParameters;
import PamController.PamController; import PamController.PamController;
@ -170,7 +172,7 @@ public class ArrayDialog extends PamDialog implements ActionListener {
public boolean getParams() { public boolean getParams() {
// all OK, so // all OK, so
// move the selected array to the top of the list in the ArrayManager // move the selected array to the top of the list in the ArrayManager
if (okOK(true) == false) return false; if (!okOK(true)) return false;
PamArray array = hydrophoneDialogPanel.getDialogSelectedArray(); PamArray array = hydrophoneDialogPanel.getDialogSelectedArray();
ArrayManager.getArrayManager().setCurrentArray(array); ArrayManager.getArrayManager().setCurrentArray(array);
@ -179,7 +181,7 @@ public class ArrayDialog extends PamDialog implements ActionListener {
hydrophoneDialogPanel.getParams(); hydrophoneDialogPanel.getParams();
instrumentIdentityPanel.getParams(array); instrumentIdentityPanel.getParams(array);
if (checkDaqChannels(array) == false) { if (!checkDaqChannels(array)) {
return false; return false;
} }
@ -198,7 +200,7 @@ public class ArrayDialog extends PamDialog implements ActionListener {
ArrayList<AcquisitionControl> daqControllers = AcquisitionControl.getControllers(); ArrayList<AcquisitionControl> daqControllers = AcquisitionControl.getControllers();
boolean allOk = true; boolean allOk = true;
for (int i = 0; i < daqControllers.size(); i++) { for (int i = 0; i < daqControllers.size(); i++) {
if (checkDaqChannels(daqControllers.get(i), array) == false) { if (!checkDaqChannels(daqControllers.get(i), array)) {
allOk = false; allOk = false;
} }
} }
@ -238,7 +240,7 @@ public class ArrayDialog extends PamDialog implements ActionListener {
} }
return false; return false;
} }
else if (environmentPanel.getParams() == false) { else if (!environmentPanel.getParams()) {
return false; return false;
} }
@ -274,6 +276,7 @@ public class ArrayDialog extends PamDialog implements ActionListener {
deleteArrayButton.setEnabled(ArrayManager.getArrayManager().getArrayCount() > 1); deleteArrayButton.setEnabled(ArrayManager.getArrayManager().getArrayCount() > 1);
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (e.getSource() == cancelButton) { if (e.getSource() == cancelButton) {
this.setVisible(false); this.setVisible(false);

View File

@ -8,11 +8,9 @@ import java.io.ObjectOutputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import javax.swing.JFrame; import javax.swing.JFrame;
import pamMaths.PamQuaternion;
import pamMaths.PamVector;
import userDisplay.UserDisplayControl;
import Array.importHydrophoneData.HydrophoneImport; import Array.importHydrophoneData.HydrophoneImport;
import Array.importHydrophoneData.StreamerImport; import Array.importHydrophoneData.StreamerImport;
import Array.layoutFX.ArrayGUIFX; import Array.layoutFX.ArrayGUIFX;
@ -26,6 +24,7 @@ import PamController.PamControlledUnit;
import PamController.PamControlledUnitGUI; import PamController.PamControlledUnitGUI;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
import PamController.PamController; import PamController.PamController;
import PamController.PamControllerInterface;
import PamController.PamGUIManager; import PamController.PamGUIManager;
import PamController.PamSettingManager; import PamController.PamSettingManager;
import PamController.PamSettings; import PamController.PamSettings;
@ -40,6 +39,9 @@ import PamguardMVC.PamDataUnit;
import PamguardMVC.PamObservable; import PamguardMVC.PamObservable;
import PamguardMVC.PamObserver; import PamguardMVC.PamObserver;
import dataPlotsFX.data.TDDataProviderRegisterFX; import dataPlotsFX.data.TDDataProviderRegisterFX;
import pamMaths.PamQuaternion;
import pamMaths.PamVector;
import userDisplay.UserDisplayControl;
/** /**
* Manager for different array configurations. Each array configuration is * Manager for different array configurations. Each array configuration is
@ -169,32 +171,33 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
} }
private boolean initComplete = false; private boolean initComplete = false;
@Override
public void notifyModelChanged(int changeType) { public void notifyModelChanged(int changeType) {
if (changeType == PamController.INITIALIZATION_COMPLETE) { if (changeType == PamControllerInterface.INITIALIZATION_COMPLETE) {
initComplete = true; initComplete = true;
} }
getCurrentArray().notifyModelChanged(changeType, initComplete); getCurrentArray().notifyModelChanged(changeType, initComplete);
if (changeType == PamController.INITIALIZATION_COMPLETE) { if (changeType == PamControllerInterface.INITIALIZATION_COMPLETE) {
// create data units and save - is this needed in the viewer ? // create data units and save - is this needed in the viewer ?
// if (PamController.getInstance().getRunMode() == PamController.RUN_NORMAL) { // if (PamController.getInstance().getRunMode() == PamController.RUN_NORMAL) {
hydrophonesProcess.createArrayData(); hydrophonesProcess.createArrayData();
// } // }
} }
if (changeType == PamController.OFFLINE_DATA_LOADED){ if (changeType == PamControllerInterface.OFFLINE_DATA_LOADED){
if (isViewer) { if (isViewer) {
getHydrophoneDataBlock().clearChannelIterators(); getHydrophoneDataBlock().clearChannelIterators();
} }
} }
if (changeType == PamController.HYDROPHONE_ARRAY_CHANGED){ if (changeType == PamControllerInterface.HYDROPHONE_ARRAY_CHANGED){
if (isViewer) { if (isViewer) {
getHydrophoneDataBlock().clearChannelIterators(); getHydrophoneDataBlock().clearChannelIterators();
} }
} }
if (changeType == PamController.GLOBAL_MEDIUM_UPDATE){ if (changeType == PamControllerInterface.GLOBAL_MEDIUM_UPDATE){
this.getCurrentArray().setSpeedOfSound(this.getPamController().getGlobalMediumManager().getDefaultSoundSpeed()); this.getCurrentArray().setSpeedOfSound(this.getPamController().getGlobalMediumManager().getDefaultSoundSpeed());
this.getCurrentArray().setDefaultSensitivity(this.getPamController().getGlobalMediumManager().getDefaultRecieverSens()); this.getCurrentArray().setDefaultSensitivity(this.getPamController().getGlobalMediumManager().getDefaultRecieverSens());
} }
@ -229,7 +232,7 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
if (selectedArray != null) { if (selectedArray != null) {
hydrophonesProcess.createArrayData(); hydrophonesProcess.createArrayData();
// need to tell all modules that the array may have changed. // need to tell all modules that the array may have changed.
PamController.getInstance().notifyModelChanged(PamController.HYDROPHONE_ARRAY_CHANGED); PamController.getInstance().notifyModelChanged(PamControllerInterface.HYDROPHONE_ARRAY_CHANGED);
} }
} }
@ -257,6 +260,7 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
/* (non-Javadoc) /* (non-Javadoc)
* @see PamController.PamSettings#GetSettingsReference() * @see PamController.PamSettings#GetSettingsReference()
*/ */
@Override
public Serializable getSettingsReference() { public Serializable getSettingsReference() {
/* /*
* Save the entire array classes in the serialised file * Save the entire array classes in the serialised file
@ -275,6 +279,7 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
/* (non-Javadoc) /* (non-Javadoc)
* @see PamController.PamSettings#GetSettingsVersion() * @see PamController.PamSettings#GetSettingsVersion()
*/ */
@Override
public long getSettingsVersion() { public long getSettingsVersion() {
return ArrayParameters.serialVersionUID; return ArrayParameters.serialVersionUID;
} }
@ -282,6 +287,7 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
/* (non-Javadoc) /* (non-Javadoc)
* @see PamController.PamSettings#GetUnitName() * @see PamController.PamSettings#GetUnitName()
*/ */
@Override
public String getUnitName() { public String getUnitName() {
return "Array Manager"; return "Array Manager";
} }
@ -289,6 +295,7 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
/* (non-Javadoc) /* (non-Javadoc)
* @see PamController.PamSettings#getUnitType() * @see PamController.PamSettings#getUnitType()
*/ */
@Override
public String getUnitType() { public String getUnitType() {
return "Array Manager"; return "Array Manager";
} }
@ -296,6 +303,7 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
/* (non-Javadoc) /* (non-Javadoc)
* @see PamController.PamSettings#RestoreSettings(PamController.PamControlledUnitSettings) * @see PamController.PamSettings#RestoreSettings(PamController.PamControlledUnitSettings)
*/ */
@Override
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) { public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
try { try {
if (pamControlledUnitSettings.getSettings() != null) { if (pamControlledUnitSettings.getSettings() != null) {
@ -385,23 +393,28 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
// } // }
// } // }
@Override
public String getObserverName() { public String getObserverName() {
return "Array Manager"; return "Array Manager";
} }
@Override
public long getRequiredDataHistory(PamObservable o, Object arg) { public long getRequiredDataHistory(PamObservable o, Object arg) {
// would be better to work out how long the Gps data are being kept for and do the same // would be better to work out how long the Gps data are being kept for and do the same
return 3600*1000; return 3600*1000;
} }
@Override
public void noteNewSettings() { public void noteNewSettings() {
} }
@Override
public void removeObservable(PamObservable o) { public void removeObservable(PamObservable o) {
} }
@Override
public void setSampleRate(float sampleRate, boolean notify) { public void setSampleRate(float sampleRate, boolean notify) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -659,10 +672,10 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
} }
// need to find the direction vector for the plane. // need to find the direction vector for the plane.
// can do this by finding any non zero vector product. // can do this by finding any non zero vector product.
PamVector planePerpendicular = null;; PamVector planePerpendicular = null;
for (int i = 0; i < nPairs; i++) { for (int i = 0; i < nPairs; i++) {
for (int j = (i+1); j < nPairs; j++) { for (int j = (i+1); j < nPairs; j++) {
if (vectorPairs[i].isParallel(vectorPairs[j]) == false) { if (!vectorPairs[i].isParallel(vectorPairs[j])) {
planePerpendicular = vectorPairs[i].vecProd(vectorPairs[j]); planePerpendicular = vectorPairs[i].vecProd(vectorPairs[j]);
break; break;
} }
@ -771,7 +784,7 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
int nPairs = pvs.length; int nPairs = pvs.length;
for (int i = 0; i < nPairs; i++) { for (int i = 0; i < nPairs; i++) {
for (int j = i+1; j < nPairs; j++) { for (int j = i+1; j < nPairs; j++) {
if (pvs[i].isInLine(pvs[j]) == false) { if (!pvs[i].isInLine(pvs[j])) {
return false; return false;
} }
} }

View File

@ -1,7 +1,6 @@
package Array; package Array;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
import PamModel.parametermanager.ManagedParameters; import PamModel.parametermanager.ManagedParameters;

View File

@ -9,7 +9,7 @@ import Array.sensors.swing.ArrayDisplayParamsDialog;
import Array.swing.sidepanel.ArraySidePanel; import Array.swing.sidepanel.ArraySidePanel;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
import PamController.PamController; import PamController.PamControllerInterface;
import PamController.PamSettingManager; import PamController.PamSettingManager;
import PamController.PamSettings; import PamController.PamSettings;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
@ -45,13 +45,13 @@ public class ArraySidePanelControl extends PamControlledUnit implements ArrayDis
public void notifyModelChanged(int changeType) { public void notifyModelChanged(int changeType) {
super.notifyModelChanged(changeType); super.notifyModelChanged(changeType);
switch (changeType) { switch (changeType) {
case PamController.INITIALIZATION_COMPLETE: case PamControllerInterface.INITIALIZATION_COMPLETE:
case PamController.HYDROPHONE_ARRAY_CHANGED: case PamControllerInterface.HYDROPHONE_ARRAY_CHANGED:
if (arraySidePanel != null) { if (arraySidePanel != null) {
arraySidePanel.update(); arraySidePanel.update();
} }
break; break;
case PamController.NEW_SCROLL_TIME: case PamControllerInterface.NEW_SCROLL_TIME:
if (isViewer()) { if (isViewer()) {
arraySidePanel.updateViewerTime(PamCalendar.getTimeInMillis()); arraySidePanel.updateViewerTime(PamCalendar.getTimeInMillis());
} }

View File

@ -59,6 +59,7 @@ public class ChannelPanel implements ActionListener, ListSelectionListener {
channelTableData.fireTableDataChanged(); channelTableData.fireTableDataChanged();
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (e.getSource() == daqControllerList) { if (e.getSource() == daqControllerList) {
selectDaqController(); selectDaqController();
@ -167,10 +168,12 @@ public class ChannelPanel implements ActionListener, ListSelectionListener {
class ChannelTableData extends AbstractTableModel { class ChannelTableData extends AbstractTableModel {
@Override
public int getColumnCount() { public int getColumnCount() {
return channelColumns.length; return channelColumns.length;
} }
@Override
public int getRowCount() { public int getRowCount() {
if (acquisitionControl == null) return 0; if (acquisitionControl == null) return 0;
return (acquisitionControl.acquisitionParameters.nChannels); return (acquisitionControl.acquisitionParameters.nChannels);
@ -181,6 +184,7 @@ public class ChannelPanel implements ActionListener, ListSelectionListener {
return channelColumns[column]; return channelColumns[column];
} }
@Override
public Object getValueAt(int rowIndex, int columnIndex) { public Object getValueAt(int rowIndex, int columnIndex) {
if (acquisitionControl == null) return null; if (acquisitionControl == null) return null;
// see if the controller has a hydrophone list // see if the controller has a hydrophone list
@ -247,6 +251,7 @@ public class ChannelPanel implements ActionListener, ListSelectionListener {
/* (non-Javadoc) /* (non-Javadoc)
* @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
*/ */
@Override
public void valueChanged(ListSelectionEvent e) { public void valueChanged(ListSelectionEvent e) {
enableButtons(); enableButtons();
} }

View File

@ -1,7 +1,5 @@
package Array; package Array;
import GPS.GpsData;
public class EmptyLocatorSettings extends LocatorSettings { public class EmptyLocatorSettings extends LocatorSettings {
public EmptyLocatorSettings(Class locatorClass) { public EmptyLocatorSettings(Class locatorClass) {

View File

@ -30,9 +30,9 @@ import PamModel.parametermanager.ManagedParameters;
import PamModel.parametermanager.PamParameterSet; import PamModel.parametermanager.PamParameterSet;
import PamModel.parametermanager.PamParameterSet.ParameterSetType; import PamModel.parametermanager.PamParameterSet.ParameterSetType;
import PamModel.parametermanager.PrivatePamParameterData; import PamModel.parametermanager.PrivatePamParameterData;
import pamMaths.PamVector;
import PamView.PamSymbol; import PamView.PamSymbol;
import PamView.PamSymbolType; import PamView.PamSymbolType;
import pamMaths.PamVector;
/** /**
* *

View File

@ -3,12 +3,11 @@ package Array;
import java.util.ListIterator; import java.util.ListIterator;
import GPS.NavDataSynchronisation; import GPS.NavDataSynchronisation;
import pamScrollSystem.ViewLoadObserver;
import PamController.PamController; import PamController.PamController;
import PamUtils.PamCalendar;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;
import PamguardMVC.dataOffline.OfflineDataLoadInfo; import PamguardMVC.dataOffline.OfflineDataLoadInfo;
import pamScrollSystem.ViewLoadObserver;
public class HydrophoneDataBlock extends PamDataBlock<HydrophoneDataUnit> { public class HydrophoneDataBlock extends PamDataBlock<HydrophoneDataUnit> {
@ -104,7 +103,7 @@ public class HydrophoneDataBlock extends PamDataBlock<HydrophoneDataUnit> {
long difference; long difference;
ListIterator<HydrophoneDataUnit> listIterator = getListIterator(ITERATOR_END); ListIterator<HydrophoneDataUnit> listIterator = getListIterator(ITERATOR_END);
if (listIterator.hasPrevious() == false) { if (!listIterator.hasPrevious()) {
return null; return null;
} }
unit = listIterator.previous(); unit = listIterator.previous();

View File

@ -9,17 +9,19 @@ import java.awt.Point;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.util.Arrays; import java.util.Arrays;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import Acquisition.AcquisitionControl; import Acquisition.AcquisitionControl;
import GPS.GpsData; import GPS.GpsData;
import Layout.PamAxis; import Layout.PamAxis;
import Layout.PamAxisPanel; import Layout.PamAxisPanel;
import PamController.PamController; import PamController.PamController;
import PamUtils.LatLong; import PamUtils.LatLong;
import PamView.PamColors.PamColor;
import PamView.PamSymbol; import PamView.PamSymbol;
import PamView.PamSymbolType; import PamView.PamSymbolType;
import PamView.PamColors.PamColor;
import PamView.panel.PamBorder; import PamView.panel.PamBorder;
import pamMaths.PamVector; import pamMaths.PamVector;

View File

@ -25,8 +25,6 @@ import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
import Array.streamerOrigin.HydrophoneOriginMethod; import Array.streamerOrigin.HydrophoneOriginMethod;
import PamController.PamController; import PamController.PamController;
@ -219,6 +217,7 @@ public class HydrophoneDialogPanel implements ActionListener, ListSelectionListe
hydrophoneTableData.fireTableDataChanged(); hydrophoneTableData.fireTableDataChanged();
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (e.getSource() == recentArrays) { if (e.getSource() == recentArrays) {
arrayDialog.newArraySelection(); arrayDialog.newArraySelection();
@ -573,7 +572,7 @@ public class HydrophoneDialogPanel implements ActionListener, ListSelectionListe
/** /**
* and the hydrophones ... * and the hydrophones ...
*/ */
if (phonesToo == false) { if (!phonesToo) {
return; return;
} }
int nPhones = currentArray.getHydrophoneCount(); int nPhones = currentArray.getHydrophoneCount();
@ -694,11 +693,13 @@ public class HydrophoneDialogPanel implements ActionListener, ListSelectionListe
class HydrophoneTableData extends AbstractTableModel { class HydrophoneTableData extends AbstractTableModel {
@Override
public int getColumnCount() { public int getColumnCount() {
return hydrophoneColumns.length; return hydrophoneColumns.length;
} }
@Override
public int getRowCount() { public int getRowCount() {
PamArray currentArray = getDialogSelectedArray(); PamArray currentArray = getDialogSelectedArray();
if (currentArray == null) return 0; if (currentArray == null) return 0;
@ -710,6 +711,7 @@ public class HydrophoneDialogPanel implements ActionListener, ListSelectionListe
return hydrophoneColumns[column]; return hydrophoneColumns[column];
} }
@Override
public Object getValueAt(int rowIndex, int columnIndex) { public Object getValueAt(int rowIndex, int columnIndex) {
PamArray array = getDialogSelectedArray(); PamArray array = getDialogSelectedArray();
Hydrophone hydrophone = array.getHydrophone(rowIndex); Hydrophone hydrophone = array.getHydrophone(rowIndex);
@ -750,6 +752,7 @@ public class HydrophoneDialogPanel implements ActionListener, ListSelectionListe
/* (non-Javadoc) /* (non-Javadoc)
* @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
*/ */
@Override
public void valueChanged(ListSelectionEvent e) { public void valueChanged(ListSelectionEvent e) {
enableButtons(); enableButtons();
} }

View File

@ -110,8 +110,8 @@ public class HydrophoneElementDialog extends PamDialog {
@Override @Override
public boolean getParams() { public boolean getParams() {
if (generalPanel.getParams() == false) return false; if (!generalPanel.getParams()) return false;
if (coordinatePanel.getParams() == false) return false; if (!coordinatePanel.getParams()) return false;
// if (sensitivityPanel.getParams() == false) return false; // if (sensitivityPanel.getParams() == false) return false;
int hi = interpolationDialogPanel.getSelection(); int hi = interpolationDialogPanel.getSelection();
if (hi >= 0) { if (hi >= 0) {
@ -158,7 +158,7 @@ public class HydrophoneElementDialog extends PamDialog {
constraints.gridwidth = 1; constraints.gridwidth = 1;
constraints.gridx = 0; constraints.gridx = 0;
constraints.gridy++; constraints.gridy++;
addComponent(this, recieverTypeLabel = new JLabel("", JLabel.RIGHT), constraints); addComponent(this, recieverTypeLabel = new JLabel("", SwingConstants.RIGHT), constraints);
constraints.gridx++; constraints.gridx++;
constraints.gridwidth = 2; constraints.gridwidth = 2;
addComponent(this, type = new JTextField(12), constraints); addComponent(this, type = new JTextField(12), constraints);
@ -169,7 +169,7 @@ public class HydrophoneElementDialog extends PamDialog {
constraints.gridx = 0; constraints.gridx = 0;
constraints.gridy++; constraints.gridy++;
constraints.anchor = GridBagConstraints.EAST; constraints.anchor = GridBagConstraints.EAST;
addComponent(this, recieverSensLabel = new JLabel("", JLabel.RIGHT), constraints); addComponent(this, recieverSensLabel = new JLabel("", SwingConstants.RIGHT), constraints);
constraints.gridx++; constraints.gridx++;
constraints.anchor = GridBagConstraints.WEST; constraints.anchor = GridBagConstraints.WEST;
addComponent(this, hSens = new JTextField(5), constraints); addComponent(this, hSens = new JTextField(5), constraints);
@ -181,7 +181,7 @@ public class HydrophoneElementDialog extends PamDialog {
constraints.gridx = 0; constraints.gridx = 0;
constraints.gridy++; constraints.gridy++;
constraints.anchor = GridBagConstraints.EAST; constraints.anchor = GridBagConstraints.EAST;
addComponent(this, new JLabel("Preamplifier gain ", JLabel.RIGHT), constraints); addComponent(this, new JLabel("Preamplifier gain ", SwingConstants.RIGHT), constraints);
constraints.gridx++; constraints.gridx++;
constraints.anchor = GridBagConstraints.WEST; constraints.anchor = GridBagConstraints.WEST;
addComponent(this, preampGain = new JTextField(5), constraints); addComponent(this, preampGain = new JTextField(5), constraints);
@ -380,7 +380,7 @@ public class HydrophoneElementDialog extends PamDialog {
double zCoeff = PamController.getInstance().getGlobalMediumManager().getZCoeff(); double zCoeff = PamController.getInstance().getGlobalMediumManager().getZCoeff();
setRecieverLabelText(); setRecieverLabelText();
if (newHydrophone == false) { if (!newHydrophone) {
x.setText(formatDouble(hydrophone.getX())); x.setText(formatDouble(hydrophone.getX()));
y.setText(formatDouble(hydrophone.getY())); y.setText(formatDouble(hydrophone.getY()));
depth.setText(formatDouble(zCoeff*hydrophone.getZ())); depth.setText(formatDouble(zCoeff*hydrophone.getZ()));

View File

@ -3,14 +3,12 @@ package Array;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import Array.streamerOrigin.StreamerDataIterator;
import GPS.GpsData; import GPS.GpsData;
import PamModel.parametermanager.ManagedParameters; import PamModel.parametermanager.ManagedParameters;
import PamModel.parametermanager.PamParameterSet; import PamModel.parametermanager.PamParameterSet;
import PamModel.parametermanager.PamParameterSet.ParameterSetType; import PamModel.parametermanager.PamParameterSet.ParameterSetType;
import PamModel.parametermanager.PrivatePamParameterData; import PamModel.parametermanager.PrivatePamParameterData;
import PamUtils.LatLong; import PamUtils.LatLong;
import PamguardMVC.PamDataBlock;
import pamMaths.PamQuaternion; import pamMaths.PamQuaternion;
import pamMaths.PamVector; import pamMaths.PamVector;

View File

@ -3,7 +3,6 @@ package Array;
import java.util.ArrayList; import java.util.ArrayList;
import PamController.PamController; import PamController.PamController;
import PamController.PamguardVersionInfo;
public class HydrophoneLocators { public class HydrophoneLocators {

View File

@ -1,11 +1,10 @@
package Array; package Array;
import pamScrollSystem.AbstractScrollManager;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
import PamView.symbol.StandardSymbolManager; import PamView.symbol.StandardSymbolManager;
import PamguardMVC.PamConstants;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import PamguardMVC.PamProcess; import PamguardMVC.PamProcess;
import pamScrollSystem.AbstractScrollManager;
public class HydrophoneProcess extends PamProcess{ public class HydrophoneProcess extends PamProcess{

View File

@ -1,9 +1,9 @@
package Array; package Array;
import generalDatabase.SQLLogging;
import generalDatabase.SQLTypes;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;
import generalDatabase.SQLLogging;
import generalDatabase.SQLTypes;
public class HydrophoneSQLLogging extends SQLLogging { public class HydrophoneSQLLogging extends SQLLogging {

View File

@ -7,6 +7,7 @@ import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import PamView.dialog.PamGridBagContraints; import PamView.dialog.PamGridBagContraints;
@ -30,12 +31,12 @@ public class InstrumentIdentityPanel {
mainPanel.setBorder(new TitledBorder("Instrument information")); mainPanel.setBorder(new TitledBorder("Instrument information"));
mainPanel.setLayout(new GridBagLayout()); mainPanel.setLayout(new GridBagLayout());
GridBagConstraints c = new PamGridBagContraints(); GridBagConstraints c = new PamGridBagContraints();
mainPanel.add(new JLabel("Instrument Type ", JLabel.RIGHT), c); mainPanel.add(new JLabel("Instrument Type ", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
mainPanel.add(instrumentType = new JTextField(20), c); mainPanel.add(instrumentType = new JTextField(20), c);
c.gridx = 0; c.gridx = 0;
c.gridy++; c.gridy++;
mainPanel.add(new JLabel("Instrument Id ", JLabel.RIGHT), c); mainPanel.add(new JLabel("Instrument Id ", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
mainPanel.add(instrumentId = new JTextField(20), c); mainPanel.add(instrumentId = new JTextField(20), c);

View File

@ -2,23 +2,12 @@ package Array;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import Array.streamerOrigin.OriginSettings;
import GPS.GPSControl;
import GPS.GpsData; import GPS.GpsData;
import GPS.GpsDataUnit; import PamController.PamControllerInterface;
import PamController.PamController;
import PamController.PamSettingsSource;
import PamController.SettingsObject;
import PamController.masterReference.MasterReferencePoint;
import PamModel.parametermanager.ManagedParameters; import PamModel.parametermanager.ManagedParameters;
import PamModel.parametermanager.PamParameterSet; import PamModel.parametermanager.PamParameterSet;
import PamModel.parametermanager.PrivatePamParameterData; import PamModel.parametermanager.PrivatePamParameterData;
import PamUtils.LatLong;
import PamUtils.PamCalendar;
import PamguardMVC.PamDataBlock;
/** /**
* Master PAMGuard array localiser. There is now one of these and * Master PAMGuard array localiser. There is now one of these and
@ -192,8 +181,8 @@ public class MasterLocator extends HydrophoneLocator implements Serializable, Cl
// streamerLocators[i].notifyModelChanged(changeType); // streamerLocators[i].notifyModelChanged(changeType);
// } // }
if (initComplete) switch (changeType) { if (initComplete) switch (changeType) {
case PamController.HYDROPHONE_ARRAY_CHANGED: case PamControllerInterface.HYDROPHONE_ARRAY_CHANGED:
case PamController.INITIALIZATION_COMPLETE: case PamControllerInterface.INITIALIZATION_COMPLETE:
setupLocators(ArrayManager.getArrayManager().getCurrentArray()); setupLocators(ArrayManager.getArrayManager().getCurrentArray());
} }
} }
@ -238,7 +227,7 @@ public class MasterLocator extends HydrophoneLocator implements Serializable, Cl
boolean isStat = true; boolean isStat = true;
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
Streamer streamer = pamArray.getStreamer(i); Streamer streamer = pamArray.getStreamer(i);
if (streamer.getHydrophoneLocator().isStatic() == false) { if (!streamer.getHydrophoneLocator().isStatic()) {
isStat = false; isStat = false;
} }
} }

View File

@ -1,10 +1,5 @@
package Array; package Array;
import GPS.GpsData;
import GPS.GpsDataUnit;
import PamUtils.LatLong;
import PamguardMVC.PamDataBlock;
abstract public class MovingHydrophoneLocator extends SimpleHydrophoneLocator { abstract public class MovingHydrophoneLocator extends SimpleHydrophoneLocator {
/** /**

View File

@ -23,27 +23,21 @@ package Array;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import Acquisition.AcquisitionControl; import Acquisition.AcquisitionControl;
import pamMaths.PamVector;
import Array.streamerOrigin.HydrophoneOriginMethod;
import Array.streamerOrigin.OriginSettings; import Array.streamerOrigin.OriginSettings;
import Array.streamerOrigin.StreamerDataIterator;
import GPS.GpsData;
import PamModel.parametermanager.ManagedParameters; import PamModel.parametermanager.ManagedParameters;
import PamModel.parametermanager.PamParameterSet; import PamModel.parametermanager.PamParameterSet;
import PamModel.parametermanager.PamParameterSet.ParameterSetType; import PamModel.parametermanager.PamParameterSet.ParameterSetType;
import PamModel.parametermanager.PrivatePamParameterData; import PamModel.parametermanager.PrivatePamParameterData;
import PamUtils.LatLong;
import PamUtils.PamArrayUtils; import PamUtils.PamArrayUtils;
import PamUtils.PamCalendar;
import PamView.PamSymbol; import PamView.PamSymbol;
import PamguardMVC.ChannelIterator; import PamguardMVC.ChannelIterator;
import PamguardMVC.PamConstants; import PamguardMVC.PamConstants;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import pamMaths.PamVector;
/** /**
* *
@ -1281,7 +1275,7 @@ public class PamArray implements Serializable, Cloneable, ManagedParameters {
return preceeding.getStreamerData(); return preceeding.getStreamerData();
} }
// otherwise, we also want the next one ... // otherwise, we also want the next one ...
if (streamerIterator.hasNext() == false) { if (!streamerIterator.hasNext()) {
return preceeding.getStreamerData(); return preceeding.getStreamerData();
} }
nextUnit = streamerIterator.next(); nextUnit = streamerIterator.next();
@ -1293,7 +1287,7 @@ public class PamArray implements Serializable, Cloneable, ManagedParameters {
double w1 = nextUnit.getTimeMilliseconds()-timeMilliseconds; double w1 = nextUnit.getTimeMilliseconds()-timeMilliseconds;
double w2 = timeMilliseconds-preceeding.getTimeMilliseconds(); double w2 = timeMilliseconds-preceeding.getTimeMilliseconds();
double wTot = w1+w2; double wTot = w1+w2;
if (wTot == 0 || Double.isFinite(wTot) == false) { if (wTot == 0 || !Double.isFinite(wTot)) {
w1 = w2 = 0.5; w1 = w2 = 0.5;
} }
else { else {

View File

@ -73,7 +73,7 @@ public class Preamplifier implements Serializable, Cloneable, ManagedParameters
return (Preamplifier) super.clone(); return (Preamplifier) super.clone();
} }
catch (CloneNotSupportedException Ex) { catch (CloneNotSupportedException Ex) {
Ex.printStackTrace();; Ex.printStackTrace();
return null; return null;
} }
} }

View File

@ -2,11 +2,6 @@ package Array;
import java.util.ArrayList; import java.util.ArrayList;
import javax.vecmath.Point3d;
import javax.vecmath.Point3f;
import GPS.GpsData;
import pamMaths.PamVector; import pamMaths.PamVector;
/** /**

View File

@ -1,21 +1,13 @@
package Array; package Array;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ListIterator;
import depthReadout.DepthControl;
import depthReadout.DepthDataBlock;
import depthReadout.DepthDataUnit;
import Array.streamerOrigin.HydrophoneOriginMethod;
import GPS.GpsData; import GPS.GpsData;
import GPS.GpsDataUnit; import GPS.GpsDataUnit;
import PamModel.parametermanager.ManagedParameters; import PamModel.parametermanager.ManagedParameters;
import PamModel.parametermanager.PamParameterSet; import PamModel.parametermanager.PamParameterSet;
import PamModel.parametermanager.PrivatePamParameterData; import PamModel.parametermanager.PrivatePamParameterData;
import PamUtils.LatLong;
import PamUtils.PamUtils;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import PamguardMVC.PamObservable;
/** /**
* Straight Hydrophone Locator, uses GPS heading information from * Straight Hydrophone Locator, uses GPS heading information from

View File

@ -13,7 +13,7 @@ import Array.streamerOrigin.GPSOriginSettings;
import Array.streamerOrigin.HydrophoneOriginMethod; import Array.streamerOrigin.HydrophoneOriginMethod;
import Array.streamerOrigin.HydrophoneOriginMethods; import Array.streamerOrigin.HydrophoneOriginMethods;
import Array.streamerOrigin.OriginSettings; import Array.streamerOrigin.OriginSettings;
import PamController.PamController; import PamController.PamControllerInterface;
import PamController.masterReference.MasterReferencePoint; import PamController.masterReference.MasterReferencePoint;
import PamModel.parametermanager.ManagedParameters; import PamModel.parametermanager.ManagedParameters;
import PamModel.parametermanager.PamParameterSet; import PamModel.parametermanager.PamParameterSet;
@ -560,7 +560,7 @@ public class Streamer implements Serializable, Cloneable, ManagedParameters {
hydrophoneOrigin.prepare(); hydrophoneOrigin.prepare();
} }
switch (changeType) { switch (changeType) {
case PamController.INITIALIZATION_COMPLETE: case PamControllerInterface.INITIALIZATION_COMPLETE:
// if (PamController.getInstance().getRunMode() == PamController.RUN_NORMAL) { // if (PamController.getInstance().getRunMode() == PamController.RUN_NORMAL) {
// makeStreamerDataUnit(); // makeStreamerDataUnit();
// } // }
@ -886,7 +886,7 @@ public class Streamer implements Serializable, Cloneable, ManagedParameters {
break; break;
case HEIGHT: case HEIGHT:
if (value != null) { if (value != null) {
setZ(value);; setZ(value);
} }
break; break;
case PITCH: case PITCH:

View File

@ -94,6 +94,7 @@ public class StreamerDataBlock extends PamDataBlock<StreamerDataUnit>{
} }
} }
@Override
public boolean loadViewerData(OfflineDataLoadInfo offlineDataLoadInfo, ViewLoadObserver loadObserver) { public boolean loadViewerData(OfflineDataLoadInfo offlineDataLoadInfo, ViewLoadObserver loadObserver) {
return super.loadViewerData(offlineDataLoadInfo, loadObserver); return super.loadViewerData(offlineDataLoadInfo, loadObserver);
} }

View File

@ -2,9 +2,7 @@ package Array;
import Array.sensors.ArrayParameterType; import Array.sensors.ArrayParameterType;
import Array.sensors.ArraySensorFieldType; import Array.sensors.ArraySensorFieldType;
import Array.streamerOrigin.HydrophoneOriginMethod;
import Array.streamerOrigin.OriginSettings; import Array.streamerOrigin.OriginSettings;
import Array.streamerOrigin.StaticOriginMethod;
import Array.streamerOrigin.StaticOriginSettings; import Array.streamerOrigin.StaticOriginSettings;
import GPS.GpsData; import GPS.GpsData;
import GPS.GpsDataUnit; import GPS.GpsDataUnit;

View File

@ -7,16 +7,15 @@ import java.awt.Insets;
import java.awt.Window; import java.awt.Window;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.ListIterator;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JSeparator; import javax.swing.JSeparator;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
@ -123,7 +122,7 @@ public class StreamerDialog extends PamDialog {
addComponent(p, new JLabel("Error"), c); addComponent(p, new JLabel("Error"), c);
c.gridx = 0; c.gridx = 0;
c.gridy ++; c.gridy ++;
addComponent(p, new JLabel("x ", JLabel.RIGHT), c); addComponent(p, new JLabel("x ", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
addComponent(p, x = new JTextField(textLength), c); addComponent(p, x = new JTextField(textLength), c);
c.gridx++; c.gridx++;
@ -133,7 +132,7 @@ public class StreamerDialog extends PamDialog {
c.gridx = 0; c.gridx = 0;
c.gridy ++; c.gridy ++;
addComponent(p, new JLabel("y ", JLabel.RIGHT), c); addComponent(p, new JLabel("y ", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
addComponent(p, y = new JTextField(textLength), c); addComponent(p, y = new JTextField(textLength), c);
c.gridx++; c.gridx++;
@ -143,7 +142,7 @@ public class StreamerDialog extends PamDialog {
c.gridx = 0; c.gridx = 0;
c.gridy ++; c.gridy ++;
addComponent(p, streamerHeightLabel = new JLabel(" ", JLabel.RIGHT), c); // set in setStreamerLabels addComponent(p, streamerHeightLabel = new JLabel(" ", SwingConstants.RIGHT), c); // set in setStreamerLabels
c.gridx++; c.gridx++;
addComponent(p, z = new JTextField(textLength), c); addComponent(p, z = new JTextField(textLength), c);
c.gridx++; c.gridx++;
@ -196,29 +195,29 @@ public class StreamerDialog extends PamDialog {
String degsLab = LatLong.deg + " "; String degsLab = LatLong.deg + " ";
c.gridx = 0; c.gridx = 0;
c.gridy++; c.gridy++;
addComponent(headPanel, new JLabel("Heading ", JLabel.RIGHT), c); addComponent(headPanel, new JLabel("Heading ", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
addComponent(headPanel, heading = new JTextField(orWidth), c); addComponent(headPanel, heading = new JTextField(orWidth), c);
c.gridx++; c.gridx++;
addComponent(headPanel, new JLabel(degsLab, JLabel.LEFT), c); addComponent(headPanel, new JLabel(degsLab, SwingConstants.LEFT), c);
c.gridx++; c.gridx++;
addComponent(headPanel, sensorComponents[ArraySensorFieldType.HEADING.ordinal()].getComponent(), c); addComponent(headPanel, sensorComponents[ArraySensorFieldType.HEADING.ordinal()].getComponent(), c);
c.gridx = 0; c.gridx = 0;
c.gridy++; c.gridy++;
addComponent(headPanel, new JLabel("Pitch ", JLabel.RIGHT), c); addComponent(headPanel, new JLabel("Pitch ", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
addComponent(headPanel, pitch = new JTextField(orWidth), c); addComponent(headPanel, pitch = new JTextField(orWidth), c);
c.gridx++; c.gridx++;
addComponent(headPanel, new JLabel(degsLab, JLabel.LEFT), c); addComponent(headPanel, new JLabel(degsLab, SwingConstants.LEFT), c);
c.gridx++; c.gridx++;
addComponent(headPanel, sensorComponents[ArraySensorFieldType.PITCH.ordinal()].getComponent(), c); addComponent(headPanel, sensorComponents[ArraySensorFieldType.PITCH.ordinal()].getComponent(), c);
c.gridx = 0; c.gridx = 0;
c.gridy++; c.gridy++;
addComponent(headPanel, new JLabel("Roll ", JLabel.RIGHT), c); addComponent(headPanel, new JLabel("Roll ", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
addComponent(headPanel, roll = new JTextField(orWidth), c); addComponent(headPanel, roll = new JTextField(orWidth), c);
c.gridx++; c.gridx++;
addComponent(headPanel, new JLabel(degsLab, JLabel.LEFT), c); addComponent(headPanel, new JLabel(degsLab, SwingConstants.LEFT), c);
c.gridx++; c.gridx++;
addComponent(headPanel, sensorComponents[ArraySensorFieldType.ROLL.ordinal()].getComponent(), c); addComponent(headPanel, sensorComponents[ArraySensorFieldType.ROLL.ordinal()].getComponent(), c);
@ -240,7 +239,7 @@ public class StreamerDialog extends PamDialog {
locPanel.setLayout(new BorderLayout()); locPanel.setLayout(new BorderLayout());
locPanel.setBorder(locateRecieverBorder = new TitledBorder("")); //set by steStreamerLabels locPanel.setBorder(locateRecieverBorder = new TitledBorder("")); //set by steStreamerLabels
locPanel.add(BorderLayout.WEST, relPanel); locPanel.add(BorderLayout.WEST, relPanel);
locPanel.add(BorderLayout.CENTER, new JSeparator(JSeparator.VERTICAL)); locPanel.add(BorderLayout.CENTER, new JSeparator(SwingConstants.VERTICAL));
locPanel.add(BorderLayout.EAST, headPanel); locPanel.add(BorderLayout.EAST, headPanel);
getMainPanel().add(locPanel); getMainPanel().add(locPanel);
getMainPanel().add(interpolationPanel.getComponent(getOwner())); getMainPanel().add(interpolationPanel.getComponent(getOwner()));
@ -403,7 +402,7 @@ public class StreamerDialog extends PamDialog {
} }
OriginDialogComponent mthDialogComponent = currentOriginMethod.getDialogComponent(); OriginDialogComponent mthDialogComponent = currentOriginMethod.getDialogComponent();
if (mthDialogComponent != null) { if (mthDialogComponent != null) {
if (mthDialogComponent.getParams() == false) { if (!mthDialogComponent.getParams()) {
return false; return false;
} }
} }
@ -517,7 +516,7 @@ public class StreamerDialog extends PamDialog {
} }
public void newOriginMethod() { public void newOriginMethod() {
if (constructed == false) { if (!constructed) {
return; return;
} }
int methInd = originMethod.getSelectedIndex(); int methInd = originMethod.getSelectedIndex();

View File

@ -1,6 +1,5 @@
package Array; package Array;
import java.sql.Connection;
import java.sql.Types; import java.sql.Types;
import Array.sensors.ArrayParameterType; import Array.sensors.ArrayParameterType;
@ -8,11 +7,6 @@ import Array.sensors.ArraySensorFieldType;
import Array.streamerOrigin.HydrophoneOriginMethod; import Array.streamerOrigin.HydrophoneOriginMethod;
import Array.streamerOrigin.HydrophoneOriginMethods; import Array.streamerOrigin.HydrophoneOriginMethods;
import Array.streamerOrigin.HydrophoneOriginSystem; import Array.streamerOrigin.HydrophoneOriginSystem;
import Array.streamerOrigin.OriginSettings;
import Array.streamerOrigin.StaticOriginSettings;
import GPS.GPSDataBlock;
import GPS.GpsData;
import GPS.GpsDataUnit;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;

View File

@ -5,18 +5,16 @@ import java.awt.Graphics;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Window; import java.awt.Window;
import Array.streamerOrigin.HydrophoneOriginMethod;
import GPS.GpsData; import GPS.GpsData;
import GPS.GpsDataUnit;
import PamUtils.Coordinate3d; import PamUtils.Coordinate3d;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
import PamView.GeneralProjector; import PamView.GeneralProjector;
import PamView.GeneralProjector.ParameterType;
import PamView.GeneralProjector.ParameterUnits;
import PamView.PamKeyItem; import PamView.PamKeyItem;
import PamView.PamSymbol; import PamView.PamSymbol;
import PamView.PamSymbolType; import PamView.PamSymbolType;
import PamView.PanelOverlayDraw; import PamView.PanelOverlayDraw;
import PamView.GeneralProjector.ParameterType;
import PamView.GeneralProjector.ParameterUnits;
import PamView.symbol.SymbolData; import PamView.symbol.SymbolData;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;

View File

@ -1,15 +1,10 @@
package Array; package Array;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ListIterator;
import pamMaths.PamVector;
import Array.sensors.StreamerSensorManager;
import Array.streamerOrigin.HydrophoneOriginMethod; import Array.streamerOrigin.HydrophoneOriginMethod;
import Array.streamerOrigin.OriginIterator; import Array.streamerOrigin.OriginIterator;
import GPS.GPSControl;
import GPS.GPSDataBlock;
import GPS.GpsData; import GPS.GpsData;
import GPS.GpsDataUnit;
import GPS.NavDataSynchronisation; import GPS.NavDataSynchronisation;
import PamModel.parametermanager.ManagedParameters; import PamModel.parametermanager.ManagedParameters;
import PamModel.parametermanager.PamParameterSet; import PamModel.parametermanager.PamParameterSet;
@ -92,7 +87,7 @@ public class ThreadingHydrophoneLocator extends StraightHydrophoneLocator implem
*/ */
gpsUnit = gpsIt.previous(); gpsUnit = gpsIt.previous();
} }
if (gpsIt.hasPrevious() == false) { if (!gpsIt.hasPrevious()) {
/** /**
* We're off the start of the available track, so can do nothing except use the stright model to * We're off the start of the available track, so can do nothing except use the stright model to
* interpolate backwards. * interpolate backwards.

View File

@ -7,13 +7,13 @@ import java.io.Serializable;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import mcc.MccJniInterface;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
import PamController.PamSettingManager; import PamController.PamSettingManager;
import PamController.PamSettings; import PamController.PamSettings;
import PamView.PamSidePanel; import PamView.PamSidePanel;
import PamView.dialog.warn.WarnOnce; import PamView.dialog.warn.WarnOnce;
import mcc.MccJniInterface;
public class ArrayAccelControl extends PamControlledUnit implements PamSettings { public class ArrayAccelControl extends PamControlledUnit implements PamSettings {

View File

@ -1,10 +1,10 @@
package ArrayAccelerometer; package ArrayAccelerometer;
import pamMaths.PamVector;
import Array.sensors.ArraySensorDataUnit; import Array.sensors.ArraySensorDataUnit;
import Array.sensors.ArraySensorFieldType; import Array.sensors.ArraySensorFieldType;
import PamUtils.PamUtils; import PamUtils.PamUtils;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;
import pamMaths.PamVector;
public class ArrayAccelDataUnit extends PamDataUnit implements ArraySensorDataUnit { public class ArrayAccelDataUnit extends PamDataUnit implements ArraySensorDataUnit {

View File

@ -9,18 +9,18 @@ import java.awt.event.ActionListener;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import PamView.dialog.PamDialog;
import PamView.dialog.PamGridBagContraints;
import mcc.MccJniInterface; import mcc.MccJniInterface;
import mcc.MccPanel; import mcc.MccPanel;
import mcc.mccjna.MCCException; import mcc.mccjna.MCCException;
import mcc.mccjna.MCCUtils; import mcc.mccjna.MCCUtils;
import PamView.dialog.PamDialog;
import PamView.dialog.PamGridBagContraints;
public class ArrayAccelDialog extends PamDialog { public class ArrayAccelDialog extends PamDialog {
@ -52,17 +52,17 @@ public class ArrayAccelDialog extends PamDialog {
JPanel rPanel = new JPanel(new GridBagLayout()); JPanel rPanel = new JPanel(new GridBagLayout());
rPanel.setBorder(new TitledBorder("Readout")); rPanel.setBorder(new TitledBorder("Readout"));
GridBagConstraints c = new PamGridBagContraints(); GridBagConstraints c = new PamGridBagContraints();
rPanel.add(new JLabel("Read interval ", JLabel.RIGHT), c); rPanel.add(new JLabel("Read interval ", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
rPanel.add(readInterval = new JTextField(5), c); rPanel.add(readInterval = new JTextField(5), c);
readInterval.setToolTipText("Readout interval in seconds"); readInterval.setToolTipText("Readout interval in seconds");
c.gridx++; c.gridx++;
rPanel.add(new JLabel(" s", JLabel.LEFT), c); rPanel.add(new JLabel(" s", SwingConstants.LEFT), c);
for (int i = 0; i < ArrayAccelParams.NDIMENSIONS; i++) { for (int i = 0; i < ArrayAccelParams.NDIMENSIONS; i++) {
c.gridx = 0; c.gridx = 0;
c.gridy++; c.gridy++;
c.fill = GridBagConstraints.HORIZONTAL; c.fill = GridBagConstraints.HORIZONTAL;
rPanel.add(new JLabel("Channel " + ArrayAccelParams.DIMENSIONNAME[i] + " ", JLabel.RIGHT), c); rPanel.add(new JLabel("Channel " + ArrayAccelParams.DIMENSIONNAME[i] + " ", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
c.fill = GridBagConstraints.NONE; c.fill = GridBagConstraints.NONE;
rPanel.add(dimChannel[i] = new JTextField(3), c); rPanel.add(dimChannel[i] = new JTextField(3), c);
@ -75,23 +75,23 @@ public class ArrayAccelDialog extends PamDialog {
calPanel.setBorder(new TitledBorder("Calibration")); calPanel.setBorder(new TitledBorder("Calibration"));
c = new PamGridBagContraints(); c = new PamGridBagContraints();
c.gridx = 1; c.gridx = 1;
calPanel.add(new JLabel("Zero", JLabel.CENTER), c); calPanel.add(new JLabel("Zero", SwingConstants.CENTER), c);
c.gridx += 2; c.gridx += 2;
calPanel.add(new JLabel("Scale", JLabel.CENTER), c); calPanel.add(new JLabel("Scale", SwingConstants.CENTER), c);
for (int i = 0; i < ArrayAccelParams.NDIMENSIONS; i++) { for (int i = 0; i < ArrayAccelParams.NDIMENSIONS; i++) {
c.gridy ++; c.gridy ++;
c.gridx = 0; c.gridx = 0;
calPanel.add(new JLabel(ArrayAccelParams.DIMENSIONNAME[i] + " ", JLabel.RIGHT), c); calPanel.add(new JLabel(ArrayAccelParams.DIMENSIONNAME[i] + " ", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
calPanel.add(zeroVolts[i] = new JTextField(5), c); calPanel.add(zeroVolts[i] = new JTextField(5), c);
zeroVolts[i].setToolTipText(String.format("Offset voltage for %s coordinate", ArrayAccelParams.DIMENSIONNAME[i])); zeroVolts[i].setToolTipText(String.format("Offset voltage for %s coordinate", ArrayAccelParams.DIMENSIONNAME[i]));
c.gridx++; c.gridx++;
calPanel.add(new JLabel(" V, ", JLabel.LEFT), c); calPanel.add(new JLabel(" V, ", SwingConstants.LEFT), c);
c.gridx++; c.gridx++;
calPanel.add(voltsPerG[i] = new JTextField(5), c); calPanel.add(voltsPerG[i] = new JTextField(5), c);
voltsPerG[i].setToolTipText(String.format("Voltage scale for %s coordinate", ArrayAccelParams.DIMENSIONNAME[i])); voltsPerG[i].setToolTipText(String.format("Voltage scale for %s coordinate", ArrayAccelParams.DIMENSIONNAME[i]));
c.gridx++; c.gridx++;
calPanel.add(new JLabel(" V/g ", JLabel.LEFT), c); calPanel.add(new JLabel(" V/g ", SwingConstants.LEFT), c);
} }
c.gridx = 0; c.gridx = 0;
c.gridwidth = 3; c.gridwidth = 3;
@ -103,23 +103,23 @@ public class ArrayAccelDialog extends PamDialog {
c.gridy++; c.gridy++;
c.gridx = 0; c.gridx = 0;
c.gridwidth = 3; c.gridwidth = 3;
calPanel.add(new JLabel("Roll offset ", JLabel.RIGHT), c); calPanel.add(new JLabel("Roll offset ", SwingConstants.RIGHT), c);
c.gridx += c.gridwidth; c.gridx += c.gridwidth;
c.gridwidth = 1; c.gridwidth = 1;
calPanel.add(rollOffset = new JTextField(5), c); calPanel.add(rollOffset = new JTextField(5), c);
rollOffset.setToolTipText("This value gets ADDED to the measured roll"); rollOffset.setToolTipText("This value gets ADDED to the measured roll");
c.gridx++; c.gridx++;
calPanel.add(new JLabel(" deg.", JLabel.LEFT), c); calPanel.add(new JLabel(" deg.", SwingConstants.LEFT), c);
c.gridy++; c.gridy++;
c.gridx = 0; c.gridx = 0;
c.gridwidth = 3; c.gridwidth = 3;
calPanel.add(new JLabel("Pitch offset ", JLabel.RIGHT), c); calPanel.add(new JLabel("Pitch offset ", SwingConstants.RIGHT), c);
c.gridx += c.gridwidth; c.gridx += c.gridwidth;
c.gridwidth = 1; c.gridwidth = 1;
calPanel.add(pitchOffset = new JTextField(5), c); calPanel.add(pitchOffset = new JTextField(5), c);
pitchOffset.setToolTipText("This value gets ADDED to the measured pitch"); pitchOffset.setToolTipText("This value gets ADDED to the measured pitch");
c.gridx++; c.gridx++;
calPanel.add(new JLabel(" deg.", JLabel.LEFT), c); calPanel.add(new JLabel(" deg.", SwingConstants.LEFT), c);
@ -226,7 +226,7 @@ public class ArrayAccelDialog extends PamDialog {
* Set the zero voltage for each channel. * Set the zero voltage for each channel.
*/ */
public void findZero() { public void findZero() {
if (getParams() == false) { if (!getParams()) {
return; return;
} }
// read the voltages from the three channels and set as // read the voltages from the three channels and set as

View File

@ -15,12 +15,10 @@ import PamUtils.LatLong;
import PamView.PamColors; import PamView.PamColors;
import PamView.PamColors.PamColor; import PamView.PamColors.PamColor;
import PamView.panel.PamBorder; import PamView.panel.PamBorder;
import PamView.panel.PamBorderPanel;
import PamView.panel.PamPanel; import PamView.panel.PamPanel;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit; import PamguardMVC.PamDataUnit;
import PamguardMVC.PamObservable; import PamguardMVC.PamObservable;
import PamguardMVC.PamObserver;
import PamguardMVC.PamObserverAdapter; import PamguardMVC.PamObserverAdapter;
/* /*
@ -36,7 +34,7 @@ public class ArrayAccelPanel {
private long zeroGraphTime; private long zeroGraphTime;
private ArrayAccelDataBlock accelDataBlock; private ArrayAccelDataBlock accelDataBlock;
private int panelDurationSecs = 300; private int panelDurationSecs = 300;
private double timeScale = 1;; private double timeScale = 1;
public ArrayAccelPanel(ArrayAccelControl accelControl) { public ArrayAccelPanel(ArrayAccelControl accelControl) {

View File

@ -1,12 +1,10 @@
package ArrayAccelerometer; package ArrayAccelerometer;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays;
import PamModel.parametermanager.ManagedParameters; import PamModel.parametermanager.ManagedParameters;
import PamModel.parametermanager.PamParameterSet; import PamModel.parametermanager.PamParameterSet;
import PamModel.parametermanager.PamParameterSet.ParameterSetType; import PamModel.parametermanager.PamParameterSet.ParameterSetType;
import mcc.MccJniInterface;
import mcc.mccjna.MCCConstants; import mcc.mccjna.MCCConstants;
public class ArrayAccelParams implements Serializable, Cloneable, ManagedParameters { public class ArrayAccelParams implements Serializable, Cloneable, ManagedParameters {

View File

@ -5,17 +5,12 @@ import java.awt.event.ActionListener;
import javax.swing.Timer; import javax.swing.Timer;
import PamController.PamController;
import PamUtils.PamCalendar;
import PamguardMVC.PamProcess;
import mcc.MccJniInterface; import mcc.MccJniInterface;
import mcc.mccjna.MCCException; import mcc.mccjna.MCCException;
import mcc.mccjna.MCCUtils; import mcc.mccjna.MCCUtils;
import Array.ArrayManager;
import Array.PamArray;
import Array.Streamer;
import PamController.PamControlledUnit;
import PamController.PamController;
import PamUtils.PamCalendar;
import PamguardMVC.PamDataBlock;
import PamguardMVC.PamProcess;
public class ArrayAccelProcess extends PamProcess { public class ArrayAccelProcess extends PamProcess {

View File

@ -1,11 +1,8 @@
package ArrayAccelerometer; package ArrayAccelerometer;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import PamView.PamColors.PamColor;
import PamView.panel.PamPanel;
import PamView.PamSidePanel; import PamView.PamSidePanel;
public class ArrayAccelSidePanel implements PamSidePanel { public class ArrayAccelSidePanel implements PamSidePanel {

View File

@ -2,8 +2,6 @@ package Azigram;
import java.util.Arrays; import java.util.Arrays;
import Acquisition.AcquisitionProcess;
import PamUtils.PamUtils;
import PamUtils.complex.ComplexArray; import PamUtils.complex.ComplexArray;
import fftManager.FFTDataUnit; import fftManager.FFTDataUnit;

View File

@ -8,8 +8,6 @@ import PamModel.parametermanager.PamParameterSet;
import PamModel.parametermanager.PamParameterSet.ParameterSetType; import PamModel.parametermanager.PamParameterSet.ParameterSetType;
import PamModel.parametermanager.PrivatePamParameterData; import PamModel.parametermanager.PrivatePamParameterData;
import PamView.GroupedSourceParameters; import PamView.GroupedSourceParameters;
import PamguardMVC.PamConstants;
import whistlesAndMoans.WhistleToneParameters;
public class AzigramParameters implements Serializable, ManagedParameters, Cloneable { public class AzigramParameters implements Serializable, ManagedParameters, Cloneable {

View File

@ -8,19 +8,14 @@ import java.io.Serializable;
import javax.swing.JMenu; import javax.swing.JMenu;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import Filters.layoutFX.FilterGUIFX; import Filters.layoutFX.FilterGUIFX;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamControlledUnitGUI; import PamController.PamControlledUnitGUI;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
import PamController.PamController;
import PamController.PamControllerInterface; import PamController.PamControllerInterface;
import PamController.PamGUIManager; import PamController.PamGUIManager;
import PamController.PamSettingManager; import PamController.PamSettingManager;
import PamController.PamSettings; import PamController.PamSettings;
import fftManager.layoutFX.FFTGuiFX;
/** /**
* Filters raw data using a specified filter. * Filters raw data using a specified filter.
@ -71,6 +66,7 @@ public class FilterControl extends PamControlledUnit implements PamSettings {
this.parentFrame = parentFrame; this.parentFrame = parentFrame;
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
FilterParameters_2 newParams = FilterDataSourceDialog.showDialog(filterParams, parentFrame, filterProcess.outputData); FilterParameters_2 newParams = FilterDataSourceDialog.showDialog(filterParams, parentFrame, filterProcess.outputData);
@ -90,6 +86,7 @@ public class FilterControl extends PamControlledUnit implements PamSettings {
super(); super();
this.parentFrame = parentFrame; this.parentFrame = parentFrame;
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
FilterParams newParams = FilterDialog.showDialog(parentFrame, FilterParams newParams = FilterDialog.showDialog(parentFrame,
@ -109,7 +106,7 @@ public class FilterControl extends PamControlledUnit implements PamSettings {
public void notifyModelChanged(int changeType) { public void notifyModelChanged(int changeType) {
//System.out.println("FFTControl: notifyModelChanged : " +changeType); //System.out.println("FFTControl: notifyModelChanged : " +changeType);
super.notifyModelChanged(changeType); super.notifyModelChanged(changeType);
if (changeType == PamController.INITIALIZATION_COMPLETE) { if (changeType == PamControllerInterface.INITIALIZATION_COMPLETE) {
filterProcess.setupProcess(); filterProcess.setupProcess();
} }
if (filterGUIFX!=null) { if (filterGUIFX!=null) {
@ -117,14 +114,17 @@ public class FilterControl extends PamControlledUnit implements PamSettings {
} }
} }
@Override
public Serializable getSettingsReference() { public Serializable getSettingsReference() {
return filterParams; return filterParams;
} }
@Override
public long getSettingsVersion() { public long getSettingsVersion() {
return FilterParams.serialVersionUID; return FilterParams.serialVersionUID;
} }
@Override
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) { public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
filterParams = ((FilterParameters_2) pamControlledUnitSettings.getSettings()).clone(); filterParams = ((FilterParameters_2) pamControlledUnitSettings.getSettings()).clone();
return true; return true;

View File

@ -1,6 +1,7 @@
package Filters; package Filters;
import java.awt.Frame; import java.awt.Frame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;

View File

@ -21,6 +21,7 @@
package Filters; package Filters;
import java.awt.Window; import java.awt.Window;
import PamView.dialog.PamDialog; import PamView.dialog.PamDialog;
public class FilterDialog extends PamDialog { public class FilterDialog extends PamDialog {

View File

@ -37,10 +37,14 @@ import javax.swing.JRadioButton;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
import com.opencsv.CSVReader;
import com.opencsv.exceptions.CsvException;
import Layout.PamAxis; import Layout.PamAxis;
import PamUtils.PamFileChooser; import PamUtils.PamFileChooser;
import PamUtils.PamFileFilter; import PamUtils.PamFileFilter;
@ -49,9 +53,6 @@ import PamView.PamColors.PamColor;
import PamView.dialog.PamDialog; import PamView.dialog.PamDialog;
import PamView.dialog.PamGridBagContraints; import PamView.dialog.PamGridBagContraints;
import PamView.panel.PamPanel; import PamView.panel.PamPanel;
import com.opencsv.CSVReader;
import com.opencsv.exceptions.CsvException;
import fftManager.Complex; import fftManager.Complex;
/** /**
@ -188,8 +189,9 @@ public class FilterDialogPanel implements ActionListener {
repaintAll(); repaintAll();
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (isSetup == false) { if (!isSetup) {
return; return;
} }
if (e.getSource() == filterTypes) { if (e.getSource() == filterTypes) {
@ -235,7 +237,7 @@ public class FilterDialogPanel implements ActionListener {
break; break;
} }
boolean isArb = filterType == 4; boolean isArb = filterType == 4;
normalPanel.setVisible(isArb == false); normalPanel.setVisible(!isArb);
arbPanel.setVisible(isArb); arbPanel.setVisible(isArb);
} }
@ -321,14 +323,14 @@ public class FilterDialogPanel implements ActionListener {
c.gridwidth = 1; c.gridwidth = 1;
c.gridy++; c.gridy++;
c.gridx = xc; c.gridx = xc;
normalPanel.add(new JLabel(" High Pass", JLabel.RIGHT), c); normalPanel.add(new JLabel(" High Pass", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
normalPanel.add(highCut, c); normalPanel.add(highCut, c);
c.gridx++; c.gridx++;
normalPanel.add(new JLabel(" Hz"), c); normalPanel.add(new JLabel(" Hz"), c);
c.gridy++; c.gridy++;
c.gridx = xc; c.gridx = xc;
normalPanel.add(new JLabel(" Low Pass", JLabel.RIGHT), c); normalPanel.add(new JLabel(" Low Pass", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
normalPanel.add(lowCut, c); normalPanel.add(lowCut, c);
c.gridx++; c.gridx++;
@ -702,10 +704,10 @@ public class FilterDialogPanel implements ActionListener {
if (filterMethod == null) { if (filterMethod == null) {
return; return;
} }
if (IIRFilterMethod.class.isAssignableFrom(filterMethod.getClass()) == true) { if (IIRFilterMethod.class.isAssignableFrom(filterMethod.getClass())) {
paintPoleZeros(g); paintPoleZeros(g);
} }
else if (FIRFilterMethod.class.isAssignableFrom(filterMethod.getClass()) == true) { else if (FIRFilterMethod.class.isAssignableFrom(filterMethod.getClass())) {
paintImpulseResponse(g); paintImpulseResponse(g);
} }
} }

View File

@ -20,8 +20,6 @@
*/ */
package Filters; package Filters;
import fftManager.Complex;
/** /**
* @author Doug Gillespie * @author Doug Gillespie
* <p> * <p>

View File

@ -2,9 +2,6 @@ package Filters;
import java.io.Serializable; import java.io.Serializable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import PamModel.parametermanager.ManagedParameters; import PamModel.parametermanager.ManagedParameters;
import PamModel.parametermanager.PamParameterSet; import PamModel.parametermanager.PamParameterSet;
import PamModel.parametermanager.PamParameterSet.ParameterSetType; import PamModel.parametermanager.PamParameterSet.ParameterSetType;

View File

@ -22,12 +22,7 @@ package Filters;
import java.io.File; import java.io.File;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import PamController.PamControlledUnit;
import PamModel.parametermanager.ManagedParameters; import PamModel.parametermanager.ManagedParameters;
import PamModel.parametermanager.PamParameterSet; import PamModel.parametermanager.PamParameterSet;
import PamModel.parametermanager.PamParameterSet.ParameterSetType; import PamModel.parametermanager.PamParameterSet.ParameterSetType;

View File

@ -28,7 +28,7 @@ public class FilterSpeed {
data[i] = r.nextGaussian(); data[i] = r.nextGaussian();
} }
testData = data.clone(); testData = data.clone();
long sn, en, mn = 0;; long sn, en, mn = 0;
double a; double a;
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
for (int i = 0; i < nTrials; i++) { for (int i = 0; i < nTrials; i++) {

View File

@ -229,6 +229,7 @@ public abstract class IIRFilterMethod extends FilterMethod {
* Get coefficients from poles and zeros for fast filter computations. * Get coefficients from poles and zeros for fast filter computations.
* @return * @return
*/ */
@Override
public double[] getFastFilterCoefficients() { public double[] getFastFilterCoefficients() {
Complex[] poles = getPoles(filterParams); Complex[] poles = getPoles(filterParams);
Complex[] zeros = getZeros(filterParams); Complex[] zeros = getZeros(filterParams);

View File

@ -195,6 +195,7 @@ public class IirfFilter implements Filter {
/* (non-Javadoc) /* (non-Javadoc)
* @see Filters.Filter#runFilter(double[]) * @see Filters.Filter#runFilter(double[])
*/ */
@Override
synchronized public void runFilter(double[] inputData) { synchronized public void runFilter(double[] inputData) {
int f; int f;
for (int i = 0; i < inputData.length; i++) { for (int i = 0; i < inputData.length; i++) {
@ -208,6 +209,7 @@ public class IirfFilter implements Filter {
/* (non-Javadoc) /* (non-Javadoc)
* @see Filters.Filter#runFilter(double[], double[]) * @see Filters.Filter#runFilter(double[], double[])
*/ */
@Override
synchronized public void runFilter(double[] inputData, double[] outputData) { synchronized public void runFilter(double[] inputData, double[] outputData) {
int f; int f;
if (outputData == null || outputData.length != inputData.length) { if (outputData == null || outputData.length != inputData.length) {
@ -225,6 +227,7 @@ public class IirfFilter implements Filter {
/* (non-Javadoc) /* (non-Javadoc)
* @see Filters.Filter#runFilter(double) * @see Filters.Filter#runFilter(double)
*/ */
@Override
synchronized public double runFilter(double aData) { synchronized public double runFilter(double aData) {
double newData = aData; double newData = aData;
for (int f = 0; f < nFilterUnits; f++) { for (int f = 0; f < nFilterUnits; f++) {

View File

@ -52,14 +52,14 @@ public class FormatGpsData {
Date dateO; Date dateO;
FormatGpsData() { FormatGpsData() {
}; }
FormatGpsData(StringBuffer nmeaString) { FormatGpsData(StringBuffer nmeaString) {
/* /*
* Unpack the string buffer to populate the above datas * Unpack the string buffer to populate the above datas
*/ */
}; }
public static String formatTime(int intTime) { public static String formatTime(int intTime) {
SimpleDateFormat gpsTimeFormat = new SimpleDateFormat("HHmmss"); SimpleDateFormat gpsTimeFormat = new SimpleDateFormat("HHmmss");

View File

@ -9,11 +9,6 @@ import java.util.ListIterator;
import javax.swing.JMenu; import javax.swing.JMenu;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import warnings.PamWarning;
import warnings.WarningSystem;
import NMEA.NMEADataBlock; import NMEA.NMEADataBlock;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
@ -21,9 +16,10 @@ import PamController.PamController;
import PamController.PamSettingManager; import PamController.PamSettingManager;
import PamController.PamSettings; import PamController.PamSettings;
import PamController.positionreference.PositionReference; import PamController.positionreference.PositionReference;
import PamUtils.PamCalendar;
import PamView.dialog.warn.WarnOnce; import PamView.dialog.warn.WarnOnce;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import warnings.PamWarning;
import warnings.WarningSystem;
public class GPSControl extends PamControlledUnit implements PamSettings, PositionReference { public class GPSControl extends PamControlledUnit implements PamSettings, PositionReference {
@ -144,7 +140,9 @@ public class GPSControl extends PamControlledUnit implements PamSettings, Positi
@Override @Override
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
String currentPath; String currentPath;
ImportGPSParams newParams=ImportGPSDialog.showDialog(PamController.getInstance().getMainFrame(), PamController.getInstance().getMainFrame().getMousePosition(),gpsImportParams, importGPSData); PamController.getInstance();
PamController.getInstance();
ImportGPSParams newParams=ImportGPSDialog.showDialog(PamController.getMainFrame(), PamController.getMainFrame().getMousePosition(),gpsImportParams, importGPSData);
if (newParams!=null) gpsImportParams=newParams.clone(); if (newParams!=null) gpsImportParams=newParams.clone();
@ -168,6 +166,7 @@ public class GPSControl extends PamControlledUnit implements PamSettings, Positi
this.parentFrame = parentFrame; this.parentFrame = parentFrame;
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
GPSParameters newP = GPSParametersDialog.showDialog(parentFrame, gpsParameters); GPSParameters newP = GPSParametersDialog.showDialog(parentFrame, gpsParameters);
if (newP != null) { if (newP != null) {
@ -184,6 +183,7 @@ public class GPSControl extends PamControlledUnit implements PamSettings, Positi
this.parentFrame = parentFrame; this.parentFrame = parentFrame;
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String message = "<html>Clock management is now controlled from the \"File/Global time settings\" menu<p>" + String message = "<html>Clock management is now controlled from the \"File/Global time settings\" menu<p>" +
"The Global time settings do not require administrator privilidges<p><p>" + "The Global time settings do not require administrator privilidges<p><p>" +
@ -195,13 +195,16 @@ public class GPSControl extends PamControlledUnit implements PamSettings, Positi
} }
} }
} }
@Override
public Serializable getSettingsReference() { public Serializable getSettingsReference() {
return gpsParameters; return gpsParameters;
} }
@Override
public long getSettingsVersion() { public long getSettingsVersion() {
return GPSParameters.serialVersionUID; return GPSParameters.serialVersionUID;
} }
@Override
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) { public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
if (pamControlledUnitSettings.getUnitType().equals(this.getUnitType()) if (pamControlledUnitSettings.getUnitType().equals(this.getUnitType())
@ -260,7 +263,7 @@ public class GPSControl extends PamControlledUnit implements PamSettings, Positi
* @return interpolated gps position. * @return interpolated gps position.
*/ */
public GpsDataUnit getShipPosition(long timeMilliseconds, boolean interpolate) { public GpsDataUnit getShipPosition(long timeMilliseconds, boolean interpolate) {
if (interpolate == false) { if (!interpolate) {
return getGpsDataBlock().getClosestUnitMillis(timeMilliseconds); return getGpsDataBlock().getClosestUnitMillis(timeMilliseconds);
} }
// otherwise try to fine a point either side and weighted mean them or extrapolate. // otherwise try to fine a point either side and weighted mean them or extrapolate.

Some files were not shown because too many files have changed in this diff Show More