mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-21 14:42:27 +00:00
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:
parent
b9c613ea1b
commit
b420fd9f9d
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.pamguard</groupId>
|
||||
<artifactId>Pamguard</artifactId>
|
||||
<version>2.02.13</version>
|
||||
<version>2.02.13a</version>
|
||||
<name>Pamguard</name>
|
||||
<description>Pamguard using Maven to control dependencies</description>
|
||||
<url>www.pamguard.org</url>
|
||||
|
@ -13,7 +13,6 @@ import binaryFileStorage.BinaryHeader;
|
||||
import binaryFileStorage.BinaryObjectData;
|
||||
import binaryFileStorage.ModuleFooter;
|
||||
import binaryFileStorage.ModuleHeader;
|
||||
import binaryFileStorage.PackedBinaryObject;
|
||||
|
||||
public class AISBinaryDataSource extends BinaryDataSource {
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class AISBugSearch {
|
||||
// first comma separates date and NMEA data
|
||||
int chPos = line.indexOf(",");
|
||||
String nmeaData = line.substring(chPos+1);
|
||||
if (nmeaData.contains("AIVDM") == false) {
|
||||
if (!nmeaData.contains("AIVDM")) {
|
||||
continue;
|
||||
}
|
||||
System.out.println(nmeaData);
|
||||
|
@ -44,6 +44,7 @@ public class AISControl extends PamControlledUnit implements PamSettings {
|
||||
super();
|
||||
this.parentFrame = parentFrame;
|
||||
}
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
AISStringsTable.show(aisControl);
|
||||
}
|
||||
@ -55,6 +56,7 @@ public class AISControl extends PamControlledUnit implements PamSettings {
|
||||
super();
|
||||
this.parentFrame = parentFrame;
|
||||
}
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
AISParameters newParams = AISDisplayDialog.showDialog(parentFrame, aisParameters);
|
||||
@ -70,6 +72,7 @@ public class AISControl extends PamControlledUnit implements PamSettings {
|
||||
super();
|
||||
this.parentFrame = parentFrame;
|
||||
}
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
AISParameters newParams = AISSettingsDialog.showDialog(parentFrame, aisParameters);
|
||||
if (newParams != null) {
|
||||
@ -115,14 +118,17 @@ public class AISControl extends PamControlledUnit implements PamSettings {
|
||||
aisProcess.noteNewSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getSettingsReference() {
|
||||
return aisParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSettingsVersion() {
|
||||
return AISParameters.serialVersionUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
|
||||
|
||||
this.aisParameters = ((AISParameters) pamControlledUnitSettings.getSettings()).clone();
|
||||
|
@ -1,18 +1,16 @@
|
||||
package AIS;
|
||||
|
||||
import generalDatabase.DBControlUnit;
|
||||
import generalDatabase.SQLTypes;
|
||||
|
||||
import java.util.ListIterator;
|
||||
|
||||
import pamScrollSystem.ViewLoadObserver;
|
||||
import nmeaEmulator.EmulatedData;
|
||||
import nmeaEmulator.NMEAEmulator;
|
||||
import NMEA.AcquireNmeaData;
|
||||
import PamController.masterReference.MasterReferencePoint;
|
||||
import PamUtils.LatLong;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamProcess;
|
||||
import generalDatabase.DBControlUnit;
|
||||
import generalDatabase.SQLTypes;
|
||||
import nmeaEmulator.EmulatedData;
|
||||
import nmeaEmulator.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) {
|
||||
if (aisControl.aisParameters.limitRange == false) {
|
||||
if (!aisControl.aisParameters.limitRange) {
|
||||
return true;
|
||||
}
|
||||
double range = 0;
|
||||
@ -133,7 +131,7 @@ public class AISDataBlock extends PamDataBlock<AISDataUnit> implements NMEAEmula
|
||||
@Override
|
||||
public EmulatedData getNextData() {
|
||||
SQLTypes sqlTypes = DBControlUnit.findConnection().getSqlTypes();
|
||||
if (getLogging().readNextEmulation(sqlTypes) == false) {
|
||||
if (!getLogging().readNextEmulation(sqlTypes)) {
|
||||
return null;
|
||||
}
|
||||
// now all data should be in the loggers table definition.
|
||||
|
@ -5,7 +5,6 @@ import java.util.ArrayList;
|
||||
|
||||
import NMEA.NMEABitArray;
|
||||
import NMEA.NMEADataBlock;
|
||||
import PamDetection.AbstractLocalisation;
|
||||
import PamDetection.LocContents;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
|
@ -7,8 +7,6 @@ import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import radardisplay.RadarProjector;
|
||||
|
||||
import GPS.GpsData;
|
||||
import GPS.GpsDataUnit;
|
||||
import Map.MapRectProjector;
|
||||
@ -20,14 +18,14 @@ import PamUtils.Coordinate3d;
|
||||
import PamUtils.LatLong;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamView.GeneralProjector;
|
||||
import PamView.GeneralProjector.ParameterType;
|
||||
import PamView.PamDetectionOverlayGraphics;
|
||||
import PamView.PamKeyItem;
|
||||
import PamView.PamSymbol;
|
||||
import PamView.PamSymbolType;
|
||||
import PamView.GeneralProjector.ParameterType;
|
||||
import PamView.symbol.SymbolData;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import PamguardMVC.debug.Debug;
|
||||
import radardisplay.RadarProjector;
|
||||
|
||||
|
||||
public class AISGraphics extends PamDetectionOverlayGraphics {
|
||||
@ -73,12 +71,12 @@ public class AISGraphics extends PamDetectionOverlayGraphics {
|
||||
AISStaticData staticData = aisDataUnit.getStaticData();
|
||||
AISPositionReport positionReport = aisDataUnit.getPositionReport();
|
||||
|
||||
if (aisDataUnit.isComplete() == false) {
|
||||
if (!aisDataUnit.isComplete()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
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 range = localisation.getRange(0);
|
||||
Coordinate3d c3d = generalProjector.getCoord3d(bearing, range, 0);
|
||||
|
@ -1,22 +1,19 @@
|
||||
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.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Types;
|
||||
|
||||
import javax.naming.ldap.HasControls;
|
||||
|
||||
import PamController.PamController;
|
||||
import PamView.dialog.warn.WarnOnce;
|
||||
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 {
|
||||
|
||||
@ -167,7 +164,7 @@ public class AISLogger extends SQLLogging {
|
||||
acallSign = (String) callSign.getValue();
|
||||
ashipName = (String) shipName.getValue();
|
||||
ashipType = (String) shipType.getValue();
|
||||
aetaMillis = sqlTypes.millisFromTimeStamp(eta.getValue());
|
||||
aetaMillis = SQLTypes.millisFromTimeStamp(eta.getValue());
|
||||
// aetaMillis = (Long) eta.getValue();
|
||||
adraught = (Double) draft.getValue();
|
||||
adestination = (String) destination.getValue();
|
||||
|
@ -199,7 +199,7 @@ public class AISStaticData extends AISReport implements Serializable, ManagedPar
|
||||
}
|
||||
switch(stationType) {
|
||||
case BASESTATION:
|
||||
return stationType.BASESTATION.toString();
|
||||
return StationType.BASESTATION.toString();
|
||||
case A:
|
||||
case B:
|
||||
return getVesselTypeAndCargo(type);
|
||||
|
@ -109,12 +109,13 @@ public class AISStringsTable {
|
||||
|
||||
class TimerListener implements ActionListener {
|
||||
boolean doneLayout;
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ev) {
|
||||
// table.
|
||||
// nmeaTableData.fireTableRowsUpdated(0, 10);
|
||||
aisTableData.fireTableDataChanged();
|
||||
|
||||
if (doneLayout == false && aisTableData.getRowCount() > 0) {
|
||||
if (!doneLayout && aisTableData.getRowCount() > 0) {
|
||||
doneLayout = true;
|
||||
}
|
||||
}
|
||||
@ -134,6 +135,7 @@ public class AISStringsTable {
|
||||
/* (non-Javadoc)
|
||||
* @see javax.swing.table.TableModel#getColumnCount()
|
||||
*/
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return tableColumns.length;
|
||||
}
|
||||
@ -141,6 +143,7 @@ public class AISStringsTable {
|
||||
/* (non-Javadoc)
|
||||
* @see javax.swing.table.TableModel#getRowCount()
|
||||
*/
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
if (aisDataBlock == null) return 0;
|
||||
//System.out.println(aisDataBlock.getUnitsCount() + " rows in AIS data");
|
||||
@ -150,6 +153,7 @@ public class AISStringsTable {
|
||||
/* (non-Javadoc)
|
||||
* @see javax.swing.table.TableModel#getValueAt(int, int)
|
||||
*/
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
AISDataUnit aisDataUnit = aisDataBlock.getDataUnit(rowIndex, PamDataBlock.REFERENCE_CURRENT);
|
||||
|
||||
|
@ -3,7 +3,6 @@ package AIS;
|
||||
import NMEA.NMEADataBlock;
|
||||
import NMEA.NMEADataUnit;
|
||||
import PamController.PamController;
|
||||
import PamDetection.AbstractLocalisation;
|
||||
import PamDetection.LocContents;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamView.symbol.StandardSymbolManager;
|
||||
@ -11,7 +10,6 @@ import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import PamguardMVC.PamObservable;
|
||||
import PamguardMVC.PamProcess;
|
||||
import autecPhones.AutecGraphics;
|
||||
|
||||
/**
|
||||
* Process NMEA data to extract AIS information
|
||||
|
@ -2,7 +2,7 @@ package Acquisition;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
@ -12,7 +12,7 @@ public class AcquisitionCParameters {
|
||||
public static final int SOUNDCARD = 1;
|
||||
public static final int WAVFILE = 2;
|
||||
public static final int DAQCARD = 3;
|
||||
|
||||
|
||||
public int deviceType;
|
||||
public int deviceNumber;
|
||||
public int sampleRate;
|
||||
@ -23,7 +23,7 @@ public class AcquisitionCParameters {
|
||||
public String spareString2 = null;
|
||||
public int[] channelList = new int[MAXCHAN];
|
||||
public String soundFile;
|
||||
|
||||
|
||||
public int setDaqType(String daqType) {
|
||||
deviceType = -1;
|
||||
if (daqType.equalsIgnoreCase("Sound Card")) {
|
||||
@ -37,5 +37,5 @@ public class AcquisitionCParameters {
|
||||
}
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
/* 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).
|
||||
*
|
||||
* Copyright (C) 2006
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2006
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 3
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
@ -21,10 +21,6 @@
|
||||
|
||||
package Acquisition;
|
||||
|
||||
import hfDaqCard.SmruDaqSystem;
|
||||
//import mcc.mccacquisition.MCCDaqSystem;
|
||||
import mcc.mccacquisition.MCCDaqSystem;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Window;
|
||||
@ -38,20 +34,6 @@ import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
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.StandardFileDate;
|
||||
import Acquisition.filetypes.SoundFileTypes;
|
||||
@ -74,8 +56,6 @@ import PamController.PamGUIManager;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
import PamController.RawInputControlledUnit;
|
||||
import PamController.fileprocessing.StoreStatus;
|
||||
import PamModel.PamModel;
|
||||
import PamModel.SMRUEnable;
|
||||
import PamUtils.FrequencyFormat;
|
||||
import PamUtils.PamCalendar;
|
||||
@ -91,6 +71,20 @@ import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamProcess;
|
||||
import PamguardMVC.PamRawDataBlock;
|
||||
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,
|
||||
@ -98,9 +92,9 @@ import PamguardMVC.dataOffline.OfflineDataLoadInfo;
|
||||
* <p>
|
||||
* Uses a plug in architecture to allow new types to be added. This
|
||||
* is done through RegisterDaqType().
|
||||
*
|
||||
*
|
||||
* @author Doug Gillespie
|
||||
*
|
||||
*
|
||||
* @see Acquisition.DaqSystem
|
||||
*
|
||||
*/
|
||||
@ -133,26 +127,26 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
protected FolderInputSystem folderSystem;
|
||||
|
||||
private DCL5System dclSystem;
|
||||
|
||||
|
||||
protected FileDate fileDate;
|
||||
|
||||
|
||||
/**
|
||||
* The JavaFX GUI for the sound acquisition module.
|
||||
* The JavaFX GUI for the sound acquisition module.
|
||||
*/
|
||||
private AquisitionGUIFX aquisitionGUIFX;
|
||||
|
||||
|
||||
private SUDNotificationManager sudNotificationManager;
|
||||
|
||||
|
||||
protected SoundFileTypes soundFileTypes;
|
||||
|
||||
|
||||
/**
|
||||
* Main control unit for audio data acquisition.
|
||||
* <p>
|
||||
* It is possible to instantiate several instances of this, preferably
|
||||
* 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>
|
||||
* Each different acquisition device must implement the DaqSystem interface
|
||||
* Each different acquisition device must implement the DaqSystem interface
|
||||
* and register with each AcquisitionControl.
|
||||
* @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
|
||||
@ -164,13 +158,13 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
super(unitType, name);
|
||||
|
||||
acquisitionControl = this;
|
||||
|
||||
|
||||
fileDate = new StandardFileDate(this);
|
||||
|
||||
pamController = PamController.getInstance();
|
||||
|
||||
|
||||
soundFileTypes = new SoundFileTypes(this);
|
||||
|
||||
|
||||
registerDaqSystem(new SoundCardSystem(this));
|
||||
if (PlatformInfo.calculateOS() == OSType.WINDOWS) {
|
||||
long tic = System.currentTimeMillis();
|
||||
@ -178,13 +172,13 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
registerDaqSystem(new ASIOSoundSystem(this));
|
||||
toc = System.currentTimeMillis();
|
||||
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();
|
||||
registerDaqSystem(new NewAsioSoundSystem(this));
|
||||
toc = System.currentTimeMillis();
|
||||
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));
|
||||
@ -200,7 +194,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
registerDaqSystem(new MCCDaqSystem(this));
|
||||
// registerDaqSystem(new RonaInputSystem(this));
|
||||
}
|
||||
|
||||
|
||||
// load the DAQ Systems found in the plugins folder
|
||||
loadExternalDaqSystems();
|
||||
|
||||
@ -231,7 +225,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
}
|
||||
}
|
||||
setSelectedSystem();
|
||||
|
||||
|
||||
TDDataProviderRegisterFX.getInstance().registerDataInfo(new RawSoundProviderFX(this));
|
||||
|
||||
}
|
||||
@ -242,22 +236,22 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
acquisitionControl = this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Overloaded constructor - used by the STAcquisitionControl class as a way to call
|
||||
* the PamController.PamControlledUnit constructor without all of the AcquisitionControl
|
||||
* code above
|
||||
*
|
||||
*
|
||||
* @param type the type of unit
|
||||
* @param name the name of the unit
|
||||
*/
|
||||
public AcquisitionControl(String type, String name) {
|
||||
super(type, name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private PamPanel systemPanel;
|
||||
|
||||
|
||||
protected Component getStatusBarComponent() {
|
||||
PamPanel p = new PamPanel();
|
||||
p.add(statusBarText = new PamLabel());
|
||||
@ -275,7 +269,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
*/
|
||||
public void registerDaqSystem(DaqSystem daqSystem){
|
||||
if (systemList == null) {
|
||||
systemList = new ArrayList<DaqSystem>();
|
||||
systemList = new ArrayList<>();
|
||||
}
|
||||
systemList.add(daqSystem);
|
||||
//daqSystem.getItemsList();
|
||||
@ -283,7 +277,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
}
|
||||
|
||||
public static ArrayList<AcquisitionControl> getControllers() {
|
||||
ArrayList<AcquisitionControl> daqControllers = new ArrayList<AcquisitionControl>();
|
||||
ArrayList<AcquisitionControl> daqControllers = new ArrayList<>();
|
||||
PamControlledUnit pcu;
|
||||
for (int i = 0; i < PamController.getInstance().getNumControlledUnits(); 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.
|
||||
* @param systemType
|
||||
* @return reference to a DaqSystem object
|
||||
* @return reference to a DaqSystem object
|
||||
*/
|
||||
public DaqSystem findDaqSystem(String systemType) {
|
||||
|
||||
@ -323,8 +317,8 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
|
||||
if (systemType == null) systemType = acquisitionParameters.daqSystemType;
|
||||
|
||||
for (int i = 0; i < systemList.size(); i++) {
|
||||
if (systemList.get(i).getSystemType().equals(systemType)) return systemList.get(i);
|
||||
for (DaqSystem element : systemList) {
|
||||
if (element.getSystemType().equals(systemType)) return element;
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -347,6 +341,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
this.parentFrame = parentFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
AcquisitionParameters newParameters = AcquisitionDialog.showDialog(parentFrame, acquisitionControl, acquisitionParameters);
|
||||
if (newParameters != null) {
|
||||
@ -378,28 +373,28 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
}
|
||||
lastSelSystem = selSystem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check array channels have corresponding hydrophones in the array manager. Does
|
||||
* not open a dialog to warn or fix.
|
||||
* @return check array channel. False if array manager
|
||||
* Check array channels have corresponding hydrophones in the array manager. Does
|
||||
* not open a dialog to warn or fix.
|
||||
* @return check array channel. False if array manager
|
||||
*/
|
||||
public boolean checkArrayChannels() {
|
||||
int error = arrayChannelsOK();
|
||||
if (error == ARRAY_ERROR_OK) {
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run a check to see that all read out channels are connected to
|
||||
* a hydrophone and if not, do something about it.
|
||||
* @return true if OK, or problem resolved.
|
||||
* Run a check to see that all read out channels are connected to
|
||||
* a hydrophone and if not, do something about it.
|
||||
* @return true if OK, or problem resolved.
|
||||
*/
|
||||
public boolean checkArrayChannels(Frame parentFrame) {
|
||||
public boolean checkArrayChannels(Frame parentFrame) {
|
||||
|
||||
int error = arrayChannelsOK();
|
||||
if (error == ARRAY_ERROR_OK) {
|
||||
@ -526,14 +521,17 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
* (non-Javadoc)
|
||||
* @see PamController.PamSettings#GetSettingsReference()
|
||||
*/
|
||||
@Override
|
||||
public Serializable getSettingsReference() {
|
||||
return acquisitionParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSettingsVersion() {
|
||||
return AcquisitionParameters.serialVersionUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restoreSettings(PamControlledUnitSettings 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
|
||||
public int ChannelsToHydrophones(int channels) {
|
||||
int[] hydrophoneList = getHydrophoneList();
|
||||
if (hydrophoneList == null) return channels; // they are the same by default
|
||||
//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.
|
||||
if (acquisitionParameters.nChannels==0) return channels;
|
||||
|
||||
// they are the same by default
|
||||
//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.
|
||||
if ((hydrophoneList == null) || (acquisitionParameters.nChannels==0)) return channels;
|
||||
|
||||
int hydrophones = 0;
|
||||
int channelListIndex;
|
||||
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
|
||||
* the currentarray.
|
||||
* Return a list of which channels are connected to which hydrophones in
|
||||
* the currentarray.
|
||||
* @return List of hydrophone numbers.
|
||||
*/
|
||||
public int[] getHydrophoneList() {
|
||||
@ -601,15 +599,15 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
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
|
||||
*
|
||||
*
|
||||
* @param hydrophoneId Number of a hydrophone in a PamArray
|
||||
* @return the ADC channel for the given hydrophone
|
||||
*/
|
||||
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
|
||||
// if no list, assume 1-1 mapping
|
||||
int channelList[] = acquisitionControl.acquisitionParameters.getHardwareChannelList();
|
||||
@ -664,7 +662,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
|
||||
/**
|
||||
* Getter for acquisition parameters.
|
||||
* @return data acquisition parameters.
|
||||
* @return data acquisition parameters.
|
||||
*/
|
||||
public AcquisitionParameters getAcquisitionParameters() {
|
||||
return acquisitionParameters;
|
||||
@ -679,6 +677,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
/**
|
||||
* @return the offlineFileServer
|
||||
*/
|
||||
@Override
|
||||
public OfflineFileServer getOfflineFileServer() {
|
||||
return offlineFileServer;
|
||||
}
|
||||
@ -759,15 +758,15 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
public FileDate getFileDate() {
|
||||
return fileDate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load any classes that were found in the plugins folder and implement the DaqSystemInterface interface
|
||||
*/
|
||||
public void loadExternalDaqSystems() {
|
||||
|
||||
// get a list of plugins
|
||||
List<DaqSystemInterface> daqList = ((PamModel) PamController.getInstance().getModelInterface()).getDaqList();
|
||||
|
||||
|
||||
// get a list of plugins
|
||||
List<DaqSystemInterface> daqList = PamController.getInstance().getModelInterface().getDaqList();
|
||||
|
||||
// if there are no plugins, return
|
||||
if (daqList.isEmpty()) {
|
||||
return;
|
||||
@ -776,7 +775,7 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
registerDaqSystem(dsi.createDAQControl(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the available DAQ systems
|
||||
* @return
|
||||
@ -784,16 +783,16 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
public ArrayList<DaqSystem> getSystemList() {
|
||||
return this.systemList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the acquisition parameters.
|
||||
* @param params - the acquisition params to set.
|
||||
* Set the acquisition parameters.
|
||||
* @param params - the acquisition params to set.
|
||||
*/
|
||||
public void setAquisitionParams(AcquisitionParameters params) {
|
||||
this.acquisitionParameters=params;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PamControlledUnitGUI getGUI(int flag) {
|
||||
if (flag==PamGUIManager.FX) {
|
||||
@ -805,18 +804,18 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
//TODO swing
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a summary of the daq settings for the QA module.
|
||||
* @return summary of DAQ settings.
|
||||
* Get a summary of the daq settings for the QA module.
|
||||
* @return summary of DAQ settings.
|
||||
*/
|
||||
public String getDaqSummary() {
|
||||
DaqSystem daqSys = findDaqSystem(null);
|
||||
if (daqSys == null) {
|
||||
return String.format("%s - currently unavailable", acquisitionParameters.daqSystemType);
|
||||
}
|
||||
String str = String.format("%s - %s, %3.1fVp-p",
|
||||
acquisitionParameters.daqSystemType, daqSys.getDeviceName(),
|
||||
String str = String.format("%s - %s, %3.1fVp-p",
|
||||
acquisitionParameters.daqSystemType, daqSys.getDeviceName(),
|
||||
acquisitionParameters.voltsPeak2Peak);
|
||||
Preamplifier preamp = acquisitionParameters.getPreamplifier();
|
||||
if (preamp != null) {
|
||||
@ -825,11 +824,11 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
str += ", Sample Rate " + FrequencyFormat.formatFrequency(acquisitionParameters.sampleRate, true);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String tellModule(String command) {
|
||||
/**
|
||||
* Get timing summary and return as a string.
|
||||
* Get timing summary and return as a string.
|
||||
*/
|
||||
switch (command) {
|
||||
case "gettimeinfo":
|
||||
@ -837,35 +836,35 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
}
|
||||
return super.tellModule(command);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get a summary of time information as to what's going on in the DAQ
|
||||
* @return time summary
|
||||
*/
|
||||
private String getTimeInfoString() {
|
||||
/*
|
||||
*
|
||||
*
|
||||
sprintf(returned,"%s:%lld,%lld,%ld,%lld",getModuleName(),calendar->getRawStartTime(),
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void pamHasStopped() {
|
||||
acquisitionProcess.pamHasStopped();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModuleSummary(boolean clear) {
|
||||
return getDaqProcess().getRawDataBlock().getSummaryString(clear);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the SUD processing notification manager.
|
||||
* @return SUD processing notification manager.
|
||||
* Get the SUD processing notification manager.
|
||||
* @return SUD processing notification manager.
|
||||
*/
|
||||
public SUDNotificationManager getSUDNotificationManager() {
|
||||
if (sudNotificationManager == null) {
|
||||
@ -873,8 +872,8 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
}
|
||||
return sudNotificationManager;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getRawInputType() {
|
||||
DaqSystem system = acquisitionProcess.getRunningSystem();
|
||||
@ -889,17 +888,18 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
public InputStoreInfo getStoreInfo(boolean detail) {
|
||||
return getDaqProcess().getStoreInfo(detail);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean setAnalysisStartTime(long startTime) {
|
||||
return getDaqProcess().setAnalysisStartTime(startTime);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Very specific command handler for batch status which will only work
|
||||
* with the folderinputSystem.
|
||||
* Very specific command handler for batch status which will only work
|
||||
* with the folderinputSystem.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getBatchStatus() {
|
||||
DaqSystem runningSystem = getAcquisitionProcess().getRunningSystem();
|
||||
if (runningSystem instanceof FolderInputSystem) {
|
||||
@ -909,5 +909,5 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -30,87 +30,87 @@ import dataMap.filemaps.OfflineFileDialogPanel;
|
||||
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
|
||||
* necessary.
|
||||
*
|
||||
* necessary.
|
||||
*
|
||||
* @author Doug Gillespie
|
||||
*
|
||||
*/
|
||||
public class AcquisitionDialog extends PamDialog {
|
||||
|
||||
private static AcquisitionParameters acquisitionParameters;
|
||||
|
||||
|
||||
private static AcquisitionDialog singleInstance;
|
||||
|
||||
|
||||
private static AcquisitionControl acquisitionControl;
|
||||
|
||||
|
||||
private OfflineFileDialogPanel offlineDAQDialogPanel;
|
||||
|
||||
|
||||
private PPSDialogPanel ppsDialogPanel;
|
||||
|
||||
private DaqSystem currentDaqSystem;
|
||||
|
||||
|
||||
private JComboBox deviceType;
|
||||
|
||||
|
||||
private JPanel mainPanel;
|
||||
|
||||
|
||||
private JComponent deviceSpecificPanel;
|
||||
|
||||
|
||||
private JTextField sampleRate, nChannels, vPeak2Peak;
|
||||
|
||||
private JTextField preampGain;
|
||||
|
||||
private JTextField preampGain;
|
||||
// bandwidth0, bandwidth1;
|
||||
private JCheckBox subtractDC;
|
||||
|
||||
|
||||
private JTextField dcTimeconstant;
|
||||
|
||||
|
||||
// public int channelList[] = new int[PamConstants.MAX_CHANNELS];
|
||||
//
|
||||
// private JLabel panelChannelLabel[] = new JLabel[PamConstants.MAX_CHANNELS];
|
||||
// private JComboBox panelChannelList[] = new JComboBox[PamConstants.MAX_CHANNELS];
|
||||
|
||||
|
||||
private ChannelListPanel standardChannelListPanel = new StandardChannelListPanel();
|
||||
private ChannelListPanel currentChannelListPanel;
|
||||
private JPanel channelListPanelArea = new JPanel();
|
||||
//private static AcquisitionParameters acquisitionParameters; //Xiao Yan Deng
|
||||
|
||||
|
||||
/**
|
||||
* Main dialog for data acquisition control
|
||||
* <p>
|
||||
* When shown, the dialog contains three main panels.
|
||||
* <p>The top one shows
|
||||
* a list of available DaqSystems (e.g. sound cards, NI cards, etc.
|
||||
* Main dialog for data acquisition control
|
||||
* <p>
|
||||
* When shown, the dialog contains three main panels.
|
||||
* <p>The top one shows
|
||||
* a list of available DaqSystems (e.g. sound cards, NI cards, etc.
|
||||
* >p>
|
||||
* 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
|
||||
* 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
|
||||
* specific for a particular device.
|
||||
* specific for a particular device.
|
||||
* <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
|
||||
* 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
|
||||
* setVPeak2Peak
|
||||
* setVPeak2Peak
|
||||
*
|
||||
*/
|
||||
private AcquisitionDialog (Frame parentFrame) {
|
||||
|
||||
super(parentFrame, "Audio Data Acquisition", false);
|
||||
|
||||
|
||||
|
||||
mainPanel = new JPanel();
|
||||
|
||||
|
||||
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
|
||||
mainPanel.add(DeviceTypePanel());
|
||||
mainPanel.add(SamplingPanel());
|
||||
mainPanel.add(CalibrationPanel());
|
||||
|
||||
nChannels.addActionListener(new NumChannels());
|
||||
|
||||
nChannels.addActionListener(new NumChannels());
|
||||
|
||||
setHelpPoint("sound_processing.AcquisitionHelp.docs.AcquisitionConfiguration");
|
||||
|
||||
|
||||
if (PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW) {
|
||||
JTabbedPane tabbedPane = new JTabbedPane();
|
||||
offlineDAQDialogPanel = new OfflineFileDialogPanel(acquisitionControl, this);
|
||||
@ -131,45 +131,45 @@ public class AcquisitionDialog extends PamDialog {
|
||||
setParams(); //Xiao Yan Deng
|
||||
sortChannelLists(); // Xiao Yan Deng
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the static instance so that the dialog is
|
||||
* totally rebuilt next time it's launched.
|
||||
* Clear the static instance so that the dialog is
|
||||
* totally rebuilt next time it's launched.
|
||||
*/
|
||||
static public void clearInstance() {
|
||||
singleInstance = null;
|
||||
}
|
||||
/**
|
||||
* Shows the data acquisition dialog.
|
||||
* Shows the data acquisition dialog.
|
||||
* @param daqControl the calling AcquisitionControl
|
||||
* @param oldParams current parameters from the AcquisitionControl
|
||||
* @return new parameters selected in the dialog
|
||||
* @see AcquisitionControl
|
||||
*/
|
||||
static public AcquisitionParameters showDialog(Frame parentFrame, AcquisitionControl daqControl, AcquisitionParameters oldParams) {
|
||||
|
||||
|
||||
acquisitionParameters = oldParams.clone();
|
||||
|
||||
|
||||
acquisitionControl = daqControl;
|
||||
// singleInstance = null;
|
||||
|
||||
|
||||
if (singleInstance == null || singleInstance.getOwner() != parentFrame) {
|
||||
singleInstance = new AcquisitionDialog(parentFrame);
|
||||
}
|
||||
|
||||
|
||||
singleInstance.setParams();
|
||||
|
||||
|
||||
singleInstance.sortChannelLists();
|
||||
|
||||
|
||||
singleInstance.setVisible(true);
|
||||
|
||||
|
||||
singleInstance.sortChannelLists(); // Xiao Yan Deng
|
||||
|
||||
|
||||
return acquisitionParameters;
|
||||
}
|
||||
|
||||
|
||||
private void setParams() {
|
||||
|
||||
|
||||
// fill in the different device types.
|
||||
deviceType.removeAllItems();
|
||||
int ind = 0;
|
||||
@ -180,23 +180,23 @@ public class AcquisitionDialog extends PamDialog {
|
||||
}
|
||||
}
|
||||
deviceType.setSelectedIndex(ind);
|
||||
|
||||
|
||||
newDeviceType();
|
||||
|
||||
|
||||
setSampleRate(acquisitionParameters.sampleRate);
|
||||
|
||||
|
||||
setChannels(acquisitionParameters.nChannels);
|
||||
|
||||
|
||||
setVPeak2Peak(acquisitionParameters.voltsPeak2Peak);
|
||||
|
||||
|
||||
// preampGain.setText(String.format("%.1f", acquisitionParameters.preamplifier.getGain()));
|
||||
setPreampGain(acquisitionParameters.preamplifier.getGain());
|
||||
// bandwidth0.setText(String.format("%.1f", acquisitionParameters.preamplifier.getBandwidth()[0]));
|
||||
// bandwidth1.setText(String.format("%.1f", acquisitionParameters.preamplifier.getBandwidth()[1]));
|
||||
subtractDC.setSelected(acquisitionParameters.subtractDC);
|
||||
dcTimeconstant.setText(String.format("%3.1f", acquisitionParameters.dcTimeConstant));
|
||||
|
||||
|
||||
|
||||
|
||||
if (currentDaqSystem != null) currentDaqSystem.dialogSetParams();
|
||||
|
||||
if (currentChannelListPanel != null) {
|
||||
@ -206,24 +206,24 @@ public class AcquisitionDialog extends PamDialog {
|
||||
if (offlineDAQDialogPanel != null) {
|
||||
offlineDAQDialogPanel.setParams();
|
||||
}
|
||||
|
||||
|
||||
if (ppsDialogPanel != null) {
|
||||
ppsDialogPanel.setParams(acquisitionParameters.getPpsParameters());
|
||||
}
|
||||
|
||||
|
||||
enableControls();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* sample rate of data in the current file.
|
||||
* the DaqSystem (for instance FileInputSystem will set sample rate to the
|
||||
* sample rate of data in the current file.
|
||||
* @param sampleRate Current sample rate
|
||||
*/
|
||||
public void setSampleRate(float sampleRate) {
|
||||
this.sampleRate.setText(String.format("%.0f", sampleRate));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the sample rate, or null if sample rate is not a valid number
|
||||
* @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
|
||||
* the DaqSystem (for instance FileInputSystem will set it to the
|
||||
* number of channels in the current file.
|
||||
* the DaqSystem (for instance FileInputSystem will set it to the
|
||||
* number of channels in the current file.
|
||||
* @param nChannels Number of channels
|
||||
*/
|
||||
public void setChannels(int nChannels) {
|
||||
this.nChannels.setText(String.format("%d", nChannels));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @return the number of channels or null if invalid number
|
||||
*/
|
||||
public Integer getChannels() {
|
||||
@ -258,7 +258,7 @@ public class AcquisitionDialog extends PamDialog {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setPreampGain(double 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.
|
||||
* This is used for calculating absolute SPL's in various detectors
|
||||
* the DaqSystem
|
||||
* the DaqSystem
|
||||
* @param vPeak2Peak Peak to Peak input voltage
|
||||
*/
|
||||
public void setVPeak2Peak(double vPeak2Peak) {
|
||||
this.vPeak2Peak.setText(String.format("%4.3f", vPeak2Peak));
|
||||
}
|
||||
|
||||
|
||||
// read parameters back from the dialog
|
||||
@Override
|
||||
public boolean getParams() {
|
||||
@ -287,15 +287,15 @@ public class AcquisitionDialog extends PamDialog {
|
||||
// bw[0] = Double.valueOf(bandwidth0.getText());
|
||||
// bw[1] = Double.valueOf(bandwidth1.getText());
|
||||
// acquisitionParameters.preamplifier.setBandwidth(bw);
|
||||
|
||||
if(!currentDaqSystem.areSampleSettingsOk(acquisitionParameters.nChannels, acquisitionParameters.sampleRate)){
|
||||
|
||||
if(!currentDaqSystem.areSampleSettingsOk(acquisitionParameters.nChannels, acquisitionParameters.sampleRate)){
|
||||
currentDaqSystem.showSampleSettingsDialog(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int nP = getNumChannels();
|
||||
if (getCurrentDaqSystem().supportsChannelLists() && currentChannelListPanel != null) {
|
||||
if (currentChannelListPanel.isDataOk() == false) {
|
||||
if (!currentChannelListPanel.isDataOk()) {
|
||||
return false;
|
||||
}
|
||||
int[] chL = currentChannelListPanel.getChannelList();
|
||||
@ -312,7 +312,7 @@ public class AcquisitionDialog extends PamDialog {
|
||||
Ex.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
acquisitionParameters.subtractDC = subtractDC.isSelected();
|
||||
if (acquisitionParameters.subtractDC) {
|
||||
try {
|
||||
@ -325,8 +325,8 @@ public class AcquisitionDialog extends PamDialog {
|
||||
return showWarning("The DC bacround subtractino time constant must be greater than zero");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (offlineDAQDialogPanel != null) {
|
||||
OfflineFileParameters ofp = offlineDAQDialogPanel.getParams();
|
||||
if (ofp == null) {
|
||||
@ -346,13 +346,13 @@ public class AcquisitionDialog extends PamDialog {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the latest sample rate value.
|
||||
* @return sample rate Hz.
|
||||
|
||||
/**
|
||||
* Read the latest sample rate value.
|
||||
* @return sample rate Hz.
|
||||
*/
|
||||
public double readSampleRate() {
|
||||
double sr = 0;
|
||||
@ -365,22 +365,24 @@ public class AcquisitionDialog extends PamDialog {
|
||||
return sr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void cancelButtonPressed() {
|
||||
acquisitionParameters = null;
|
||||
}
|
||||
@Override
|
||||
public void restoreDefaultSettings() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private class NewDeviceType implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
newDeviceType();
|
||||
}
|
||||
}
|
||||
private class NumChannels implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
sortChannelLists();
|
||||
}
|
||||
@ -395,7 +397,7 @@ public class AcquisitionDialog extends PamDialog {
|
||||
deviceType.addActionListener(new NewDeviceType());
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Only need to show the channel panel for certain device types,
|
||||
*
|
||||
@ -415,20 +417,20 @@ public class AcquisitionDialog extends PamDialog {
|
||||
channelListPanelArea.add(standardChannelListPanel.getComponent());
|
||||
// channelListPanel.setVisible(currentSystem.supportsChannelLists());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private JPanel SamplingPanel () {
|
||||
|
||||
|
||||
JPanel sP = new PamAlignmentPanel(new BorderLayout(), BorderLayout.WEST);
|
||||
|
||||
|
||||
JPanel p = new JPanel();
|
||||
sP.setBorder(new TitledBorder("Sampling"));
|
||||
GridBagLayout layout;
|
||||
|
||||
|
||||
p.setLayout(layout = new GridBagLayout());
|
||||
GridBagConstraints constraints = new PamGridBagContraints();
|
||||
|
||||
|
||||
constraints.anchor = GridBagConstraints.EAST;
|
||||
constraints.insets = new Insets(2,2,2,2);
|
||||
constraints.fill = GridBagConstraints.NONE;
|
||||
@ -450,31 +452,31 @@ public class AcquisitionDialog extends PamDialog {
|
||||
constraints.gridx ++;
|
||||
constraints.gridwidth = 2;
|
||||
addComponent(p, new JLabel(" (hit enter)"), constraints);
|
||||
|
||||
|
||||
sP.add(BorderLayout.NORTH, p);
|
||||
|
||||
|
||||
// constraints.gridy++;
|
||||
// constraints.gridx = 0;
|
||||
// constraints.gridwidth = 4;
|
||||
standardChannelListPanel = new StandardChannelListPanel();
|
||||
// addComponent(p, channelListPanel, constraints);
|
||||
|
||||
|
||||
constraints.insets = new Insets(2,2,2,2);
|
||||
|
||||
|
||||
|
||||
|
||||
sP.add(BorderLayout.CENTER, channelListPanelArea);
|
||||
|
||||
|
||||
return sP;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
// private JPanel createStandardChannelListPanel() {
|
||||
//
|
||||
// /* code for select channel */
|
||||
// /*
|
||||
// * put this in a separate panel so it can be hidden if
|
||||
// * it's not possible to change these parameters.
|
||||
// *
|
||||
// * put this in a separate panel so it can be hidden if
|
||||
// * it's not possible to change these parameters.
|
||||
// *
|
||||
// * Text information updated DG & JG 12/8/08
|
||||
// */
|
||||
// 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>";
|
||||
// for (int i = 0; i < PamConstants.MAX_CHANNELS; i++){ //Xiao Yan Deng
|
||||
// //for (int i = 0; i < getNumChannels(); i++){
|
||||
//
|
||||
//
|
||||
// if (i%2 ==0){
|
||||
// c2.gridx = 0;
|
||||
// c2.gridy ++;
|
||||
@ -509,28 +511,28 @@ public class AcquisitionDialog extends PamDialog {
|
||||
// else {
|
||||
// spaceStr = "";
|
||||
// }
|
||||
// addComponent(cP, panelChannelLabel[i] =
|
||||
// addComponent(cP, panelChannelLabel[i] =
|
||||
// new JLabel(spaceStr + " SW Ch " + i + " = HW Ch "), c2);
|
||||
// c2.gridx ++;
|
||||
// //constraints.gridwidth = 2;
|
||||
// addComponent(cP, panelChannelList[i] = new JComboBox(), c2);
|
||||
// panelChannelLabel[i].setToolTipText(s);
|
||||
// panelChannelList[i].setToolTipText(s);
|
||||
//
|
||||
//
|
||||
// }
|
||||
// return cP;
|
||||
// }
|
||||
//
|
||||
//
|
||||
private JPanel CalibrationPanel() {
|
||||
|
||||
|
||||
JPanel p = new PamAlignmentPanel(BorderLayout.WEST) ;
|
||||
|
||||
|
||||
p.setBorder(new TitledBorder("Calibration"));
|
||||
GridBagLayout layout;
|
||||
|
||||
|
||||
p.setLayout(layout = new GridBagLayout());
|
||||
GridBagConstraints constraints = new PamGridBagContraints();
|
||||
|
||||
|
||||
constraints.anchor = GridBagConstraints.WEST;
|
||||
constraints.insets = new Insets(2,2,2,2);
|
||||
constraints.gridx = 0;
|
||||
@ -588,13 +590,13 @@ public class AcquisitionDialog extends PamDialog {
|
||||
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.";
|
||||
dcTimeconstant.setToolTipText(t);
|
||||
subtractDC.setToolTipText(t);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -604,10 +606,10 @@ public class AcquisitionDialog extends PamDialog {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return the number of channels
|
||||
*/
|
||||
int getNumChannels() {
|
||||
int getNumChannels() {
|
||||
try {
|
||||
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
|
||||
if (currentChannelListPanel != null) {
|
||||
currentChannelListPanel.setNumChannels(getNumChannels());
|
||||
@ -624,64 +626,64 @@ public class AcquisitionDialog extends PamDialog {
|
||||
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
|
||||
*
|
||||
*/
|
||||
*/
|
||||
private void newDeviceType() {
|
||||
|
||||
|
||||
int devNumber = deviceType.getSelectedIndex();
|
||||
|
||||
|
||||
if (devNumber < 0) return;
|
||||
|
||||
|
||||
// remove the old type specific panel and replace it with a new one.
|
||||
if (deviceSpecificPanel != null) {
|
||||
mainPanel.remove(deviceSpecificPanel);
|
||||
}
|
||||
currentDaqSystem = acquisitionControl.systemList.get(devNumber);
|
||||
|
||||
|
||||
deviceSpecificPanel = currentDaqSystem.getDaqSpecificDialogComponent(this);
|
||||
if (deviceSpecificPanel != null) {
|
||||
mainPanel.add(deviceSpecificPanel, 1);
|
||||
currentDaqSystem.dialogSetParams();
|
||||
}
|
||||
|
||||
|
||||
sampleRate.setEnabled(currentDaqSystem.getMaxSampleRate() != DaqSystem.PARAMETER_FIXED);
|
||||
nChannels.setEnabled(currentDaqSystem.getMaxChannels() != DaqSystem.PARAMETER_FIXED);
|
||||
vPeak2Peak.setEnabled(currentDaqSystem.getPeak2PeakVoltage(0) == DaqSystem.PARAMETER_UNKNOWN);
|
||||
|
||||
|
||||
showHideChannelPanel();
|
||||
|
||||
|
||||
if (currentChannelListPanel != null) {
|
||||
currentChannelListPanel.setNumChannels(getNumChannels());
|
||||
currentChannelListPanel.setParams(acquisitionParameters.getHardwareChannelList());
|
||||
}
|
||||
|
||||
|
||||
pack();
|
||||
}
|
||||
public DaqSystem getCurrentDaqSystem() {
|
||||
return currentDaqSystem;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return the sample rate component
|
||||
*/
|
||||
public JTextField getSampleRateComponent() {
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the nChannels component.
|
||||
*
|
||||
* @return the nChannels component.
|
||||
*/
|
||||
public JTextField getnChanComponent() {
|
||||
return nChannels;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,20 +1,16 @@
|
||||
package Acquisition;
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import generalDatabase.PamTableDefinition;
|
||||
import generalDatabase.PamTableItem;
|
||||
import generalDatabase.SQLLogging;
|
||||
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.
|
||||
* @author Doug Gillespie
|
||||
*
|
||||
@ -22,16 +18,16 @@ import clickTrainDetector.CTDataUnit;
|
||||
public class AcquisitionLogging extends SQLLogging {
|
||||
|
||||
AcquisitionControl acquisitionControl;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
public AcquisitionLogging(PamDataBlock pamDataBlock, AcquisitionControl acquisitionControl) {
|
||||
super(pamDataBlock);
|
||||
this.acquisitionControl = acquisitionControl;
|
||||
|
||||
|
||||
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(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(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"));
|
||||
|
||||
|
||||
setTableDefinition(tableDef);
|
||||
}
|
||||
|
||||
@ -68,8 +64,8 @@ public class AcquisitionLogging extends SQLLogging {
|
||||
adcClockMillis.setValue((int)(ds.getAdcMilliseconds()%1000));
|
||||
rawADCTime.setValue(sqlTypes.getTimeStamp(ds.getRawADCMillis()));
|
||||
long s = ds.getSamples();
|
||||
gSamples.setValue((long)(s/1000000000));
|
||||
samples.setValue((long) (s%1000000000));
|
||||
gSamples.setValue(s/1000000000);
|
||||
samples.setValue(s%1000000000);
|
||||
Long gT = ds.getGpsPPSMilliseconds();
|
||||
if (gT == null) {
|
||||
GPSPPSTime.setValue(null);
|
||||
@ -84,7 +80,7 @@ public class AcquisitionLogging extends SQLLogging {
|
||||
sampleRate.setValue(ds.getSampleRate());
|
||||
nChannels.setValue(ds.getNChannels());
|
||||
voltsPeak2Peak.setValue(ds.getVoltsPeak2Peak());
|
||||
gain.setValue((float) daqParameters.getPreamplifier().getGain());
|
||||
gain.setValue((float) daqParameters.getPreamplifier().getGain());
|
||||
duration.setValue(ds.getSampleDuration());
|
||||
clockError.setValue(ds.clockError);
|
||||
Long sTime = ds.getServerTime();
|
||||
@ -95,55 +91,55 @@ public class AcquisitionLogging extends SQLLogging {
|
||||
serverTime.setValue(sqlTypes.getTimeStamp(sTime));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected DaqStatusDataUnit createDataUnit(SQLTypes sqlTypes, long timeMilliseconds, int databaseIndex) {
|
||||
|
||||
// Debug.out.println("DaqStatusDataUnit sql Logging: " + PamCalendar.formatDateTime(timeMilliseconds) + " ADC: " +adcClockTime.getDeblankedStringValue() + " Samples: " + samples.getLongValue());
|
||||
|
||||
long adcClock ;
|
||||
|
||||
// Debug.out.println("DaqStatusDataUnit sql Logging: " + PamCalendar.formatDateTime(timeMilliseconds) + " ADC: " +adcClockTime.getDeblankedStringValue() + " Samples: " + samples.getLongValue());
|
||||
|
||||
long adcClock ;
|
||||
if (adcClockTime.getDeblankedStringValue()!=null) {
|
||||
adcClock = SQLTypes.millisFromTimeStamp(adcClockTime.getValue());
|
||||
adcClock = SQLTypes.millisFromTimeStamp(adcClockTime.getValue());
|
||||
}
|
||||
else {
|
||||
adcClock =-1;
|
||||
adcClock =-1;
|
||||
}
|
||||
|
||||
|
||||
Long adcRawClock = SQLTypes.millisFromTimeStamp(rawADCTime.getValue());
|
||||
if (adcRawClock == null) {
|
||||
adcRawClock = 0L;
|
||||
}
|
||||
//long adcClockMillisVal = adcClockMillis.getLongValue();
|
||||
long gpsPPSClock ;
|
||||
//long adcClockMillisVal = adcClockMillis.getLongValue();
|
||||
long gpsPPSClock ;
|
||||
if (GPSPPSTime.getDeblankedStringValue()!=null) {
|
||||
gpsPPSClock = SQLTypes.millisFromTimeStamp(GPSPPSTime.getValue());
|
||||
gpsPPSClock = SQLTypes.millisFromTimeStamp(GPSPPSTime.getValue());
|
||||
}
|
||||
else {
|
||||
gpsPPSClock=1;
|
||||
gpsPPSClock=1;
|
||||
}
|
||||
|
||||
Long samplesVal = samples.getLongValue();
|
||||
|
||||
String reasonVal = reason.getDeblankedStringValue();
|
||||
String statusVal = status.getDeblankedStringValue();
|
||||
Long samplesVal = samples.getLongValue();
|
||||
|
||||
double clockErrVal = clockError.getDoubleValue();
|
||||
String reasonVal = reason.getDeblankedStringValue();
|
||||
String statusVal = status.getDeblankedStringValue();
|
||||
|
||||
double clockErrVal = clockError.getDoubleValue();
|
||||
double durationValue = duration.getDoubleValue();
|
||||
|
||||
|
||||
String systemName = daqSystemName.getStringValue();
|
||||
|
||||
// DaqStatusDataUnit(long timeMilliseconds, long adcMilliseconds, long samples, Long gpsPPSMillis,
|
||||
// String status, String reason,
|
||||
|
||||
// DaqStatusDataUnit(long timeMilliseconds, long adcMilliseconds, long samples, Long gpsPPSMillis,
|
||||
// String status, String reason,
|
||||
// AcquisitionParameters daqParameters, double duration, double clockError)
|
||||
|
||||
// Debug.out.println("DaqStatusDataUnit sql Logging: " + samplesVal);
|
||||
|
||||
DaqStatusDataUnit dataUnit = new DaqStatusDataUnit(timeMilliseconds, adcClock, adcRawClock, samplesVal, gpsPPSClock,
|
||||
statusVal, reasonVal, null, systemName, durationValue, clockErrVal) ;
|
||||
|
||||
return dataUnit;
|
||||
|
||||
|
||||
// Debug.out.println("DaqStatusDataUnit sql Logging: " + samplesVal);
|
||||
|
||||
DaqStatusDataUnit dataUnit = new DaqStatusDataUnit(timeMilliseconds, adcClock, adcRawClock, samplesVal, gpsPPSClock,
|
||||
statusVal, reasonVal, null, systemName, durationValue, clockErrVal) ;
|
||||
|
||||
return dataUnit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package Acquisition;
|
||||
|
||||
import hfDaqCard.SmruDaqSystem;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@ -13,58 +11,59 @@ import PamModel.parametermanager.PamParameterSet;
|
||||
import PamModel.parametermanager.PamParameterSet.ParameterSetType;
|
||||
import PamModel.parametermanager.PrivatePamParameterData;
|
||||
import PamguardMVC.PamConstants;
|
||||
import hfDaqCard.SmruDaqSystem;
|
||||
|
||||
public class AcquisitionParameters implements Serializable, Cloneable, ManagedParameters {
|
||||
|
||||
static final long serialVersionUID = 2;
|
||||
|
||||
|
||||
String daqSystemType = "Sound Card";
|
||||
|
||||
|
||||
public float sampleRate = 48000;
|
||||
|
||||
|
||||
public int nChannels = 2;
|
||||
|
||||
|
||||
public double voltsPeak2Peak = 5;
|
||||
|
||||
|
||||
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
|
||||
* 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
|
||||
|
||||
|
||||
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
|
||||
* your channel list does not start at zero, you have to first use the
|
||||
* channelListIndexes before using this lookup table.
|
||||
* your channel list does not start at zero, you have to first use the
|
||||
* channelListIndexes before using this lookup table.
|
||||
*/
|
||||
private int[] hydrophoneList;
|
||||
|
||||
|
||||
/**
|
||||
* list of indexes for each hardware channel in channelList (i.e. opposite LUT)
|
||||
*/
|
||||
transient int[] channelListIndexes;
|
||||
|
||||
transient int[] channelListIndexes;
|
||||
|
||||
private PPSParameters ppsParameters;
|
||||
|
||||
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() {
|
||||
getHardwareChannelList(); // automatically create a channellist.
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AcquisitionParameters clone() {
|
||||
try {
|
||||
@ -106,7 +105,7 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
|
||||
|
||||
/**
|
||||
* Gets a list of hydrophones from channel Indexes (not channel numbers)
|
||||
* @return list of hydrophones.
|
||||
* @return list of hydrophones.
|
||||
*/
|
||||
public int[] getHydrophoneList() {
|
||||
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
|
||||
*/
|
||||
public void setHydrophoneList(int[] 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
|
||||
* @return a specific hydrophone number from the selected array
|
||||
*/
|
||||
@ -146,18 +145,15 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
|
||||
if (channel < 0) {
|
||||
return channel;
|
||||
}
|
||||
if (channelListIndexes.length <= channel) return -1;
|
||||
|
||||
// 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];
|
||||
if (channel < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (hydrophoneList.length <= channel) return -1;
|
||||
if ((channelListIndexes.length <= channel) || (channel < 0) || (hydrophoneList.length <= channel)) return -1;
|
||||
return hydrophoneList[channel];
|
||||
}
|
||||
|
||||
|
||||
public int getNChannels() {
|
||||
return nChannels;
|
||||
}
|
||||
@ -165,7 +161,7 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
|
||||
public void setNChannels(int channels) {
|
||||
nChannels = channels;
|
||||
}
|
||||
|
||||
|
||||
public int[] getNChannelList(){
|
||||
return channelList;
|
||||
}
|
||||
@ -196,7 +192,7 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public int[] getHardwareChannelList() {
|
||||
@ -221,7 +217,7 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
|
||||
this.channelList = channelList;
|
||||
sortChannelListIndexes();
|
||||
}
|
||||
|
||||
|
||||
public void setChannelList(int index, int channelNumber) {
|
||||
getHardwareChannelList();
|
||||
if (index >= channelList.length) {
|
||||
@ -230,7 +226,7 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
|
||||
channelList[index] = channelNumber;
|
||||
sortChannelListIndexes();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a default channel list 0,1,2,3,4 etc.
|
||||
*/
|
||||
@ -241,19 +237,19 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
|
||||
}
|
||||
sortChannelListIndexes();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the channel number for a particular channel index.
|
||||
* Gets the channel number for a particular channel index.
|
||||
* @param index channel index
|
||||
* @return channel number
|
||||
*/
|
||||
public int getChannelList(int index) {
|
||||
return getHardwareChannelList()[index];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the complete list of channel indexes.
|
||||
* @return list of channel indexes.
|
||||
* Gets the complete list of channel indexes.
|
||||
* @return list of channel indexes.
|
||||
*/
|
||||
public int[] getChannelListIndexes() {
|
||||
if (channelListIndexes == null) {
|
||||
@ -261,7 +257,7 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
|
||||
}
|
||||
return channelListIndexes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the channel list indeces
|
||||
* @param channelListIndexes
|
||||
@ -269,11 +265,11 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
|
||||
public void setChannelListIndexes(int[] channelListIndexes) {
|
||||
this.channelListIndexes = channelListIndexes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the channel index for a particular hardware channel
|
||||
* Gets the channel index for a particular hardware 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) {
|
||||
if (channelListIndexes == null) {
|
||||
@ -284,10 +280,10 @@ public class AcquisitionParameters implements Serializable, Cloneable, ManagedPa
|
||||
}
|
||||
else return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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++) {
|
||||
max = Math.max(max, channelList[i]);
|
||||
}
|
||||
|
||||
|
||||
channelListIndexes = new int[max+1];
|
||||
for (int i = 0; i < channelListIndexes.length; i++) {
|
||||
channelListIndexes[i] = -1;
|
||||
|
@ -1,19 +1,13 @@
|
||||
package Acquisition;
|
||||
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
||||
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 Acquisition.gpstiming.PPSDetector;
|
||||
import Acquisition.gpstiming.PPSParameters;
|
||||
import Array.ArrayManager;
|
||||
import Array.Hydrophone;
|
||||
import Array.PamArray;
|
||||
import Array.Preamplifier;
|
||||
import Filters.Filter;
|
||||
@ -23,40 +17,29 @@ import Filters.FilterType;
|
||||
import Filters.IirfFilter;
|
||||
import PamController.DataInputStore;
|
||||
import PamController.InputStoreInfo;
|
||||
import PamController.OfflineDataStore;
|
||||
import PamController.PamControlledUnit;
|
||||
import PamController.PamController;
|
||||
import PamController.fileprocessing.ReprocessManager;
|
||||
import PamController.fileprocessing.StoreStatus;
|
||||
import PamController.status.BaseProcessCheck;
|
||||
import PamController.status.ProcessCheck;
|
||||
import PamDetection.RawDataUnit;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamUtils.PamUtils;
|
||||
import PamUtils.time.ntp.PamNTPTime;
|
||||
import PamUtils.time.ntp.PamNTPTimeException;
|
||||
import PamguardMVC.PamConstants;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import PamguardMVC.PamObservable;
|
||||
import PamguardMVC.PamObserver;
|
||||
import PamguardMVC.PamProcess;
|
||||
import PamguardMVC.PamRawDataBlock;
|
||||
import PamguardMVC.RequestCancellationObject;
|
||||
import PamguardMVC.dataOffline.OfflineDataLoadInfo;
|
||||
import dataGram.DatagramManager;
|
||||
import dataMap.OfflineDataMapPoint;
|
||||
import pamScrollSystem.AbstractScrollManager;
|
||||
import pamScrollSystem.ViewLoadObserver;
|
||||
|
||||
/**
|
||||
* Data acquisition process for all types of input device.
|
||||
* This arranges the output data block and starts and stops the
|
||||
* device in the detected DaqSystem. Each DaqSystem should
|
||||
* Data acquisition process for all types of input device.
|
||||
* This arranges the output data block and starts and stops the
|
||||
* device in the detected DaqSystem. Each DaqSystem should
|
||||
* operate a different thread to read the device / file and add its
|
||||
* data to the volatile Vector newDataUnits. AcquisitonProcess will
|
||||
* poll newDataUnits on a timer and when new data is found, put that
|
||||
* data into PamDataUnits and PamRawDataBlocks to be sent out for
|
||||
* data to the volatile Vector newDataUnits. AcquisitonProcess will
|
||||
* poll newDataUnits on a timer and when new data is found, put that
|
||||
* data into PamDataUnits and PamRawDataBlocks to be sent out for
|
||||
* processing.
|
||||
* <p>
|
||||
* @author Doug Gillespie
|
||||
@ -66,9 +49,9 @@ import pamScrollSystem.ViewLoadObserver;
|
||||
*
|
||||
*/
|
||||
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;
|
||||
|
||||
AcquisitionControl acquisitionControl;
|
||||
@ -90,23 +73,23 @@ public class AcquisitionProcess extends PamProcess {
|
||||
private volatile boolean bufferOverflow = false;
|
||||
|
||||
private Timer restartTimer;
|
||||
|
||||
|
||||
private Filter sampleRateErrorFilter;
|
||||
|
||||
|
||||
private double totalExtraSamples;
|
||||
|
||||
private DaqStatusDataUnit previousDaqStatus = null;
|
||||
|
||||
private long millisecondSampleOffset;
|
||||
|
||||
|
||||
private AudioDataQueue newDataQueue = new AudioDataQueue();
|
||||
|
||||
private final double sqrt2 = Math.sqrt(2.0);
|
||||
|
||||
private Object runingSynchObject = new Object();
|
||||
|
||||
|
||||
private PPSDetector ppsDetector;
|
||||
|
||||
|
||||
private DCFilter dcFilter;
|
||||
|
||||
protected AcquisitionProcess(AcquisitionControl acquisitionControl) {
|
||||
@ -116,16 +99,16 @@ public class AcquisitionProcess extends PamProcess {
|
||||
acquisitionProcess = this;
|
||||
|
||||
this.acquisitionControl = acquisitionControl;
|
||||
|
||||
|
||||
ppsDetector = new PPSDetector(this);
|
||||
|
||||
String name = String.format("Raw input data from %s", acquisitionControl.getUnitName());
|
||||
|
||||
//addOutputDataBlock(rawDataBlock = new PamRawDataBlock(name, this,
|
||||
// PamUtils.makeChannelMap(acquisitionControl.acquisitionParameters.nChannels),
|
||||
// PamUtils.makeChannelMap(acquisitionControl.acquisitionParameters.nChannels),
|
||||
// acquisitionControl.acquisitionParameters.sampleRate));
|
||||
|
||||
addOutputDataBlock(rawDataBlock = new PamRawDataBlock(name, this,
|
||||
addOutputDataBlock(rawDataBlock = new PamRawDataBlock(name, this,
|
||||
PamUtils.makeChannelMap(acquisitionControl.acquisitionParameters.nChannels,acquisitionControl.acquisitionParameters.getHardwareChannelList()),
|
||||
acquisitionControl.acquisitionParameters.sampleRate));
|
||||
|
||||
@ -134,11 +117,11 @@ public class AcquisitionProcess extends PamProcess {
|
||||
// daqStatusDataBlock.
|
||||
addOutputDataBlock(daqStatusDataBlock);
|
||||
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
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
// daqStatusDataBlock.setBinaryDataSource(new DaqStatusBinaryStore(daqStatusDataBlock, acquisitionControl));
|
||||
AbstractScrollManager.getScrollManager().addToSpecialDatablock(daqStatusDataBlock);
|
||||
@ -151,14 +134,14 @@ public class AcquisitionProcess extends PamProcess {
|
||||
// stallCheckTimer = new Timer(60000, new StallCheckAction());
|
||||
|
||||
bufferTimer = new Timer(1000, new BufferTimerTest());
|
||||
|
||||
|
||||
ProcessCheck pp = new BaseProcessCheck(this, null, 0, 10);
|
||||
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
|
||||
* 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.filterBand = FilterBand.LOWPASS;
|
||||
@ -205,27 +188,27 @@ public class AcquisitionProcess extends PamProcess {
|
||||
// private long daqCheckInterval = 60 * 1000;
|
||||
@Override
|
||||
public void pamStart() {
|
||||
// called by PamController. Don't actually start if
|
||||
// we're in network receive mode.
|
||||
// called by PamController. Don't actually start if
|
||||
// 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
|
||||
rawDataBlock.clearAll();
|
||||
|
||||
|
||||
sampleRateErrorFilter.prepareFilter();
|
||||
totalExtraSamples = 0;
|
||||
millisecondSampleOffset = 0;
|
||||
|
||||
|
||||
if (runningSystem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
boolean netRX = PamController.getInstance().getRunMode() == PamController.RUN_NETWORKRECEIVER;
|
||||
if (!netRX) {
|
||||
if (runningSystem.startSystem(acquisitionControl) == false) return;
|
||||
if (!runningSystem.startSystem(acquisitionControl)) return;
|
||||
}
|
||||
// Log a data unit asap to get the start time
|
||||
long daqStartedTime = PamCalendar.getTimeInMillis();
|
||||
@ -243,7 +226,7 @@ public class AcquisitionProcess extends PamProcess {
|
||||
acquisitionControl.fillStatusBarText();
|
||||
|
||||
bufferTimer.start();
|
||||
|
||||
|
||||
// stallCheckTimer.start();
|
||||
|
||||
/**
|
||||
@ -255,13 +238,13 @@ public class AcquisitionProcess extends PamProcess {
|
||||
addServerTime(daqStatusDataUnit);
|
||||
daqStatusDataBlock.addPamData(daqStatusDataUnit);
|
||||
previousDaqStatus = daqStatusDataUnit;
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
bufferOverflow = false;
|
||||
// daqCheckTime = PamCalendar.getTimeInMillis();
|
||||
if (!netRX) {
|
||||
@ -270,9 +253,9 @@ public class AcquisitionProcess extends PamProcess {
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean addServerTime(DaqStatusDataUnit daqStatusDataUnit) {
|
||||
if (runningSystem.isRealTime() == false) {
|
||||
if (!runningSystem.isRealTime()) {
|
||||
return false;
|
||||
}
|
||||
// PamNTPTime pamNTPTime = PamNTPTime.getInstance();
|
||||
@ -301,7 +284,7 @@ public class AcquisitionProcess extends PamProcess {
|
||||
// called by PamController.
|
||||
// stop the running system - not the selected system since
|
||||
// this may have changed
|
||||
|
||||
|
||||
restartTimer.stop();
|
||||
// stallCheckTimer.stop();
|
||||
pamStop("");
|
||||
@ -316,15 +299,15 @@ public class AcquisitionProcess extends PamProcess {
|
||||
// Boolean s = isStalled();
|
||||
//// System.out.printf("%s Stall state = %s\n", PamCalendar.formatDateTime(System.currentTimeMillis()), s.toString());
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
private long simpleSamplesToMilliseconds(long samples) {
|
||||
return (long) (samples * 1000. / sampleRate) + PamCalendar.getSessionStartTime();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Periodic logging of ADC status into database.
|
||||
* Periodic logging of ADC status into database.
|
||||
*/
|
||||
private void logRunningStatus() {
|
||||
if (runningSystem == null) return;
|
||||
@ -334,16 +317,16 @@ public class AcquisitionProcess extends PamProcess {
|
||||
long adcMillis = this.absSamplesToMilliseconds(samplesRead);
|
||||
long simpleTime= simpleSamplesToMilliseconds(samplesRead);
|
||||
DaqStatusDataUnit ds = new DaqStatusDataUnit(PamCalendar.getTimeInMillis(), adcMillis, simpleTime,
|
||||
samplesRead, null, "Continue", "",
|
||||
samplesRead, null, "Continue", "",
|
||||
acquisitionControl.acquisitionParameters, runningSystem.getSystemName(), duration, clockError);
|
||||
addServerTime(ds);
|
||||
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);
|
||||
}
|
||||
// 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);
|
||||
// if (previousDaqStatus != null) {
|
||||
//// Double trueSampleRate = ds.calculateTrueSampleRate(previousDaqStatus);
|
||||
@ -353,14 +336,14 @@ public class AcquisitionProcess extends PamProcess {
|
||||
// totalExtraSamples += extExtraSamples;
|
||||
// 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
|
||||
// * when we create a raw data unit.
|
||||
// * when we create a raw data unit.
|
||||
// */
|
||||
//// 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);
|
||||
//
|
||||
//
|
||||
//// }
|
||||
// }
|
||||
daqStatusDataBlock.addPamData(ds);
|
||||
@ -376,11 +359,11 @@ public class AcquisitionProcess extends PamProcess {
|
||||
long adcMillis = this.absSamplesToMilliseconds(samplesRead);
|
||||
long simpleMillis = this.simpleSamplesToMilliseconds(samplesRead);
|
||||
DaqStatusDataUnit ds = new DaqStatusDataUnit(PamCalendar.getTimeInMillis(), adcMillis, simpleMillis,
|
||||
samplesRead, null, "Stop", reason,
|
||||
samplesRead, null, "Stop", reason,
|
||||
acquisitionControl.acquisitionParameters, runningSystem.getSystemName(), duration, clockError);
|
||||
addServerTime(ds);
|
||||
daqStatusDataBlock.addPamData(ds);
|
||||
|
||||
|
||||
runningSystem.stopSystem(acquisitionControl);
|
||||
|
||||
keepRunning = false;
|
||||
@ -397,19 +380,19 @@ public class AcquisitionProcess extends PamProcess {
|
||||
double duration = (double) edgeSample / getSampleRate();
|
||||
double clockError = checkClockSpeed(edgeSample, 0);
|
||||
DaqStatusDataUnit ds = new DaqStatusDataUnit(timeNow, adcMillis, simpleMillis,
|
||||
edgeSample, gpsUTC, "GPSPPS", "",
|
||||
edgeSample, gpsUTC, "GPSPPS", "",
|
||||
acquisitionControl.acquisitionParameters, runningSystem.getSystemName(), duration, clockError);
|
||||
ds.setServerTime(serverTime);
|
||||
|
||||
daqStatusDataBlock.addPamData(ds);
|
||||
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
* 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)
|
||||
*/
|
||||
|
||||
@ -427,9 +410,9 @@ public class AcquisitionProcess extends PamProcess {
|
||||
}
|
||||
}
|
||||
|
||||
// call acquireData one last time to make sure that
|
||||
// all data have been flushed from the buffer.
|
||||
if (bufferOverflow == false) {
|
||||
// call acquireData one last time to make sure that
|
||||
// all data have been flushed from the buffer.
|
||||
if (!bufferOverflow) {
|
||||
acquireData();
|
||||
}
|
||||
else {
|
||||
@ -441,7 +424,7 @@ public class AcquisitionProcess extends PamProcess {
|
||||
/*
|
||||
* 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 !
|
||||
* Synch on runingSynchObject to stop crash during shut down of system.
|
||||
* Synch on runingSynchObject to stop crash during shut down of system.
|
||||
*/
|
||||
synchronized(runingSynchObject) {
|
||||
runningSystem = null;
|
||||
@ -459,21 +442,21 @@ public class AcquisitionProcess extends PamProcess {
|
||||
// PamController.pamStop will wait for that to happen, so if we call pamStop
|
||||
// first it will hang.
|
||||
sendSourceNotification(LASTDATA, null);
|
||||
|
||||
|
||||
// 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
|
||||
// acquisitionControl.pamController.pamStop();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called from AcquisitionControl when all observer thread data queues
|
||||
* have been emptied and processing has stopped
|
||||
*/
|
||||
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){
|
||||
runningSystem = acquisitionControl.findDaqSystem(null);
|
||||
}
|
||||
@ -481,12 +464,12 @@ public class AcquisitionProcess extends PamProcess {
|
||||
runningSystem.daqHasEnded();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* the various threads can clean themselves up.
|
||||
*
|
||||
*
|
||||
* @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)
|
||||
*/
|
||||
@ -496,7 +479,7 @@ public class AcquisitionProcess extends PamProcess {
|
||||
rawDataBlock.getPamObserver(i).receiveSourceNotification(type, object);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean prepareProcessOK() {
|
||||
super.prepareProcessOK();
|
||||
@ -512,9 +495,9 @@ public class AcquisitionProcess extends PamProcess {
|
||||
lastStallCheckTime = 0;
|
||||
lastStallCheckSamples = 0;
|
||||
lastStallState = false;
|
||||
|
||||
|
||||
if (acquisitionControl.acquisitionParameters.subtractDC) {
|
||||
dcFilter = new DCFilter(acquisitionControl.acquisitionParameters.sampleRate,
|
||||
dcFilter = new DCFilter(acquisitionControl.acquisitionParameters.sampleRate,
|
||||
acquisitionControl.acquisitionParameters.dcTimeConstant, PamConstants.MAX_CHANNELS);
|
||||
}
|
||||
else {
|
||||
@ -524,20 +507,20 @@ public class AcquisitionProcess extends PamProcess {
|
||||
setSampleRate(acquisitionControl.acquisitionParameters.sampleRate, true);
|
||||
|
||||
super.prepareProcess();
|
||||
|
||||
|
||||
ppsDetector.prepare(acquisitionControl.acquisitionParameters);
|
||||
|
||||
if (runningSystem != null) {
|
||||
pamStop();
|
||||
}
|
||||
dataBlockLength = -1;
|
||||
|
||||
|
||||
runningSystem = acquisitionControl.findDaqSystem(null);
|
||||
if (runningSystem == null) {
|
||||
System.out.printf("Unable to find daq system %s\n", acquisitionControl.acquisitionParameters.daqSystemType);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
systemPrepared = runningSystem.prepareSystem(acquisitionControl);
|
||||
|
||||
}
|
||||
@ -559,7 +542,7 @@ public class AcquisitionProcess extends PamProcess {
|
||||
/**
|
||||
* Set up channels when using a channel list - note
|
||||
* 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 channelList
|
||||
*/
|
||||
@ -567,7 +550,7 @@ public class AcquisitionProcess extends PamProcess {
|
||||
acquisitionControl.acquisitionParameters.nChannels = numChannels;
|
||||
acquisitionControl.acquisitionParameters.setChannelList(channelList);
|
||||
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 {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
acquisitionControl.fillStatusBarText();
|
||||
@ -609,7 +593,7 @@ public class AcquisitionProcess extends PamProcess {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (acquireData() == false) {
|
||||
if (!acquireData()) {
|
||||
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
|
||||
*
|
||||
*/
|
||||
class RestartTimerFunction implements ActionListener {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
|
||||
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());
|
||||
// long unitMillis = absSamplesToMilliseconds(threadDataUnit.getStartSample()) - millisecondSampleOffset;
|
||||
long unitMillis = (long) simpleSamplesToMilliseconds(threadDataUnit.getStartSample()) + millisecondSampleOffset;
|
||||
newDataUnit = new RawDataUnit(unitMillis,
|
||||
long unitMillis = simpleSamplesToMilliseconds(threadDataUnit.getStartSample()) + millisecondSampleOffset;
|
||||
newDataUnit = new RawDataUnit(unitMillis,
|
||||
threadDataUnit.getChannelBitmap(), threadDataUnit.getStartSample(),
|
||||
threadDataUnit.getSampleDuration());
|
||||
if (dcFilter != null) {
|
||||
@ -688,23 +673,23 @@ public class AcquisitionProcess extends PamProcess {
|
||||
// calculated in the call to setRawData, to dB.
|
||||
newDataUnit.setCalculatedAmlitudeDB(rawAmplitude2dB(newDataUnit.getMeasuredAmplitude(),
|
||||
PamUtils.getSingleChannel(threadDataUnit.getChannelBitmap()), false));
|
||||
|
||||
|
||||
PPSParameters ppsParams = acquisitionControl.acquisitionParameters.getPpsParameters();
|
||||
if (ppsParams.useGpsPPS & newDataUnit.getChannelBitmap() == 1<<ppsParams.gpsPPSChannel){
|
||||
ppsDetector.newData(newDataUnit);
|
||||
}
|
||||
|
||||
|
||||
addData(null, newDataUnit);
|
||||
rawData = newDataUnit.getRawData();
|
||||
dataBlockLength = rawData.length;
|
||||
for (int i = 0; i < rawData.length; i++) {
|
||||
maxLevel = Math.max(maxLevel, Math.abs(rawData[i]));
|
||||
for (double element : rawData) {
|
||||
maxLevel = Math.max(maxLevel, Math.abs(element));
|
||||
}
|
||||
levelSamples += rawData.length;
|
||||
if (bufferOverflow) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (threadDataUnit.getChannelBitmap() == 1<<(acquisitionControl.getAcquisitionParameters().nChannels-1) &&
|
||||
threadDataUnit.getTimeMilliseconds() - lastStatusTime > statusInterval) {
|
||||
logRunningStatus();
|
||||
@ -726,39 +711,39 @@ public class AcquisitionProcess extends PamProcess {
|
||||
// * buffer with a 10s maximum
|
||||
// */
|
||||
// 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");
|
||||
// pamStop("Buffer overflow in sound system");
|
||||
//
|
||||
//
|
||||
// newDataUnits.clear();
|
||||
//
|
||||
//
|
||||
// acquisitionStopped();
|
||||
//
|
||||
//
|
||||
// restartTimer.start();
|
||||
//
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// long now = PamCalendar.getTimeInMillis();
|
||||
// if (now - daqCheckTime >= daqCheckInterval) {
|
||||
// double duration = (double) totalSamples[0] / getSampleRate();
|
||||
// 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,
|
||||
// acquisitionControl.acquisitionParameters.voltsPeak2Peak, duration, clockError);
|
||||
// daqStatusDataBlock.addPamData(ds);
|
||||
// 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
|
||||
// * 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
|
||||
// * there - so would never reduce the delay !
|
||||
// *
|
||||
// * Don't do this if it isn't a real time process since we want to
|
||||
// * there - so would never reduce the delay !
|
||||
// *
|
||||
// * Don't do this if it isn't a real time process since we want to
|
||||
// * keep going as fast as possible
|
||||
// */
|
||||
//// trials++;
|
||||
@ -766,25 +751,25 @@ public class AcquisitionProcess extends PamProcess {
|
||||
//// if (trials == 15 || counts >= 40) {
|
||||
//// if (trials > counts * 3) {
|
||||
//// 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) {
|
||||
//// 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;
|
||||
//// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// RawDataUnit newDataUnit, threadDataUnit;
|
||||
//
|
||||
//
|
||||
// int readCount = 0;
|
||||
// while (!newDataUnits.isEmpty()) {
|
||||
//
|
||||
// threadDataUnit = newDataUnits.remove(0);
|
||||
//
|
||||
//
|
||||
// int channel = PamUtils.getSingleChannel(threadDataUnit.getChannelBitmap());
|
||||
// newDataUnit = new RawDataUnit(absSamplesToMilliseconds(threadDataUnit.getStartSample()),
|
||||
// newDataUnit = new RawDataUnit(absSamplesToMilliseconds(threadDataUnit.getStartSample()),
|
||||
// threadDataUnit.getChannelBitmap(), threadDataUnit.getStartSample(),
|
||||
// threadDataUnit.getDuration());
|
||||
// newDataUnit.setRawData(threadDataUnit.getRawData(), true);
|
||||
@ -800,13 +785,13 @@ public class AcquisitionProcess extends PamProcess {
|
||||
// maxLevel = Math.max(maxLevel, Math.abs(rawData[i]));
|
||||
// }
|
||||
// levelSamples += rawData.length;
|
||||
//
|
||||
//
|
||||
//
|
||||
// // about every 5 seconds, check the buffer isn't filling
|
||||
// if (newDataUnit.getAbsBlockIndex() % (50 * acquisitionControl.acquisitionParameters.nChannels) == 0) {
|
||||
// double buffer = getBufferEstimate(newDataUnit.getStartSample() + newDataUnit.getDuration());
|
||||
// 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");
|
||||
// pamStop("Type 2 Buffer overflow in sound system");
|
||||
//
|
||||
@ -819,7 +804,7 @@ public class AcquisitionProcess extends PamProcess {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// // about every minute, or every 1200 blocks, check the timing
|
||||
// if ((newDataUnit.getAbsBlockIndex()+1) % (600 * acquisitionControl.acquisitionParameters.nChannels) == 0) {
|
||||
// checkClockSpeed(newDataUnit.getStartSample() + newDataUnit.getDuration(), 1);
|
||||
@ -829,7 +814,7 @@ public class AcquisitionProcess extends PamProcess {
|
||||
// if (++readCount >= acquisitionControl.acquisitionParameters.nChannels * 4 && finalFlush == false) {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
// if (levelSamples >= sampleRate * acquisitionControl.acquisitionParameters.nChannels * 2) {
|
||||
// acquisitionControl.setStatusBarLevel(maxLevel);
|
||||
@ -854,7 +839,7 @@ public class AcquisitionProcess extends PamProcess {
|
||||
double soundCardError = (sampleSeconds - clockSeconds) / clockSeconds * 100;
|
||||
int missingSamples = (int) ((sampleSeconds - clockSeconds) * getSampleRate());
|
||||
// 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));
|
||||
// }
|
||||
return soundCardError;
|
||||
@ -881,19 +866,19 @@ public class AcquisitionProcess extends PamProcess {
|
||||
{
|
||||
// if (newDataUnits == null) return 0;
|
||||
// if (dataBlockLength <= 0) return 0;
|
||||
// double blocksPerSecond = getSampleRate() / dataBlockLength *
|
||||
// double blocksPerSecond = getSampleRate() / dataBlockLength *
|
||||
// acquisitionControl.acquisitionParameters.nChannels;
|
||||
// return newDataUnits.size() / blocksPerSecond;
|
||||
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
|
||||
* 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() {
|
||||
/**
|
||||
@ -908,7 +893,7 @@ public class AcquisitionProcess extends PamProcess {
|
||||
System.out.printf("Restart because %ss buffer > %ss maximum\n", getBufferSeconds(), getMaxBufferSeconds());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -931,20 +916,20 @@ public class AcquisitionProcess extends PamProcess {
|
||||
/**
|
||||
* Convert a raw amplitude to dB re 1 micropascal based on
|
||||
* calibration information held in the AcquisitionController
|
||||
*
|
||||
*
|
||||
* @param rawAmplitude raw amplitude (should be -1 < rawAmplitude < 1)
|
||||
* @return amplitude in dB re 1 uPa.
|
||||
*/
|
||||
public double rawAmplitude2dB(double rawAmplitude, int channel, boolean fast){
|
||||
|
||||
channel = checkSingleChannel(channel);
|
||||
|
||||
|
||||
double constantTerm;
|
||||
if (fast && fixedAmplitudeConstantTerm[channel] != 0) {
|
||||
constantTerm = fixedAmplitudeConstantTerm[channel];
|
||||
}
|
||||
else {
|
||||
constantTerm = getAmplitudeConstantTerm(channel);
|
||||
constantTerm = getAmplitudeConstantTerm(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
|
||||
* 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;
|
||||
|
||||
@ -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
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* channel number not a bitmap with a single set channel.
|
||||
* and we need to be 100% sure that all amplitude calculations are sent a
|
||||
* channel number not a bitmap with a single set 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) {
|
||||
return channel;
|
||||
@ -986,7 +971,7 @@ public class AcquisitionProcess extends PamProcess {
|
||||
/**
|
||||
* Some devices may be setting this per channel.
|
||||
* @param swChannel software channel number
|
||||
* @return peak to peak voltage range.
|
||||
* @return peak to peak voltage range.
|
||||
*/
|
||||
public double getPeak2PeakVoltage(int swChannel) {
|
||||
|
||||
@ -1005,17 +990,17 @@ public class AcquisitionProcess extends PamProcess {
|
||||
/**
|
||||
* A Constant used for fast amplitude calculations when things
|
||||
* like preamp gain will remain constant. Contains a constant
|
||||
* term in the SPL calculations bases on preamp gains and
|
||||
* hdrophone sensitivities.
|
||||
* Changes to be channel specific since with multi threading it goes horribly
|
||||
* wrong if different channels have different sensitivities.
|
||||
* term in the SPL calculations bases on preamp gains and
|
||||
* hdrophone sensitivities.
|
||||
* Changes to be channel specific since with multi threading it goes horribly
|
||||
* wrong if different channels have different sensitivities.
|
||||
*/
|
||||
private double[] fixedAmplitudeConstantTerm = new double[PamConstants.MAX_CHANNELS];
|
||||
|
||||
|
||||
private DaqSystem ampSystem;
|
||||
/**
|
||||
* Gets the fixedAmplitudeConstantTerm based on channel and hydrophone This is
|
||||
* the hydrophone sensitivity + all gains + ADC sensitivity in counts / volt.
|
||||
* Gets the fixedAmplitudeConstantTerm based on channel and hydrophone This is
|
||||
* the hydrophone sensitivity + all gains + ADC sensitivity in counts / volt.
|
||||
* @param channel = single software channel
|
||||
* @return constant term for amplitude calculations
|
||||
*/
|
||||
@ -1027,7 +1012,7 @@ public class AcquisitionProcess extends PamProcess {
|
||||
if (hydrophoneChannel < 0) hydrophoneChannel = 0;
|
||||
// Hydrophone hydrophone = array.getHydrophone(hydrophoneChannel);
|
||||
double hSens = array.getHydrophoneSensitivityAndGain(hydrophoneChannel);
|
||||
|
||||
|
||||
Preamplifier preamp = acquisitionControl.acquisitionParameters.preamplifier;
|
||||
if (getRunningSystem() != null) {
|
||||
ampSystem = getRunningSystem();
|
||||
@ -1037,14 +1022,14 @@ public class AcquisitionProcess extends PamProcess {
|
||||
}
|
||||
double xtra = 0;
|
||||
if (ampSystem != null) {
|
||||
xtra = ampSystem.getChannelGain(channel);
|
||||
xtra = ampSystem.getChannelGain(channel);
|
||||
}
|
||||
return (hSens + preamp.getGain() + xtra);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
channel = checkSingleChannel(channel);
|
||||
@ -1055,7 +1040,7 @@ public class AcquisitionProcess extends PamProcess {
|
||||
* Convert a raw amplitude to dB re 1 micropascal based on
|
||||
* calibration information held in the AcquisitionController
|
||||
* for an array of double data
|
||||
*
|
||||
*
|
||||
* @param rawAmplitude raw amplitude (should be -1 < rawAmplitude < 1)
|
||||
* @param channel channel number (MUST be a channel 0 - 31, not a sequence number)
|
||||
* @return amplitude in dB re 1 uPa.
|
||||
@ -1073,10 +1058,10 @@ public class AcquisitionProcess extends PamProcess {
|
||||
* dB re 1 micropacal / sqrt(Hz).
|
||||
* @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 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.
|
||||
* @param fftLength length of the FFT (needed for Parsevals correction)
|
||||
* @param isSquared is magnitude squared (in which case sqrt will be taken).
|
||||
* @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.
|
||||
* @param fftLength length of the FFT (needed for Parsevals correction)
|
||||
* @param isSquared is magnitude squared (in which case sqrt will be taken).
|
||||
* @param fast use fast calculation (after call to prepareFastAmplitudeCalculation(...).
|
||||
* @return spectrum level amplitude.
|
||||
*/
|
||||
@ -1096,13 +1081,13 @@ public class AcquisitionProcess extends PamProcess {
|
||||
double dB = rawAmplitude2dB(fftAmplitude, channel, fast);
|
||||
return dB;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert the amplitude of fft data into a spectrum level measurement in
|
||||
* dB re 1 micropacal / sqrt(Hz) for an array of double values.
|
||||
* @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 fftLength lengthof the fft (needed for Parsevals correction)
|
||||
* @param fftLength lengthof the fft (needed for Parsevals correction)
|
||||
* @return spectrum level amplitude.
|
||||
*/
|
||||
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
|
||||
* dB re 1 micropacal / sqrt(Hz).
|
||||
* <p>
|
||||
* 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, but it does NOT convert the result to a spectrum level measurement.
|
||||
* 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, but it does NOT convert the result to a spectrum level measurement.
|
||||
* @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
|
||||
*/
|
||||
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.
|
||||
* @param channel channel number, i.e. channel index 0 - 31 NOT a bitmap.
|
||||
* 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 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) {
|
||||
double db = dBMuPascal + getAmplitudeConstantTerm(channel);
|
||||
@ -1171,9 +1156,9 @@ public class AcquisitionProcess extends PamProcess {
|
||||
|
||||
@Override
|
||||
public int getOfflineData(OfflineDataLoadInfo offlineLoadDataInfo) {
|
||||
|
||||
|
||||
// System.out.println("AquisitionProcess: GetofflineData: " + offlineLoadDataInfo.getCurrentObserver().getObserverName())
|
||||
|
||||
|
||||
if (acquisitionControl.getOfflineFileServer() == null) {
|
||||
return PamDataBlock.REQUEST_NO_DATA;
|
||||
}
|
||||
@ -1184,11 +1169,11 @@ public class AcquisitionProcess extends PamProcess {
|
||||
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
|
||||
* @return number of samples.
|
||||
* @return number of samples.
|
||||
*/
|
||||
public long getTotalSamples(int iChannel) {
|
||||
return newDataQueue.getSamplesIn(iChannel);
|
||||
@ -1205,8 +1190,8 @@ public class AcquisitionProcess extends PamProcess {
|
||||
long lastStallCheckSamples = 0;
|
||||
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() {
|
||||
long samples = getTotalSamples(0);
|
||||
@ -1214,13 +1199,13 @@ public class AcquisitionProcess extends PamProcess {
|
||||
long stallCheckSecs = getStallCheckSeconds();
|
||||
long runTime = now - PamCalendar.getSessionStartTime();
|
||||
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;
|
||||
}
|
||||
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);
|
||||
if (stalled) {
|
||||
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
|
||||
*/
|
||||
public PamDataBlock<DaqStatusDataUnit> getDaqStatusDataBlock() {
|
||||
@ -1261,6 +1246,6 @@ public class AcquisitionProcess extends PamProcess {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,40 +9,40 @@ import PamUtils.PamUtils;
|
||||
import PamguardMVC.PamConstants;
|
||||
|
||||
/**
|
||||
* Better management of new data list.
|
||||
* Better management of new data list.
|
||||
* <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
|
||||
* in their own thread and data are read out in a different thread.
|
||||
* @author Doug Gillespie.
|
||||
* in their own thread and data are read out in a different thread.
|
||||
* @author Doug Gillespie.
|
||||
*
|
||||
*/
|
||||
public class AudioDataQueue {
|
||||
|
||||
private volatile List<RawDataUnit> newDataUnits;
|
||||
|
||||
|
||||
private long samplesIn[] = new long[PamConstants.MAX_CHANNELS];
|
||||
private long samplesOut[] = new long[PamConstants.MAX_CHANNELS];
|
||||
|
||||
|
||||
public AudioDataQueue() {
|
||||
newDataUnits = Collections.synchronizedList(new LinkedList<RawDataUnit>());
|
||||
}
|
||||
|
||||
|
||||
public synchronized void clearList() {
|
||||
newDataUnits.clear();
|
||||
for (int i = 0; i < PamConstants.MAX_CHANNELS; i++) {
|
||||
samplesIn[i] = samplesOut[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public synchronized boolean hasData() {
|
||||
return !newDataUnits.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
public synchronized int getQueueSize() {
|
||||
return newDataUnits.size();
|
||||
}
|
||||
|
||||
|
||||
public synchronized RawDataUnit removeOldest() {
|
||||
RawDataUnit ru = newDataUnits.remove(0);
|
||||
if (ru != null) {
|
||||
@ -54,17 +54,17 @@ public class AudioDataQueue {
|
||||
|
||||
public void addNewData(RawDataUnit newDataUnit) {
|
||||
addNewData(newDataUnit, PamUtils.getSingleChannel(newDataUnit.getChannelBitmap()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public synchronized void addNewData(RawDataUnit newDataUnit, int channel) {
|
||||
samplesIn[channel] += newDataUnit.getSampleDuration();
|
||||
newDataUnits.add(newDataUnit);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
* @param channel channel number
|
||||
* @return number of stored samples in queue
|
||||
*/
|
||||
|
@ -7,48 +7,48 @@ import javafx.scene.Node;
|
||||
/**
|
||||
* Interface allowing individual devices to provide their
|
||||
* 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
|
||||
* whereby multiple devices may be used.
|
||||
* whereby multiple devices may be used.
|
||||
* @author Doug Gillespie
|
||||
*
|
||||
*/
|
||||
public interface ChannelListPanel {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the component for the dialog panel.
|
||||
*
|
||||
* @return the component for the dialog panel.
|
||||
*/
|
||||
public Component getComponent();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the component for the dialog panel.
|
||||
*
|
||||
* @return the component for the dialog panel.
|
||||
*/
|
||||
public Node getNode();
|
||||
|
||||
|
||||
/**
|
||||
* Set the channel list.
|
||||
* Set the channel list.
|
||||
* @param channelList channel list
|
||||
*/
|
||||
public void setParams(int[] channelList);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return the channel list
|
||||
*/
|
||||
public int[] getChannelList();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return true if the configuration seems to be valid (i.e. no repeated channels, etc)
|
||||
*/
|
||||
public boolean isDataOk();
|
||||
|
||||
|
||||
/**
|
||||
* Set the total number of channels to display.
|
||||
* @param nChannels the total number of channels to display.
|
||||
* Set the total number of channels to display.
|
||||
* @param nChannels the total number of channels to display.
|
||||
*/
|
||||
public void setNumChannels(int nChannels);
|
||||
|
||||
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class CheckWavFileHeaders extends PamDialog {
|
||||
|
||||
private CheckFiles checkFilesWorker;
|
||||
|
||||
private ArrayList<File> allFiles = new ArrayList<File>();
|
||||
private ArrayList<File> allFiles = new ArrayList<>();
|
||||
|
||||
private CheckWavFileHeaders(Window parentFrame) {
|
||||
super(parentFrame, "Check File Headers", false);
|
||||
@ -89,8 +89,8 @@ public class CheckWavFileHeaders extends PamDialog {
|
||||
}
|
||||
|
||||
private void enableControls() {
|
||||
getOkButton().setEnabled(nFiles > 0 & running == false && ran == false);
|
||||
getCancelButton().setEnabled(running == false);
|
||||
getOkButton().setEnabled(nFiles > 0 & !running && !ran);
|
||||
getCancelButton().setEnabled(!running);
|
||||
}
|
||||
|
||||
private int countFiles(File folder) {
|
||||
@ -98,8 +98,8 @@ public class CheckWavFileHeaders extends PamDialog {
|
||||
File[] files = folder.listFiles(new PamAudioFileFilter());
|
||||
if (files == null) return 0;
|
||||
File file;
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
file = files[i];
|
||||
for (File file2 : files) {
|
||||
file = file2;
|
||||
if (file.isDirectory() && subFolders) {
|
||||
System.out.println(file.getAbsoluteFile());
|
||||
nF += countFiles(file.getAbsoluteFile());
|
||||
@ -146,7 +146,7 @@ public class CheckWavFileHeaders extends PamDialog {
|
||||
private void setProgressInfo(ProgressData progressData) {
|
||||
progressBar.setValue(++doneFiles);
|
||||
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;
|
||||
if (problem) {
|
||||
nErrors++;
|
||||
@ -164,7 +164,7 @@ public class CheckWavFileHeaders extends PamDialog {
|
||||
* @return true if there is an error
|
||||
*/
|
||||
private int checkFile(File aFile) {
|
||||
if (aFile.exists() == false || aFile.isDirectory() == true) {
|
||||
if (!aFile.exists() || aFile.isDirectory()) {
|
||||
return AudioFileFuncs.FILE_DOESNTEXIST;
|
||||
}
|
||||
String fileName = aFile.getName();
|
||||
@ -179,7 +179,7 @@ public class CheckWavFileHeaders extends PamDialog {
|
||||
}
|
||||
else if (fileEnd.equalsIgnoreCase("aif")) {
|
||||
return checkAifFile(aFile);
|
||||
}
|
||||
}
|
||||
return AudioFileFuncs.FILE_UNKNOWNTYPE;
|
||||
}
|
||||
|
||||
@ -198,13 +198,13 @@ public class CheckWavFileHeaders extends PamDialog {
|
||||
protected Integer doInBackground() throws Exception {
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
int error;
|
||||
File aFile;
|
||||
for (int i = 0; i < allFiles.size(); i++) {
|
||||
error = checkFile(aFile = allFiles.get(i));
|
||||
for (File file : allFiles) {
|
||||
error = checkFile(aFile = file);
|
||||
publish(new ProgressData(aFile, error));
|
||||
}
|
||||
return null;
|
||||
@ -220,8 +220,8 @@ public class CheckWavFileHeaders extends PamDialog {
|
||||
|
||||
@Override
|
||||
protected void process(List<ProgressData> progressData) {
|
||||
for (int i = 0; i < progressData.size(); i++) {
|
||||
setProgressInfo(progressData.get(i));
|
||||
for (ProgressData element : progressData) {
|
||||
setProgressInfo(element);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import PamguardMVC.ChannelListManager;
|
||||
|
||||
/**
|
||||
* Class for converting channel indexes and numbers to hydrophones
|
||||
* for the main PAMGAURD DAQ.
|
||||
* for the main PAMGAURD DAQ.
|
||||
* <p>
|
||||
* All these functions are passed through to the AcquisitionParameters class
|
||||
* 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 {
|
||||
|
||||
private AcquisitionControl acquisitionControl;
|
||||
|
||||
|
||||
public DAQChannelListManager(AcquisitionControl acquisitionControl) {
|
||||
this.acquisitionControl = acquisitionControl;
|
||||
}
|
||||
@ -25,7 +25,7 @@ public class DAQChannelListManager extends ChannelListManager {
|
||||
// public int channelIndexToNumber(int channelIndex) {
|
||||
//
|
||||
// return acquisitionControl.acquisitionParameters.getChannelList(channelIndex);
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,7 @@
|
||||
package Acquisition;
|
||||
|
||||
/**
|
||||
* Class to remove DC offset from audio data.
|
||||
* Class to remove DC offset from audio data.
|
||||
* @author Douglas Gillespie
|
||||
*
|
||||
*/
|
||||
@ -20,7 +20,7 @@ public class DCFilter {
|
||||
background = new double[nChannels];
|
||||
alpha = 1-1./(sampleRate*timeConstant);
|
||||
}
|
||||
|
||||
|
||||
public void filterData(int channel, double[] data) {
|
||||
double x;
|
||||
double b = background[channel];
|
||||
|
@ -21,7 +21,7 @@ public class DCL5System extends FolderInputSystem implements PamSettings {
|
||||
// PamSettingManager.getInstance().registerSettings(this);
|
||||
// }
|
||||
String xmlDocName = "C:\\DCL_5_2011\\Matlab\\SpeciesFiletimes2.xml";
|
||||
|
||||
|
||||
|
||||
Document doc;
|
||||
|
||||
@ -84,9 +84,9 @@ public class DCL5System extends FolderInputSystem implements PamSettings {
|
||||
String timeString = e.getAttribute("time");
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import binaryFileStorage.BinaryHeader;
|
||||
import binaryFileStorage.BinaryObjectData;
|
||||
import binaryFileStorage.ModuleFooter;
|
||||
import binaryFileStorage.ModuleHeader;
|
||||
import binaryFileStorage.PackedBinaryObject;
|
||||
|
||||
public class DaqStatusBinaryStore extends BinaryDataSource {
|
||||
|
||||
@ -50,12 +49,12 @@ public class DaqStatusBinaryStore extends BinaryDataSource {
|
||||
|
||||
@Override
|
||||
public PamDataUnit sinkData(BinaryObjectData binaryObjectData, BinaryHeader bh, int moduleVersion) {
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(binaryObjectData.getData(),
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(binaryObjectData.getData(),
|
||||
0, binaryObjectData.getDataLength());
|
||||
DataInputStream dis = new DataInputStream(bis);
|
||||
|
||||
|
||||
long adcMilliseconds = 0;
|
||||
long samples = 0;
|
||||
long samples = 0;
|
||||
Long gpsPPSMillis = null;
|
||||
short status = 0;
|
||||
short reason = 0;
|
||||
@ -68,7 +67,7 @@ public class DaqStatusBinaryStore extends BinaryDataSource {
|
||||
gpsPPSMillis = dis.readLong();
|
||||
if (gpsPPSMillis == 0) {
|
||||
// zero must be intrpreted as null (no data) or it can screw up some time corrections in the
|
||||
// network receiver.
|
||||
// network receiver.
|
||||
gpsPPSMillis = null;
|
||||
}
|
||||
status = dis.readShort();
|
||||
@ -97,24 +96,24 @@ public class DaqStatusBinaryStore extends BinaryDataSource {
|
||||
channels = PamUtils.PamUtils.makeChannelMap(acquisitionControl.acquisitionParameters.nChannels);
|
||||
voltsPeak2Peak = acquisitionControl.acquisitionParameters.voltsPeak2Peak;
|
||||
}
|
||||
|
||||
|
||||
AcquisitionParameters daqParams = new AcquisitionParameters();
|
||||
daqParams.setVoltsPeak2Peak(voltsPeak2Peak);
|
||||
daqParams.setPreamplifier(new Preamplifier(0, null));
|
||||
daqParams.setSampleRate(sampleRate);
|
||||
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(),
|
||||
adcMilliseconds, adcMilliseconds, samples, gpsPPSMillis, (new Short(status)).toString(),
|
||||
DaqStatusDataUnit dsdu = new DaqStatusDataUnit(binaryObjectData.getTimeMilliseconds(),
|
||||
adcMilliseconds, adcMilliseconds, samples, gpsPPSMillis, (new Short(status)).toString(),
|
||||
(new Short(reason)).toString(), daqParams, null, duration, clockError);
|
||||
return dsdu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleHeader sinkModuleHeader(BinaryObjectData binaryObjectData, BinaryHeader bh) {
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(binaryObjectData.getData(),
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(binaryObjectData.getData(),
|
||||
0, binaryObjectData.getDataLength());
|
||||
DataInputStream dis = new DataInputStream(bis);
|
||||
moduleHeader = new DaqStatusModuleHeader(bh.getHeaderFormat());
|
||||
@ -127,7 +126,7 @@ public class DaqStatusBinaryStore extends BinaryDataSource {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return moduleHeader;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package Acquisition;
|
||||
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamProcess;
|
||||
import dataMap.OfflineDataMap;
|
||||
import effort.EffortProvider;
|
||||
import effort.binary.DataMapEffortProvider;
|
||||
import generalDatabase.DBControlUnit;
|
||||
@ -15,9 +14,9 @@ public class DaqStatusDataBlock extends PamDataBlock<DaqStatusDataUnit> {
|
||||
|
||||
@Override
|
||||
public EffortProvider autoEffortProvider() {
|
||||
// make a provider which will pick up on the database data.
|
||||
// db data are written every 60s, so put 62s as max gap.
|
||||
// make a provider which will pick up on the database data.
|
||||
// db data are written every 60s, so put 62s as max gap.
|
||||
return new DataMapEffortProvider(this, DBControlUnit.class, 62000L);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,42 +1,41 @@
|
||||
package Acquisition;
|
||||
|
||||
import PamUtils.PamCalendar;
|
||||
import PamUtils.PamUtils;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
|
||||
/**
|
||||
* Data unit containing information on run starts and stops.
|
||||
* Data unit containing information on run starts and stops.
|
||||
* <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
|
||||
*
|
||||
*
|
||||
* @author Doug Gillespie
|
||||
*
|
||||
*/
|
||||
public class DaqStatusDataUnit extends PamDataUnit {
|
||||
|
||||
private String status = "Stop";
|
||||
|
||||
|
||||
private String reason = "";
|
||||
|
||||
|
||||
private String daqSystemType = "";
|
||||
|
||||
|
||||
public int sampleRate;
|
||||
|
||||
|
||||
public Double trueSampleRate;
|
||||
|
||||
|
||||
public int nChannels = 2;
|
||||
|
||||
|
||||
public double voltsPeak2Peak = 5;
|
||||
|
||||
|
||||
public double duration = 0;
|
||||
|
||||
|
||||
public double clockError;
|
||||
|
||||
private long adcMilliseconds;
|
||||
|
||||
|
||||
private long samples;
|
||||
|
||||
|
||||
private Long gpsPPSMilliseconds;
|
||||
|
||||
private Long serverTime;
|
||||
@ -44,13 +43,13 @@ public class DaqStatusDataUnit extends PamDataUnit {
|
||||
private AcquisitionParameters daqParameters;
|
||||
|
||||
private long rawADCMillis;
|
||||
|
||||
|
||||
private String systemName;
|
||||
// private static DaqStatusDataUnit previousDaqStatusUnit = null;
|
||||
|
||||
public DaqStatusDataUnit(long timeMilliseconds, long adcMilliseconds, long rawADCMillis,
|
||||
long samples, Long gpsPPSMillis,
|
||||
String status, String reason,
|
||||
public DaqStatusDataUnit(long timeMilliseconds, long adcMilliseconds, long rawADCMillis,
|
||||
long samples, Long gpsPPSMillis,
|
||||
String status, String reason,
|
||||
AcquisitionParameters daqParameters, String systemName, double duration, double clockError) {
|
||||
super(timeMilliseconds);
|
||||
this.adcMilliseconds = adcMilliseconds;
|
||||
@ -60,7 +59,7 @@ public class DaqStatusDataUnit extends PamDataUnit {
|
||||
this.status = status;
|
||||
this.reason = reason;
|
||||
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.daqParameters = daqParameters;
|
||||
this.sampleRate = (int) daqParameters.getSampleRate();
|
||||
@ -70,17 +69,17 @@ public class DaqStatusDataUnit extends PamDataUnit {
|
||||
this.systemName = systemName;
|
||||
this.duration = duration;
|
||||
this.clockError = clockError;
|
||||
|
||||
|
||||
// set the DataUnitBaseData duration (in samples) to this duration
|
||||
this.setSampleDuration((long) (duration*sampleRate));
|
||||
|
||||
|
||||
// /*
|
||||
// * This won't work if data are being sent from multiple receivers !
|
||||
// */
|
||||
// calculateTrueSampleRate(previousDaqStatusUnit);
|
||||
// previousDaqStatusUnit = this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the systemName
|
||||
*/
|
||||
@ -99,9 +98,9 @@ public class DaqStatusDataUnit extends PamDataUnit {
|
||||
if (previousUnit == null || gpsPPSMilliseconds == null || previousUnit.getGpsPPSMilliseconds() == null) {
|
||||
trueSampleRate = null;
|
||||
return null;
|
||||
}
|
||||
double samples = (double) (this.samples - previousUnit.getSamples());
|
||||
double tDiff = (double) (this.gpsPPSMilliseconds - previousUnit.getGpsPPSMilliseconds()) / 1000.;
|
||||
}
|
||||
double samples = this.samples - previousUnit.getSamples();
|
||||
double tDiff = (this.gpsPPSMilliseconds - previousUnit.getGpsPPSMilliseconds()) / 1000.;
|
||||
if (tDiff > 0 && tDiff < 900 && samples > 0) {
|
||||
trueSampleRate = samples/tDiff;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import binaryFileStorage.ModuleHeader;
|
||||
class DaqStatusModuleHeader extends ModuleHeader implements Serializable, ManagedParameters {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
public DaqStatusModuleHeader(int moduleVersion) {
|
||||
super(moduleVersion);
|
||||
}
|
||||
|
@ -6,86 +6,84 @@ import javax.swing.JComponent;
|
||||
|
||||
import Acquisition.layoutFX.AcquisitionPaneFX;
|
||||
import Acquisition.layoutFX.DAQSettingsPane;
|
||||
import PamController.SettingsPane;
|
||||
import PamUtils.PamUtils;
|
||||
import javafx.scene.Node;
|
||||
import soundPlayback.FilePlayback;
|
||||
import soundPlayback.PlaybackControl;
|
||||
import soundPlayback.PlaybackSystem;
|
||||
|
||||
/**
|
||||
*
|
||||
* Abstraction to multiple data acquisition devices. This interface performs
|
||||
*
|
||||
* Abstraction to multiple data acquisition devices. This interface performs
|
||||
* the following tasks:
|
||||
* <p>
|
||||
* 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
|
||||
* general data acquisition panel
|
||||
* 3. Provides threads and any other functions necessary to create packets of raw audio data in
|
||||
* PamDataUnit's.
|
||||
* 4. Each concrete class should, if needed, save it's own setting using the PamSettings package.
|
||||
* 3. Provides threads and any other functions necessary to create packets of raw audio data in
|
||||
* PamDataUnit's.
|
||||
* 4. Each concrete class should, if needed, save it's own setting using the PamSettings package.
|
||||
* <p>
|
||||
* Current examples are in SoundCardSystem and FileInputSystem
|
||||
*
|
||||
*
|
||||
* @author Doug Gillespie
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// 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 static final int PARAMETER_UNKNOWN = -1;
|
||||
|
||||
|
||||
public static final int PARAMETER_FIXED = -2;
|
||||
|
||||
|
||||
private int streamStatus = STREAM_CLOSED;
|
||||
|
||||
|
||||
/**
|
||||
* @return The 'type' of data source for display in the Data Source dialog
|
||||
* <p> Calling functions should be able to handle 'null'
|
||||
*/
|
||||
abstract public String getSystemType();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return A string describing the data source, e.g. the sound card name, file name, udp port, etc.
|
||||
*/
|
||||
abstract public String getSystemName();
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* name, gain settings, channel lists, whatever is available for the specific device
|
||||
* <p>
|
||||
* 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
|
||||
* number of channels.
|
||||
* number of channels.
|
||||
* <p>
|
||||
* @param acquisitionDialog the AcquisitionDialog this component will be added to
|
||||
* @return dialog component specific to this DAQ device
|
||||
*/
|
||||
abstract public JComponent getDaqSpecificDialogComponent(AcquisitionDialog acquisitionDialog);
|
||||
|
||||
|
||||
/**
|
||||
* Get a channel list panel (invented for NI cards which have many more options)
|
||||
* @param acquisitionDialog reference to main acquisition dialog
|
||||
* @return ChannelListPanel component.
|
||||
* @return ChannelListPanel component.
|
||||
*/
|
||||
public ChannelListPanel getDaqSpecificChannelListPanel(AcquisitionDialog acquisitionDialog) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Called by AcquisitionDialog.SetParams so that the dialog componenet can update it's
|
||||
* fields
|
||||
*
|
||||
*/
|
||||
abstract public void dialogSetParams();
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -94,49 +92,49 @@ public abstract class DaqSystem {
|
||||
* dialog will not respond to its Ok button.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public void setSelected(boolean select) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get model changed events.
|
||||
* Get model changed events.
|
||||
* @param changeType
|
||||
*/
|
||||
public void notifyModelChanged(int changeType) {
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return the maximum sample rate supporrted by the selected device, or PARAMETER_UNKNOWN
|
||||
*/
|
||||
abstract public int getMaxSampleRate();
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return the maximum number of channels supporrted by the selected device, or PARAMETER_UNKNOWN
|
||||
*/
|
||||
abstract public int getMaxChannels();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return peak to peak voltage for the device or PARAMETER_UNKNOWN
|
||||
*/
|
||||
abstract public double getPeak2PeakVoltage(int swChannel);
|
||||
|
||||
|
||||
/**
|
||||
* Prepare the DaqSystem.
|
||||
* Prepare the DaqSystem.
|
||||
* <p>
|
||||
* Usually this is the time for opening files, preparing data buffers, etc.
|
||||
* @param daqControl AcquisitionControl unit.
|
||||
* @return true if OK, false otherwise.
|
||||
*/
|
||||
abstract public boolean prepareSystem(AcquisitionControl daqControl);
|
||||
|
||||
|
||||
/**
|
||||
* Start the DaqSystem. This is called immediately after PrepareSystem
|
||||
* <p>
|
||||
@ -148,46 +146,46 @@ public abstract class DaqSystem {
|
||||
* @return true if OK, false otherwise
|
||||
*/
|
||||
abstract public boolean startSystem(AcquisitionControl daqControl);
|
||||
|
||||
|
||||
/**
|
||||
* Stop the DaqSystem.
|
||||
* Stop the DaqSystem.
|
||||
* @param daqControl
|
||||
*/
|
||||
abstract public void stopSystem(AcquisitionControl daqControl);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @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
|
||||
* processed as fast as possible with no playback.
|
||||
*/
|
||||
abstract public boolean isRealTime();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @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 ?
|
||||
*
|
||||
* @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 ?
|
||||
*/
|
||||
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();
|
||||
|
||||
|
||||
/**
|
||||
* Gets a playback system for playing sound back out through headphones / speakers, etc.
|
||||
* <p>
|
||||
* 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
|
||||
* same sound card output, etc. At a later date, we may try to support output 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
|
||||
* 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 !
|
||||
* <p>
|
||||
* If data are being read from a file, then playback is through a sound card which sits
|
||||
* in a stand alone implementation of PlaybackSystem
|
||||
* @param playbackControl
|
||||
* @param daqSystem
|
||||
* in a stand alone implementation of PlaybackSystem
|
||||
* @param playbackControl
|
||||
* @param daqSystem
|
||||
* @return null if no playback available or a PlaybackSystem object.
|
||||
* @see PlaybackSystem
|
||||
* @see FilePlayback
|
||||
@ -203,7 +201,7 @@ public abstract class DaqSystem {
|
||||
*
|
||||
*/
|
||||
abstract public void daqHasEnded();
|
||||
|
||||
|
||||
public static final int STREAM_CLOSED = 0;
|
||||
public static final int STREAM_OPEN = 1;
|
||||
public static final int STREAM_RUNNING = 2;
|
||||
@ -220,36 +218,36 @@ public abstract class DaqSystem {
|
||||
public void setStreamStatus(int streamStatus) {
|
||||
this.streamStatus = streamStatus;
|
||||
}
|
||||
|
||||
|
||||
public boolean areSampleSettingsOk(int numInputsRequested, float sampleRateRequested){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void showSampleSettingsDialog(AcquisitionDialog acquisitionDialog){
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Component getStatusBarComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public boolean supportsChannelLists() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return a bitmap of output channels. this should ALWAYS be
|
||||
* 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) {
|
||||
return PamUtils.makeChannelMap(acquisitionParameters.nChannels);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a name for the acquisition device (may just be a number
|
||||
* but need to generalise).
|
||||
* but need to generalise).
|
||||
* @return
|
||||
*/
|
||||
public abstract String getDeviceName();
|
||||
@ -262,18 +260,18 @@ public abstract class DaqSystem {
|
||||
public double getChannelGain(int channel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of bits in each sample.
|
||||
* @return the number of bits in each sample.
|
||||
* Get the number of bits in each sample.
|
||||
* @return the number of bits in each sample.
|
||||
*/
|
||||
public int getSampleBits() {
|
||||
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() {
|
||||
return 2;
|
||||
@ -283,23 +281,23 @@ public abstract class DaqSystem {
|
||||
/**
|
||||
* Get a channel list panel (invented for NI cards which have many more options)
|
||||
* @param acquisitionDialog reference to main acquisition dialog
|
||||
* @return ChannelListPanel component.
|
||||
* @return ChannelListPanel component.
|
||||
*/
|
||||
public ChannelListPanel getDaqSpecificChannelListNode(AcquisitionPaneFX acquisitionPaneFX) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* name, gain settings, channel lists, whatever is available for the specific device
|
||||
* <p>
|
||||
* 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
|
||||
* number of channels.
|
||||
* number of channels.
|
||||
* <p>
|
||||
* @param acquisitionDialog the AcquisitionPaneFX this component will be added to
|
||||
* @return dialog component specific to this DAQ device
|
||||
@ -309,5 +307,5 @@ public abstract class DaqSystem {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,23 @@
|
||||
package Acquisition;
|
||||
|
||||
import PamModel.CommonPluginInterface;
|
||||
import PamModel.PamModel;
|
||||
import PamModel.PamModuleInfo;
|
||||
|
||||
/**
|
||||
* Interface for External DAQ Systems
|
||||
*
|
||||
*
|
||||
* @author MO
|
||||
*
|
||||
*/
|
||||
public interface DaqSystemInterface extends CommonPluginInterface {
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new instance of the DAQ System controller, the class that extends
|
||||
* DaqSystem.class. The AcquisitionControl object that gets passed to the
|
||||
* 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>
|
||||
* This field cannot be null.
|
||||
*
|
||||
*
|
||||
* @param the AcquisitionControl object
|
||||
* @return the DaqSystem object
|
||||
*/
|
||||
|
@ -15,11 +15,11 @@ import PamController.PamController;
|
||||
* 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
|
||||
* 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
|
||||
* type would potentially screw up those extended classes. That being said, the extended classes are
|
||||
* able to check for their types themselves.
|
||||
*
|
||||
*
|
||||
* @author dg50
|
||||
*
|
||||
*/
|
||||
@ -30,8 +30,8 @@ public class DaqSystemXMLManager {
|
||||
if (daqs == null) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < daqs.size(); i++) {
|
||||
AcquisitionControl daq = (AcquisitionControl) daqs.get(i);
|
||||
for (PamControlledUnit daq2 : daqs) {
|
||||
AcquisitionControl daq = (AcquisitionControl) daq2;
|
||||
AcquisitionParameters daqParams = daq.getAcquisitionParameters();
|
||||
if (daqParams.daqSystemType.equals(daqSystemType)) {
|
||||
return true;
|
||||
|
@ -16,14 +16,14 @@ import PamModel.parametermanager.PamParameterSet.ParameterSetType;
|
||||
public class FileInputParameters implements Serializable, Cloneable, ManagedParameters {
|
||||
|
||||
static public final long serialVersionUID = 1;
|
||||
|
||||
|
||||
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 String getMostRecentFile() {
|
||||
@ -34,21 +34,21 @@ public class FileInputParameters implements Serializable, Cloneable, ManagedPara
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String systemType;
|
||||
|
||||
|
||||
/**
|
||||
* 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 int bitDepth;
|
||||
|
||||
|
||||
/**
|
||||
* @param systemType
|
||||
*/
|
||||
@ -71,7 +71,7 @@ public class FileInputParameters implements Serializable, Cloneable, ManagedPara
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PamParameterSet getParameterSet() {
|
||||
// if the user has not selected this system type, just return null
|
||||
|
@ -7,8 +7,6 @@ import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -20,9 +18,9 @@ import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
import javax.sound.sampled.AudioFormat.Encoding;
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
import javax.sound.sampled.UnsupportedAudioFileException;
|
||||
import javax.sound.sampled.AudioFormat.Encoding;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
@ -32,33 +30,24 @@ import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
import org.jflac.FLACDecoder;
|
||||
import org.jflac.PCMProcessor;
|
||||
import org.jflac.frame.Frame;
|
||||
import org.jflac.metadata.StreamInfo;
|
||||
import org.jflac.sound.spi.FlacEncoding;
|
||||
import org.jflac.util.ByteData;
|
||||
import org.pamguard.x3.sud.Chunk;
|
||||
import org.pamguard.x3.sud.SudAudioInputStream;
|
||||
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.FileDateDialogStrip;
|
||||
import Acquisition.filedate.FileDateObserver;
|
||||
import Acquisition.filetypes.SoundFileType;
|
||||
import Acquisition.pamAudio.PamAudioFileManager;
|
||||
import Acquisition.pamAudio.PamAudioFileFilter;
|
||||
import Acquisition.pamAudio.PamAudioFileManager;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
import PamController.PamController;
|
||||
import PamController.PamSettingManager;
|
||||
@ -73,9 +62,19 @@ import PamView.panel.PamProgressBar;
|
||||
import pamguard.GlobalArguments;
|
||||
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
|
||||
* @see Acquisition.DaqSystem
|
||||
* @see Acquisition.AcquisitionProcess
|
||||
@ -109,7 +108,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
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;
|
||||
|
||||
@ -148,14 +147,14 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
protected ByteConverter byteConverter;
|
||||
|
||||
protected FileDateDialogStrip fileDateStrip;
|
||||
|
||||
|
||||
/**
|
||||
* Sound file types present in the current selections.
|
||||
*/
|
||||
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;
|
||||
|
||||
@ -186,7 +185,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
|
||||
/**
|
||||
* Gets and where necessary creates ...
|
||||
* @return Daq dialog panel.
|
||||
* @return Daq dialog panel.
|
||||
*/
|
||||
protected JPanel getDialogPanel() {
|
||||
if (daqDialog == null) {
|
||||
@ -217,7 +216,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
constraints.fill = GridBagConstraints.NONE;
|
||||
constraints.anchor = GridBagConstraints.WEST;
|
||||
constraints.gridx = 0;
|
||||
addComponent(p, repeat = new JCheckBox("Repeat"), constraints);
|
||||
addComponent(p, repeat = new JCheckBox("Repeat"), constraints);
|
||||
constraints.gridx = 2;
|
||||
constraints.gridy = 1;
|
||||
constraints.gridwidth = 1;
|
||||
@ -234,7 +233,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
p.add(fileDateStrip.getDialogComponent(), constraints);
|
||||
|
||||
// if (SMRUEnable.isEnable()) {
|
||||
// no reason to hide this option from users.
|
||||
// no reason to hide this option from users.
|
||||
constraints.gridy++;
|
||||
constraints.gridx = 0;
|
||||
constraints.gridwidth = 1;
|
||||
@ -287,8 +286,8 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
fileNameCombo.removeAllItems();
|
||||
String file;
|
||||
if (fileInputParameters.recentFiles.size() == 0) return;
|
||||
for (int i = 0; i < fileInputParameters.recentFiles.size(); i++){
|
||||
file = fileInputParameters.recentFiles.get(i);
|
||||
for (String element : fileInputParameters.recentFiles) {
|
||||
file = element;
|
||||
if (file == null || file.length() == 0) continue;
|
||||
fileNameCombo.addItem(file);
|
||||
}
|
||||
@ -301,7 +300,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
if (file != null && file.length() > 0) {
|
||||
fileInputParameters.recentFiles.remove(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) {
|
||||
fileInputParameters.recentFiles.remove(fileInputParameters.recentFiles.size()-1);
|
||||
fileInputParameters.recentFiles.trimToSize();
|
||||
@ -317,11 +316,11 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
|
||||
if (skipSecondsField!=null) {
|
||||
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();
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -335,13 +334,13 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
|
||||
@Override
|
||||
public String getSystemName() {
|
||||
if (fileInputParameters.recentFiles == null) return null;
|
||||
if (fileInputParameters.recentFiles.size() < 1) return null;
|
||||
if ((fileInputParameters.recentFiles == null) || (fileInputParameters.recentFiles.size() < 1)) return null;
|
||||
File f = getCurrentFile();
|
||||
if (f == null) return null;
|
||||
return f.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
if (e.getSource() == fileSelect) {
|
||||
@ -374,8 +373,8 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
javax.swing.filechooser.FileFilter[] filters = fileChooser
|
||||
.getChoosableFileFilters();
|
||||
for (int i = 0; i < filters.length; i++) {
|
||||
fileChooser.removeChoosableFileFilter(filters[i]);
|
||||
for (FileFilter filter : filters) {
|
||||
fileChooser.removeChoosableFileFilter(filter);
|
||||
}
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public void interpretNewFile(String newFile){
|
||||
if (newFile == null) return;
|
||||
if (newFile.length() == 0) return;
|
||||
if ((newFile == null) || (newFile.length() == 0)) return;
|
||||
|
||||
File file = new File(newFile);
|
||||
|
||||
|
||||
setSelectedFileTypes(acquisitionControl.soundFileTypes.getUsedTypes(file));
|
||||
|
||||
|
||||
if (file == null) return;
|
||||
|
||||
// try to work out the date of the file
|
||||
@ -430,13 +428,13 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
// acquisitionDialog.NotifyChange();
|
||||
if (file.isFile() && !file.isHidden() && acquisitionDialog != null) {
|
||||
try {
|
||||
|
||||
System.out.println("FileInputSystem - interpretNewFile");
|
||||
|
||||
System.out.println("FileInputSystem - interpretNewFile");
|
||||
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())) {
|
||||
// WavHeader wavHeader = ((WavFileInputStream) audioStream).getWavHeader();
|
||||
// WavHeader wavHeader = ((WavFileInputStream) audioStream).getWavHeader();
|
||||
// int nChunks = wavHeader.getNumHeadChunks();
|
||||
// for (int i = 0; i < nChunks; i++) {
|
||||
// WavHeadChunk aChunk = wavHeader.getHeadChunk(i);
|
||||
@ -447,7 +445,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
if (audioStream instanceof SudAudioInputStream) {
|
||||
acquisitionControl.getSUDNotificationManager().interpretNewFile(newFile, (SudAudioInputStream) audioStream);
|
||||
}
|
||||
|
||||
|
||||
AudioFormat audioFormat = audioStream.getFormat();
|
||||
// fileLength = file.length();
|
||||
fileSamples = audioStream.getFrameLength();
|
||||
@ -473,7 +471,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
super.setStreamStatus(streamStatus);
|
||||
// file has ended, so notify the daq control.
|
||||
if (streamStatus == STREAM_ENDED) {
|
||||
// tell the rest of PAMGUARD to stop.
|
||||
// tell the rest of PAMGUARD to stop.
|
||||
PamController.getInstance().stopLater();
|
||||
}
|
||||
}
|
||||
@ -511,24 +509,29 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getSettingsReference() {
|
||||
return fileInputParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSettingsVersion() {
|
||||
return FileInputParameters.serialVersionUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnitName() {
|
||||
// return "File Input System";
|
||||
return acquisitionControl.getUnitName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnitType() {
|
||||
// return "Acquisition System";
|
||||
return "File Input System";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
|
||||
// if (PamSettingManager.getInstance().isSettingsUnit(this, pamControlledUnitSettings)) {
|
||||
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.size() < 1) return false;
|
||||
// String fileName = fileInputParameters.recentFiles.get(0);
|
||||
if (runFileAnalysis() == false) {
|
||||
if (!runFileAnalysis()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public File getCurrentFile() {
|
||||
// System.out.println("fileInputParameters: " + fileInputParameters);
|
||||
if (fileInputParameters.recentFiles == null) return null;
|
||||
if (fileInputParameters.recentFiles.size() < 1) return null;
|
||||
// System.out.println("fileInputParameters: " + fileInputParameters);
|
||||
if ((fileInputParameters.recentFiles == null) || (fileInputParameters.recentFiles.size() < 1)) return null;
|
||||
String fileName = fileInputParameters.recentFiles.get(0);
|
||||
return new File(fileName);
|
||||
}
|
||||
@ -585,8 +587,8 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the audio stream for processing.
|
||||
* @return true if audio stream opened correctly.
|
||||
* Open the audio stream for processing.
|
||||
* @return true if audio stream opened correctly.
|
||||
*/
|
||||
public boolean prepareInputFile() {
|
||||
|
||||
@ -603,7 +605,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
audioStream.close();
|
||||
}
|
||||
|
||||
// System.out.println("FileInputSystem - prepareInputFile");
|
||||
// System.out.println("FileInputSystem - prepareInputFile");
|
||||
|
||||
audioStream = PamAudioFileManager.getInstance().getAudioInputStream(currentFile);
|
||||
|
||||
@ -627,8 +629,8 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
audioFormat = audioStream.getFormat();
|
||||
|
||||
if (audioFormat==null) {
|
||||
System.err.println("AudioFormat was null: " + currentFile.getAbsolutePath());
|
||||
return false;
|
||||
System.err.println("AudioFormat was null: " + currentFile.getAbsolutePath());
|
||||
return false;
|
||||
}
|
||||
|
||||
// fileLength = currentFile.length();
|
||||
@ -639,8 +641,8 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
fileInputParameters.bitDepth = audioFormat.getSampleSizeInBits();
|
||||
|
||||
loadByteConverter(audioFormat);
|
||||
|
||||
// System.out.println("FileInputSystem - prepareInputFile done");
|
||||
|
||||
// System.out.println("FileInputSystem - prepareInputFile done");
|
||||
|
||||
|
||||
} catch (UnsupportedAudioFileException ex) {
|
||||
@ -652,7 +654,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -671,7 +673,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
this.newDataUnits = acquisitionControl.getDaqProcess().getNewDataQueue();
|
||||
|
||||
// if (this.newDataUnits == null) {
|
||||
// System.err.println("newDataUnits: == null: ");
|
||||
// System.err.println("newDataUnits: == null: ");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
@ -679,7 +681,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
|
||||
String audioFileStr = getCurrentFile()==null? "Null File": getCurrentFile().getAbsolutePath();
|
||||
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 +
|
||||
"</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>";
|
||||
@ -707,9 +709,9 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
|
||||
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();
|
||||
@ -733,11 +735,11 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpret the file name to get the file time.
|
||||
* <p>Moved to a separate function so it can be overridden in a special version
|
||||
* for the DCL5 data set.
|
||||
* @param file audio file.
|
||||
* @return time in milliseconds.
|
||||
* Interpret the file name to get the file time.
|
||||
* <p>Moved to a separate function so it can be overridden in a special version
|
||||
* for the DCL5 data set.
|
||||
* @param file audio file.
|
||||
* @return time in milliseconds.
|
||||
*/
|
||||
public long getFileStartTime(File file) {
|
||||
// if there is no file, return 0
|
||||
@ -749,11 +751,11 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
public boolean startSystem(AcquisitionControl daqControl) {
|
||||
|
||||
|
||||
|
||||
|
||||
if (audioStream == null) return false;
|
||||
|
||||
dontStop = true;
|
||||
|
||||
|
||||
fullyStopped = false;
|
||||
|
||||
theThread.start();
|
||||
@ -767,7 +769,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
public void stopSystem(AcquisitionControl daqControl) {
|
||||
/*
|
||||
* 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);
|
||||
|
||||
@ -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
|
||||
* that it needs to use it's own reader.
|
||||
* that it needs to use it's own reader.
|
||||
*/
|
||||
protected void collectFlacData() {
|
||||
FileInputStream fileStream;
|
||||
@ -875,7 +877,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
|
||||
@Override
|
||||
public void processPCM(ByteData byteData) {
|
||||
if (dontStop == false) {
|
||||
if (!dontStop) {
|
||||
try {
|
||||
fileStream.close(); // will make the flac reader bomb out !
|
||||
}
|
||||
@ -914,7 +916,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
sayEta();
|
||||
long now = System.currentTimeMillis();
|
||||
if (lastProgressTime > 0 && totalSamples > lastProgressUpdate) {
|
||||
double speed = (double) (totalSamples - lastProgressUpdate) /
|
||||
double speed = (double) (totalSamples - lastProgressUpdate) /
|
||||
getSampleRate() / ((now-lastProgressTime)/1000.);
|
||||
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) {
|
||||
if (dontStop == false) break;
|
||||
if (!dontStop) break;
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (Exception ex) {
|
||||
@ -943,6 +945,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
|
||||
public class CollectorThread implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (audioFormat.getEncoding() == FlacEncoding.FLAC) {
|
||||
collectFlacData();
|
||||
@ -985,9 +988,9 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
break; // file read error
|
||||
}
|
||||
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
|
||||
// samples from the next file.
|
||||
// samples from the next file.
|
||||
if (bytesRead == -1) {
|
||||
bytesRead = 0;
|
||||
}
|
||||
@ -1009,7 +1012,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
}
|
||||
if (bytesRead > 0) {
|
||||
// convert byte array to set of double arrays, one per
|
||||
// channel
|
||||
// channel
|
||||
newSamples = bytesRead / audioFormat.getFrameSize();
|
||||
doubleData = new double[nChannels][newSamples];
|
||||
int convertedSamples = byteConverter.bytesToDouble(byteArray, doubleData, bytesRead);
|
||||
@ -1038,7 +1041,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
sayEta();
|
||||
long now = System.currentTimeMillis();
|
||||
if (lastProgressTime > 0 && totalSamples > lastProgressUpdate) {
|
||||
double speed = (double) (totalSamples - lastProgressUpdate) /
|
||||
double speed = (double) (totalSamples - lastProgressUpdate) /
|
||||
getSampleRate() / ((now-lastProgressTime)/1000.);
|
||||
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.
|
||||
*/
|
||||
while (newDataUnits.getQueueSize() > 3*nChannels) {
|
||||
if (dontStop == false) break;
|
||||
if (!dontStop) break;
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (Exception ex) {
|
||||
@ -1062,7 +1065,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
totalSamples += newSamples;
|
||||
readFileSamples += newSamples;
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
break; // end of file
|
||||
}
|
||||
@ -1079,10 +1082,10 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
}
|
||||
}
|
||||
// note the reason why the file has ended.
|
||||
if (dontStop == false) { // stop button pressed
|
||||
if (!dontStop) { // stop button pressed
|
||||
setStreamStatus(STREAM_PAUSED);
|
||||
}
|
||||
else { // file ended, since dont stop is true.
|
||||
else { // file ended, since dont stop is true.
|
||||
setStreamStatus(STREAM_ENDED);
|
||||
}
|
||||
//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.
|
||||
* @param totalSamples
|
||||
* @return
|
||||
*/
|
||||
protected boolean openNextFile(long totalSamples) {
|
||||
if (fileInputParameters.repeatLoop == false) {
|
||||
if (!fileInputParameters.repeatLoop) {
|
||||
return false;
|
||||
}
|
||||
// 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.
|
||||
*/
|
||||
public static double[] bytesToSamples(byte[] byteArray, long nBytes, int channel,
|
||||
AudioFormat audioFormat)
|
||||
AudioFormat audioFormat)
|
||||
{
|
||||
int nSamples = (int)(nBytes / audioFormat.getFrameSize());
|
||||
double[] samples = new double[nSamples];
|
||||
@ -1120,7 +1123,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
int bytesPerSample = ((audioFormat.getSampleSizeInBits() + 7) / 8);
|
||||
int byteI = channel * bytesPerSample;
|
||||
for (int isamp = 0; isamp < nSamples; isamp++) {
|
||||
samples[isamp] =
|
||||
samples[isamp] =
|
||||
getSample(byteArray, byteI, bytesPerSample, audioFormat.isBigEndian());
|
||||
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() {
|
||||
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
|
||||
* @return the acquisition control.
|
||||
* @return the acquisition control.
|
||||
*/
|
||||
public AcquisitionControl getAquisitionControl() {
|
||||
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
|
||||
* 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
|
||||
*/
|
||||
public void setSelectedFileTypes(List<SoundFileType> selectedFileTypes) {
|
||||
|
@ -7,7 +7,6 @@ import java.lang.reflect.Field;
|
||||
import PamModel.parametermanager.ManagedParameters;
|
||||
import PamModel.parametermanager.PamParameterSet;
|
||||
import PamModel.parametermanager.PrivatePamParameterData;
|
||||
import simulatedAcquisition.SimProcess;
|
||||
|
||||
/**
|
||||
* Control parameters for FolderInputSystem
|
||||
@ -18,11 +17,11 @@ import simulatedAcquisition.SimProcess;
|
||||
public class FolderInputParameters extends FileInputParameters implements Serializable, Cloneable, ManagedParameters {
|
||||
|
||||
static public final long serialVersionUID = 1;
|
||||
|
||||
|
||||
public boolean subFolders;
|
||||
|
||||
|
||||
public boolean mergeFiles;
|
||||
|
||||
|
||||
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()
|
||||
* @return List of file paths in String format.
|
||||
* @return List of file paths in String format.
|
||||
*/
|
||||
public String[] getSelectedFiles() {
|
||||
return selectedFileNames;
|
||||
@ -53,7 +52,7 @@ public class FolderInputParameters extends FileInputParameters implements Serial
|
||||
public void setSelectedFiles(String[] selectedFiles) {
|
||||
this.selectedFileNames = selectedFiles;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -69,11 +68,11 @@ public class FolderInputParameters extends FileInputParameters implements Serial
|
||||
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
|
||||
* @return list of selected files.
|
||||
* @return list of selected files.
|
||||
*/
|
||||
public File[] getSelectedFileFiles() {
|
||||
if (selectedFileNames == null) {
|
||||
|
@ -24,16 +24,14 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.Timer;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import Acquisition.filedate.FileDateDialogStrip;
|
||||
import Acquisition.layoutFX.AcquisitionPaneFX;
|
||||
import Acquisition.layoutFX.DAQSettingsPane;
|
||||
import Acquisition.layoutFX.FolderInputPane;
|
||||
import javafx.application.Platform;
|
||||
import pamguard.GlobalArguments;
|
||||
import Acquisition.pamAudio.PamAudioFileManager;
|
||||
import Acquisition.pamAudio.PamAudioFileFilter;
|
||||
import Acquisition.pamAudio.PamAudioFileLoader;
|
||||
import Acquisition.pamAudio.PamAudioSystem;
|
||||
import Acquisition.pamAudio.PamAudioFileManager;
|
||||
import PamController.DataInputStore;
|
||||
import PamController.InputStoreInfo;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
@ -52,12 +50,14 @@ import PamView.dialog.PamLabel;
|
||||
import PamView.panel.PamPanel;
|
||||
import PamView.panel.PamProgressBar;
|
||||
import PamguardMVC.debug.Debug;
|
||||
import javafx.application.Platform;
|
||||
import pamguard.GlobalArguments;
|
||||
|
||||
/**
|
||||
* Read multiple files in sequence. Options exist to either pause and
|
||||
* restart analysis after each file, or to merge files into one long
|
||||
* continuous sound stream.
|
||||
*
|
||||
*
|
||||
* @author Doug Gillespie
|
||||
*
|
||||
*/
|
||||
@ -70,7 +70,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
|
||||
private boolean running = false;
|
||||
|
||||
protected ArrayList<WavFileType> allFiles = new ArrayList<WavFileType>();
|
||||
protected ArrayList<WavFileType> allFiles = new ArrayList<>();
|
||||
|
||||
protected int currentFile;
|
||||
|
||||
@ -85,18 +85,18 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
protected long eta = -1;
|
||||
|
||||
private FolderInputParameters folderInputParameters;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@ -109,11 +109,11 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
@Override
|
||||
public boolean 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());
|
||||
/*
|
||||
* 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();
|
||||
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() {
|
||||
String globalFolder = GlobalArguments.getParam(GlobalWavFolderArg);
|
||||
@ -146,28 +146,29 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
if (globalFolder == 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);
|
||||
if (aFile.exists() == false) {
|
||||
if (!aFile.exists()) {
|
||||
System.err.printf("Command line wav folder \"%s\" does not exist", globalFolder);
|
||||
// return null;
|
||||
}
|
||||
String[] selList = {globalFolder};
|
||||
// folderInputParameters.setSelectedFiles(selList);
|
||||
// need to immediately make the allfiles list since it's about to get used by the reprocess manager
|
||||
// need to worry about how to wait for this since it's starting in a different thread.
|
||||
// need to worry about how to wait for this since it's starting in a different thread.
|
||||
//makeSelFileList();
|
||||
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
|
||||
* @author Doug Gillespie
|
||||
*
|
||||
*/
|
||||
class RestartTimer implements ActionListener {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
// System.out.println("Restart later time action");
|
||||
@ -177,8 +178,8 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected JPanel createDaqDialogPanel() {
|
||||
JPanel p = new JPanel();
|
||||
@ -247,7 +248,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
}
|
||||
|
||||
// if (SMRUEnable.isEnable()) {
|
||||
// no reason to hide this option from users.
|
||||
// no reason to hide this option from users.
|
||||
constraints.gridy++;
|
||||
constraints.gridx = 0;
|
||||
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.gridx = 0;
|
||||
constraints.gridy++;
|
||||
@ -271,7 +272,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
class FileComboListener implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
@ -292,12 +293,12 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
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() {
|
||||
CheckWavFileHeaders.showDialog(acquisitionDialog, this);
|
||||
@ -306,13 +307,14 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
|
||||
class FindAudioFolder implements ActionListener {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
selectFolder();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
* of actual files in a folder. Also needs to handle the possibility of it using
|
||||
* a globally set folder name.
|
||||
* Make a list of wav files within a folder. In some circumstances this can be a list
|
||||
* of actual files in a folder. Also needs to handle the possibility of it using
|
||||
* a globally set folder name.
|
||||
* @return flag to indicate...nothing?
|
||||
*/
|
||||
public int makeSelFileList() {
|
||||
|
||||
String[] selection = checkComandLineFolder();
|
||||
|
||||
|
||||
if (selection == null) {
|
||||
if (fileInputParameters.recentFiles == null || fileInputParameters.recentFiles.size() < 1) {
|
||||
return 0;
|
||||
@ -346,9 +348,9 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
}
|
||||
return makeSelFileList(selection);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make a list of wav files within a folder.
|
||||
* Make a list of wav files within a folder.
|
||||
* @param rootList
|
||||
* @return
|
||||
*/
|
||||
@ -356,22 +358,22 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
// File[] selectedFiles = folderInputParameters.getSelectedFiles();
|
||||
// if (selectedFiles.length == 1 && selectedFiles[0].isDirectory()) {
|
||||
// String folderName = fileInputParameters.recentFiles.get(0);
|
||||
|
||||
|
||||
//Swing calls a dialog with progress bar from the wavListWorker
|
||||
wavListStart = System.currentTimeMillis();
|
||||
|
||||
|
||||
if (folderInputPane==null) {
|
||||
//Swing way
|
||||
wavListWorker.startFileListProcess(PamController.getMainFrame(), rootList,
|
||||
wavListWorker.startFileListProcess(PamController.getMainFrame(), rootList,
|
||||
folderInputParameters.subFolders, true);
|
||||
}
|
||||
else {
|
||||
//FX system
|
||||
PamWorker<FileListData<WavFileType>> worker = wavListWorker.makeFileListProcess(rootList, folderInputParameters.subFolders, true);
|
||||
folderInputPane.setFileWorker(worker);
|
||||
if (worker!=null) worker.start();
|
||||
PamWorker<FileListData<WavFileType>> worker = wavListWorker.makeFileListProcess(rootList, folderInputParameters.subFolders, true);
|
||||
folderInputPane.setFileWorker(worker);
|
||||
if (worker!=null) worker.start();
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -413,7 +415,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
// folderProgress.setValue(0);
|
||||
//
|
||||
// Collections.sort(allFiles);
|
||||
//
|
||||
//
|
||||
// return allFiles.size();
|
||||
//
|
||||
// }
|
||||
@ -463,9 +465,9 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
|
||||
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
|
||||
* are accepted, select the parent directory of all of them.
|
||||
* are accepted, select the parent directory of all of them.
|
||||
*/
|
||||
File[] files = fc.getSelectedFiles();
|
||||
if (files.length <= 0) return;
|
||||
@ -477,12 +479,12 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
File aFile = files[0];
|
||||
setNewFile(aFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The file chooser is returning sub classes of File which are not
|
||||
* serialisable, so we can't use them. We need to convert their
|
||||
* names to strings, which can be safely serialized. This will
|
||||
* serialisable, so we can't use them. We need to convert their
|
||||
* names to strings, which can be safely serialized. This will
|
||||
* all happen in FolderInputParameters.
|
||||
*/
|
||||
folderInputParameters.setSelectedFiles(fc.getSelectedFiles());
|
||||
@ -500,12 +502,12 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
}
|
||||
|
||||
long wavListStart;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a list of wav files.
|
||||
* Creates a list of wav files.
|
||||
*/
|
||||
WavListWorker wavListWorker = new WavListWorker(new WavListReceiver());
|
||||
|
||||
|
||||
private class WavListReceiver implements WavListUser {
|
||||
|
||||
@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
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// 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
|
||||
*/
|
||||
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);
|
||||
allFiles = fileListData.getListCopy();
|
||||
|
||||
|
||||
List<WavFileType> asList = allFiles;
|
||||
setSelectedFileTypes(acquisitionControl.soundFileTypes.getUsedTypes(allFiles));
|
||||
|
||||
//set the date of the first file.
|
||||
//set the date of the first file.
|
||||
setFileDateText();
|
||||
|
||||
//set any bespoke options for the files to be laoded.
|
||||
|
||||
//set any bespoke options for the files to be laoded.
|
||||
setFileOptionPanel();
|
||||
|
||||
|
||||
// also open up the first file and get the sample rate and number of channels from it
|
||||
// and set these
|
||||
File file = getCurrentFile();
|
||||
if (file == null) return;
|
||||
AudioInputStream audioStream;
|
||||
|
||||
|
||||
AudioInputStream audioStream;
|
||||
|
||||
|
||||
/****Swing GUI stuff****/
|
||||
if (file.isFile() && !file.isHidden() && acquisitionDialog != null) {
|
||||
//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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// set the min and max of the folder progress bar
|
||||
folderProgress.setMinimum(0);
|
||||
folderProgress.setMaximum(allFiles.size());
|
||||
|
||||
|
||||
/****FX GUI stuff****/
|
||||
if (folderInputPane!=null) {
|
||||
Platform.runLater(()->{
|
||||
folderInputPane.newFileList(fileListData);
|
||||
folderInputPane.newFileList(fileListData);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fudge function so that the RonaInputsystem can always fudge the number
|
||||
* of channels to be 7.
|
||||
* of channels to be 7.
|
||||
* @param nChannels
|
||||
* @return
|
||||
*/
|
||||
protected int fudgeNumChannels(int nChannels) {
|
||||
return nChannels;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set bespoke options for certain file types.
|
||||
* Set bespoke options for certain file types.
|
||||
*/
|
||||
public void setFileOptionPanel() {
|
||||
getDialogPanel(); // make sure panel is created
|
||||
@ -606,8 +608,8 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
audioLoaderHolder.removeAll();
|
||||
|
||||
if (allFiles.size() > 0) {
|
||||
//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.
|
||||
//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.
|
||||
ArrayList<PamAudioFileLoader> loaders = PamAudioFileManager.getInstance().getAudioFileLoaders(allFiles);
|
||||
|
||||
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() {
|
||||
if (allFiles.size() > 0) {
|
||||
@ -670,9 +672,9 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
@Override
|
||||
protected boolean openNextFile(long totalSamples) {
|
||||
boolean ans = false;
|
||||
if (folderInputParameters.mergeFiles == false) return false;
|
||||
|
||||
|
||||
if (!folderInputParameters.mergeFiles) return false;
|
||||
|
||||
|
||||
long currFileStart = 0;
|
||||
long currFileLength = 0;
|
||||
long currFileEnd = 0;
|
||||
@ -692,7 +694,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
}
|
||||
if (currFileEnd == 0) {
|
||||
// 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.
|
||||
currFileEnd = PamCalendar.getTimeInMillis();
|
||||
long lastBit = (long) ((blockSamples * 1000L) / getSampleRate());
|
||||
@ -705,22 +707,22 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
currentFile--;
|
||||
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
|
||||
* counter will increment elsewhere.
|
||||
* counter will increment elsewhere.
|
||||
*/
|
||||
}
|
||||
setFolderProgress();
|
||||
// sayEta();
|
||||
/*
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* itself if we use the super.prep ....
|
||||
* being called, if false is returned it should manage moving onto the next file by
|
||||
* itself if we use the super.prep ....
|
||||
*/
|
||||
ans = super.prepareInputFile();
|
||||
if (ans == false) {
|
||||
if (!ans) {
|
||||
return false;
|
||||
}
|
||||
currentFileStart = System.currentTimeMillis();
|
||||
@ -728,11 +730,11 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
// 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,
|
||||
totalSamples, null, "NextFile", "File End",
|
||||
acquisitionControl.acquisitionParameters, getSystemName(), totalSamples/getSampleRate(), 0);
|
||||
DaqStatusDataUnit daqStatusDataUnit = new DaqStatusDataUnit(currentFileStart, currentFileStart, currentFileStart,
|
||||
totalSamples, null, "NextFile", "File End",
|
||||
acquisitionControl.acquisitionParameters, getSystemName(), totalSamples/getSampleRate(), 0);
|
||||
acquisitionControl.getAcquisitionProcess().getDaqStatusDataBlock().addPamData(daqStatusDataUnit);
|
||||
}
|
||||
return ans;
|
||||
@ -746,14 +748,14 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
}
|
||||
if (currentFile < allFiles.size()) {
|
||||
// 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()));
|
||||
newFileTimer.start();
|
||||
}
|
||||
}
|
||||
calculateETA();
|
||||
setFolderProgress();
|
||||
|
||||
|
||||
if (currentFile > 0 && currentFile >= allFiles.size()) {
|
||||
fileListComplete();
|
||||
}
|
||||
@ -776,7 +778,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
PamProgressBar folderProgress = new PamProgressBar(PamProgressBar.defaultColor);
|
||||
|
||||
private FolderInputPane folderInputPane;
|
||||
|
||||
|
||||
@Override
|
||||
public Component getStatusBarComponent() {
|
||||
|
||||
@ -817,24 +819,24 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
currentFile = 0;
|
||||
if (skipSecondsField!=null) {
|
||||
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();
|
||||
}
|
||||
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);
|
||||
|
||||
|
||||
|
||||
for (PamAudioFileLoader loader : loaders) {
|
||||
if (loader.getSettingsPane()!=null) {
|
||||
loader.getSettingsPane().getParams();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
// whether or not to include the parameters in the XML output
|
||||
if (fileInputParameters.systemType==null) fileInputParameters.systemType=getSystemType();
|
||||
|
||||
|
||||
super.dialogSetParams();
|
||||
subFolders.setSelected(folderInputParameters.subFolders);
|
||||
mergeFiles.setSelected(folderInputParameters.mergeFiles);
|
||||
@ -853,7 +855,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
if (skipSecondsField!=null) {
|
||||
skipSecondsField.setText(String.format("%.1f", fileInputParameters.skipStartFileTime/1000.));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -918,14 +920,15 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
|
||||
/****JavaFX bits***/
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by AcquisitionDialog.SetParams so that the dialog node can update it's
|
||||
* fields.
|
||||
* fields.
|
||||
*/
|
||||
public void dialogFXSetParams() {
|
||||
folderInputPane.setParams(folderInputParameters);
|
||||
@ -933,7 +936,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
|
||||
@Override
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
@ -963,12 +966,12 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
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.setFileStartTimes(allFileStarts);
|
||||
storeInfo.setFileEndTimes(allFileEnds);
|
||||
}
|
||||
System.out.println("FolderInputSystem: Get store info complete:");
|
||||
System.out.println("FolderInputSystem: Get store info complete:");
|
||||
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
|
||||
* 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
|
||||
* processing will continue from there.
|
||||
* so all we have to do (in principle) is to set the currentfile to that index and
|
||||
* processing will continue from there.
|
||||
*/
|
||||
if (allFiles == null || allFiles.size() == 0) {
|
||||
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));
|
||||
/*
|
||||
* 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());
|
||||
if (startTime > lastFileTime) {
|
||||
@ -1008,13 +1011,14 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a status update for batch processing.
|
||||
* Get a status update for batch processing.
|
||||
*/
|
||||
@Override
|
||||
public String getBatchStatus() {
|
||||
int nFiles = 0;
|
||||
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);
|
||||
return bs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -10,18 +10,18 @@ public class KETime {
|
||||
|
||||
|
||||
/**
|
||||
* Unpack the KE buoy data format. This has a decimal number of
|
||||
* seconds, but is otherwise quite rational.
|
||||
* Unpack the KE buoy data format. This has a decimal number of
|
||||
* seconds, but is otherwise quite rational.
|
||||
* @param numPart - the date string
|
||||
* @return time in millis
|
||||
*/
|
||||
public static long getKEBuoyTime(String numPart) {
|
||||
int dotPos = numPart.indexOf('.', 0);
|
||||
|
||||
|
||||
if (dotPos < 0) {
|
||||
return Long.MIN_VALUE;
|
||||
}
|
||||
|
||||
|
||||
String mainBit = numPart.substring(0, dotPos);
|
||||
String fracPart = numPart.substring(dotPos);
|
||||
String fmt = "yyyyMMdd_HHmmss";
|
||||
@ -42,32 +42,32 @@ public class KETime {
|
||||
cl.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
cl.setTime(d);
|
||||
long millis = cl.getTimeInMillis();
|
||||
|
||||
|
||||
try {
|
||||
double fracBit = Double.valueOf(fracPart);
|
||||
millis += (long) (fracBit*1000.);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
return millis;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return time in millis
|
||||
*/
|
||||
public static long getPLABuoyTime(String numPart) {
|
||||
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){
|
||||
return Long.MIN_VALUE;
|
||||
}
|
||||
|
||||
|
||||
String mainBit = timeSections[0]+timeSections[1];
|
||||
String fracPart = timeSections[2];
|
||||
String fmt = "yyyyMMddHHmmss";
|
||||
@ -88,13 +88,13 @@ public class KETime {
|
||||
cl.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
cl.setTime(d);
|
||||
long millis = cl.getTimeInMillis();
|
||||
|
||||
|
||||
try {
|
||||
double fracBit = Double.valueOf(fracPart);
|
||||
millis += (long) (fracBit/1000.);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
return millis;
|
||||
|
@ -8,24 +8,21 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import PamDetection.RawDataUnit;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import PamguardMVC.PamRawDataBlock;
|
||||
import binaryFileStorage.BinaryDataSource;
|
||||
import binaryFileStorage.BinaryHeader;
|
||||
import binaryFileStorage.BinaryObjectData;
|
||||
import binaryFileStorage.BinaryOutputStream;
|
||||
import binaryFileStorage.ModuleFooter;
|
||||
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
|
||||
* for that. The purpose of this class is to enable sending of
|
||||
* 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
|
||||
* are in use within PAMGUARD.
|
||||
* for that. The purpose of this class is to enable sending of
|
||||
* 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
|
||||
* are in use within PAMGUARD.
|
||||
* @author Doug Gillespie
|
||||
*
|
||||
*/
|
||||
@ -35,7 +32,7 @@ public class RawDataBinaryDataSource extends BinaryDataSource {
|
||||
private ByteArrayOutputStream bos;
|
||||
private DataOutputStream dos;
|
||||
private long offsetSamples;
|
||||
|
||||
|
||||
public RawDataBinaryDataSource(PamRawDataBlock sisterDataBlock) {
|
||||
super(sisterDataBlock);
|
||||
setDoBinaryStore(false);
|
||||
@ -72,8 +69,8 @@ public class RawDataBinaryDataSource extends BinaryDataSource {
|
||||
@Override
|
||||
public BinaryObjectData getPackedData(PamDataUnit pamDataUnit) {
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
RawDataUnit rawDataUnit = (RawDataUnit) pamDataUnit;
|
||||
int duration = rawDataUnit.getSampleDuration().intValue();
|
||||
@ -98,14 +95,14 @@ public class RawDataBinaryDataSource extends BinaryDataSource {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return new BinaryObjectData(0, bos.toByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PamDataUnit sinkData(BinaryObjectData binaryObjectData,
|
||||
BinaryHeader bh, int moduleVersion) {
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(binaryObjectData.getData(),
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(binaryObjectData.getData(),
|
||||
0, binaryObjectData.getDataLength());
|
||||
DataInputStream dis = new DataInputStream(bis);
|
||||
long startSample;
|
||||
@ -117,15 +114,15 @@ public class RawDataBinaryDataSource extends BinaryDataSource {
|
||||
try {
|
||||
startSample = dis.readLong();
|
||||
/*
|
||||
* Muck a bit with the timing so that within this network received
|
||||
* data, sample counts get restarted at 0. This will ensure that
|
||||
* millisecond and ADC count timings end up about right for the data.
|
||||
* Muck a bit with the timing so that within this network received
|
||||
* data, sample counts get restarted at 0. This will ensure that
|
||||
* millisecond and ADC count timings end up about right for the data.
|
||||
*/
|
||||
if (offsetSamples == 0) {
|
||||
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();
|
||||
duration = dis.readInt();
|
||||
nBytes = dis.readByte();
|
||||
@ -142,8 +139,8 @@ public class RawDataBinaryDataSource extends BinaryDataSource {
|
||||
}
|
||||
|
||||
RawDataUnit rawDataUnit = new RawDataUnit(binaryObjectData.getTimeMilliseconds(), channelMap, startSample, duration);
|
||||
rawDataUnit.setRawData(rawData, true);
|
||||
// System.out.println("raw data arrived to unpack on channels " +
|
||||
rawDataUnit.setRawData(rawData, true);
|
||||
// System.out.println("raw data arrived to unpack on channels " +
|
||||
// channelMap + " sample " + startSample);
|
||||
return rawDataUnit;
|
||||
}
|
||||
|
@ -10,11 +10,9 @@ import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
import javax.sound.sampled.AudioFormat.Encoding;
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
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.PCMProcessor;
|
||||
@ -25,27 +23,26 @@ import org.jflac.PCMProcessor;
|
||||
import org.jflac.metadata.StreamInfo;
|
||||
import org.jflac.util.ByteData;
|
||||
|
||||
import wavFiles.ByteConverter;
|
||||
import Acquisition.pamAudio.PamAudioFileManager;
|
||||
import Acquisition.pamAudio.PamAudioFileFilter;
|
||||
import Acquisition.pamAudio.PamAudioSystem;
|
||||
import Acquisition.pamAudio.PamAudioFileManager;
|
||||
import PamDetection.RawDataUnit;
|
||||
import PamUtils.FileParts;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamUtils.PamFileFilter;
|
||||
import PamUtils.PamUtils;
|
||||
import wavFiles.ByteConverter;
|
||||
|
||||
/**
|
||||
* Bespoke system for handling data from the Rona hydrophone array which
|
||||
* consists of sets of seven files, each with different ends in th ename.
|
||||
* Bespoke system for handling data from the Rona hydrophone array which
|
||||
* consists of sets of seven files, each with different ends in th ename.
|
||||
* @author Doug
|
||||
*
|
||||
*/
|
||||
public class RonaInputSystem extends FolderInputSystem {
|
||||
|
||||
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];
|
||||
|
||||
@ -58,9 +55,9 @@ public class RonaInputSystem extends FolderInputSystem {
|
||||
private int readyMask = PamUtils.makeChannelMap(NCHANNELS);
|
||||
|
||||
private int runningChannels;
|
||||
|
||||
|
||||
private long lastFileTime = 0;
|
||||
|
||||
|
||||
public static final String systemType = "Rona File Folders";
|
||||
|
||||
public RonaInputSystem(AcquisitionControl acquisitionControl) {
|
||||
@ -98,7 +95,7 @@ public class RonaInputSystem extends FolderInputSystem {
|
||||
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
if (super.accept(f) == false) {
|
||||
if (!super.accept(f)) {
|
||||
return false;
|
||||
}
|
||||
if (f.isDirectory()) {
|
||||
@ -108,11 +105,11 @@ public class RonaInputSystem extends FolderInputSystem {
|
||||
String name = f.getName();
|
||||
int lastDot = name.lastIndexOf('.');
|
||||
if (lastDot < 0) return false;
|
||||
char ch = name.charAt(lastDot-1);
|
||||
char ch = name.charAt(lastDot-1);
|
||||
if ('1' != ch) {
|
||||
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++) {
|
||||
File chanFile = findChannelFile(f, i, 2);
|
||||
if (chanFile == null) {
|
||||
@ -177,14 +174,14 @@ public class RonaInputSystem extends FolderInputSystem {
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* swap the last digit in a file name for the higher channel
|
||||
* number - rememebr the channels are one indexed.
|
||||
* swap the last digit in a file name for the higher channel
|
||||
* number - rememebr the channels are one indexed.
|
||||
* @param baseFile base file
|
||||
* @param index 0 based file index
|
||||
* @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 !
|
||||
* @param baseFile
|
||||
* @param index
|
||||
@ -214,7 +211,7 @@ public class RonaInputSystem extends FolderInputSystem {
|
||||
index = PamUtils.getNthChannel(index, RONACHANNELS);
|
||||
/*
|
||||
* 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);
|
||||
if (fileTime <= 0) {
|
||||
@ -245,7 +242,7 @@ public class RonaInputSystem extends FolderInputSystem {
|
||||
@Override
|
||||
public boolean prepareSystem(AcquisitionControl daqControl) {
|
||||
this.acquisitionControl = daqControl;
|
||||
if (prepareInputFile() == false) {
|
||||
if (!prepareInputFile()) {
|
||||
return false;
|
||||
}
|
||||
this.newDataUnits = acquisitionControl.getDaqProcess().getNewDataQueue();
|
||||
@ -285,7 +282,7 @@ public class RonaInputSystem extends FolderInputSystem {
|
||||
|
||||
currentFileStart = System.currentTimeMillis();
|
||||
fileStartTime = currentFileStart;
|
||||
|
||||
|
||||
for (int i = 0; i < NCHANNELS; i++) {
|
||||
Thread thread = new Thread(flacThreads[i]);
|
||||
thread.start();
|
||||
@ -304,7 +301,7 @@ public class RonaInputSystem extends FolderInputSystem {
|
||||
else {
|
||||
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(),
|
||||
was, runningChannels, PamUtils.getChannelList(runningChannels)));
|
||||
|
||||
@ -332,7 +329,7 @@ public class RonaInputSystem extends FolderInputSystem {
|
||||
calculateETA();
|
||||
systemHasStopped(runningChannels > 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void calculateETA() {
|
||||
long now = System.currentTimeMillis();
|
||||
@ -359,8 +356,8 @@ public class RonaInputSystem extends FolderInputSystem {
|
||||
double[] newRaw = Arrays.copyOf(readyDataUnits[i].getRawData(), (int) firstDataLen);
|
||||
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
|
||||
* and will now go into a wait state while it tries to match it's data with other channels.
|
||||
* 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.
|
||||
*/
|
||||
dontStop = false;
|
||||
}
|
||||
@ -368,7 +365,7 @@ public class RonaInputSystem extends FolderInputSystem {
|
||||
newDataUnits.addNewData(readyDataUnits[i]);
|
||||
}
|
||||
while (newDataUnits.getQueueSize() > NCHANNELS) {
|
||||
if (dontStop == false) break;
|
||||
if (!dontStop) break;
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (Exception ex) {
|
||||
@ -403,7 +400,7 @@ public class RonaInputSystem extends FolderInputSystem {
|
||||
|
||||
@Override
|
||||
public void processPCM(ByteData byteData) {
|
||||
if (dontStop == false) {
|
||||
if (!dontStop) {
|
||||
try {
|
||||
fileStream.close(); // will make the flac reader bomb out !
|
||||
}
|
||||
@ -443,12 +440,12 @@ public class RonaInputSystem extends FolderInputSystem {
|
||||
// newDataUnit.timeMilliseconds = blockMillis;
|
||||
PamCalendar.setSoundFileTimeInMillis(blockMillis);
|
||||
if (fileSamples > 0 && totalSamples - lastProgressUpdate >= getSampleRate()*2) {
|
||||
int progress = (int) (1000. * (float)theseFileSamples / (float) fileSamples);
|
||||
int progress = (int) (1000. * theseFileSamples / fileSamples);
|
||||
fileProgress.setValue(progress);
|
||||
sayEta();
|
||||
long now = System.currentTimeMillis();
|
||||
if (lastProgressTime > 0 && totalSamples > lastProgressUpdate) {
|
||||
double speed = (double) (totalSamples - lastProgressUpdate) /
|
||||
double speed = (double) (totalSamples - lastProgressUpdate) /
|
||||
getSampleRate() / ((now-lastProgressTime)/1000.);
|
||||
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
|
||||
* can continue round.
|
||||
* can continue round.
|
||||
*/
|
||||
for (int ichan = 0; ichan < 1; ichan++) {
|
||||
while (waitingDataUnit(ichan+channelOffset)) {
|
||||
if (dontStop == false) break;
|
||||
if (!dontStop) break;
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -522,7 +519,7 @@ public class RonaInputSystem extends FolderInputSystem {
|
||||
// byteData = flacDecoder.decodeFrame(flacFrame, byteData);
|
||||
// }
|
||||
} 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();
|
||||
}
|
||||
try {
|
||||
|
@ -5,7 +5,6 @@ import java.io.Serializable;
|
||||
import PamModel.parametermanager.ManagedParameters;
|
||||
import PamModel.parametermanager.PamParameterSet;
|
||||
import PamModel.parametermanager.PamParameterSet.ParameterSetType;
|
||||
import simulatedAcquisition.SimProcess;
|
||||
|
||||
/**
|
||||
* Used by SoundCardSystem
|
||||
@ -16,12 +15,12 @@ import simulatedAcquisition.SimProcess;
|
||||
public class SoundCardParameters implements Serializable, Cloneable, ManagedParameters {
|
||||
|
||||
public static final long serialVersionUID = 1;
|
||||
|
||||
|
||||
public int deviceNumber;
|
||||
|
||||
|
||||
public String systemType;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param systemType
|
||||
*/
|
||||
|
@ -8,6 +8,7 @@ import javax.sound.sampled.AudioFormat;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
import javax.sound.sampled.LineUnavailableException;
|
||||
import javax.sound.sampled.Mixer;
|
||||
import javax.sound.sampled.Mixer.Info;
|
||||
import javax.sound.sampled.TargetDataLine;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JPanel;
|
||||
@ -16,19 +17,18 @@ import javax.swing.border.TitledBorder;
|
||||
import Acquisition.layoutFX.AcquisitionPaneFX;
|
||||
import Acquisition.layoutFX.DAQSettingsPane;
|
||||
import Acquisition.layoutFX.SoundCardDAQPane;
|
||||
import soundPlayback.PlaybackControl;
|
||||
import soundPlayback.PlaybackSystem;
|
||||
import soundPlayback.SoundCardPlayback;
|
||||
import wavFiles.ByteConverter;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
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.
|
||||
*
|
||||
*
|
||||
* @author Doug Gillespie
|
||||
* @see Acquisition.DaqSystem
|
||||
* @see Acquisition.AcquisitionProcess
|
||||
@ -39,26 +39,26 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
public static final String sysType = "Sound Card";
|
||||
|
||||
JPanel daqDialog;
|
||||
|
||||
|
||||
JComboBox audioDevices;
|
||||
|
||||
|
||||
SoundCardParameters soundCardParameters = new SoundCardParameters(sysType);
|
||||
|
||||
|
||||
private AudioFormat audioFormat;
|
||||
|
||||
private AudioDataQueue newDataList;
|
||||
|
||||
|
||||
private volatile boolean stopCapture;
|
||||
|
||||
|
||||
private AcquisitionControl acquisitionControl;
|
||||
|
||||
|
||||
private int rawBufferSizeInBytes;
|
||||
// Might need this to be more flexible
|
||||
private int sampleSizeInBytes = 2;
|
||||
private double sampleMax = 32768;
|
||||
|
||||
|
||||
private int daqChannels;
|
||||
|
||||
|
||||
private TargetDataLine targetDataLine;
|
||||
|
||||
private PlaybackSystem soundCardPlayback;
|
||||
@ -66,34 +66,34 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
private int dataUnitSamples;
|
||||
|
||||
private ByteConverter byteConverter;
|
||||
|
||||
|
||||
/**
|
||||
* JavaFX settings pane for sound card settings
|
||||
*/
|
||||
private SoundCardDAQPane soundCardSettingsPane;
|
||||
|
||||
|
||||
public SoundCardSystem (AcquisitionControl daqControl) {
|
||||
this.acquisitionControl = daqControl;
|
||||
PamSettingManager.getInstance().registerSettings(this);
|
||||
soundCardPlayback = new SoundCardPlayback(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean prepareSystem(AcquisitionControl daqControl) {
|
||||
|
||||
this.acquisitionControl = daqControl;
|
||||
|
||||
|
||||
// keep a reference to where data will be put.
|
||||
this.newDataList = daqControl.getDaqProcess().getNewDataQueue();
|
||||
if (this.newDataList == null) return false;
|
||||
daqChannels = daqControl.acquisitionParameters.nChannels;
|
||||
float sampleRate = daqControl.acquisitionParameters.sampleRate;
|
||||
|
||||
|
||||
audioFormat = new AudioFormat(sampleRate, 16, daqChannels, true, true);
|
||||
|
||||
dataUnitSamples = (int) (acquisitionControl.acquisitionParameters.sampleRate / 10);
|
||||
dataUnitSamples = Math.max(dataUnitSamples, 1000);
|
||||
|
||||
|
||||
ArrayList<Mixer.Info> mixerinfos = getInputMixerList();
|
||||
//System.out.println("soundCardParameters.deviceNumber:"+soundCardParameters.deviceNumber);
|
||||
if (soundCardParameters.deviceNumber < 0 || soundCardParameters.deviceNumber >= mixerinfos.size()) {
|
||||
@ -106,7 +106,7 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
thisMixer.getLineInfo();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// try to get the device of choice ...
|
||||
targetDataLine = (TargetDataLine) thisMixer.getLine(thisMixer.getTargetLineInfo()[0]);
|
||||
@ -118,7 +118,7 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
|
||||
boolean lineOk = false;
|
||||
// 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 {
|
||||
// targetDataLine.open(audioFormat);
|
||||
// sampleSizeInBytes = 3;
|
||||
@ -128,8 +128,8 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
// } catch (LineUnavailableException Ex) {
|
||||
// lineOk = false;
|
||||
// }
|
||||
// if the 24 bit recording failed, then try to open for 16 bit recording.
|
||||
if (lineOk == false) {
|
||||
// if the 24 bit recording failed, then try to open for 16 bit recording.
|
||||
if (!lineOk) {
|
||||
audioFormat = new AudioFormat(sampleRate, 16, daqChannels, true, true);
|
||||
try {
|
||||
targetDataLine.open(audioFormat);
|
||||
@ -142,14 +142,14 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
}
|
||||
|
||||
byteConverter = ByteConverter.createByteConverter(audioFormat);
|
||||
|
||||
|
||||
// Buffer size to hold 1/10th of a second
|
||||
rawBufferSizeInBytes = dataUnitSamples * daqChannels * sampleSizeInBytes;
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see Acquisition.DaqSystem#getDataUnitSamples()
|
||||
@ -161,20 +161,20 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
|
||||
@Override
|
||||
public boolean startSystem(AcquisitionControl daqControl) {
|
||||
|
||||
|
||||
if (targetDataLine == null) return false;
|
||||
|
||||
// Create a thread to capture the sound card input
|
||||
// and start it running.
|
||||
Thread captureThread = new Thread(new CaptureThread());
|
||||
captureThread.start();
|
||||
|
||||
|
||||
// then start the device
|
||||
targetDataLine.start();
|
||||
|
||||
|
||||
setStreamStatus(STREAM_RUNNING);
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -207,70 +207,70 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
if (daqDialog == null) {
|
||||
daqDialog = createDaqDialogPanel();
|
||||
}
|
||||
|
||||
|
||||
return daqDialog;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private JPanel createDaqDialogPanel() {
|
||||
|
||||
|
||||
JPanel p = new JPanel();
|
||||
|
||||
|
||||
p.setBorder(new TitledBorder("Select audio line"));
|
||||
p.setLayout(new BorderLayout());
|
||||
p.add(BorderLayout.CENTER, audioDevices = new JComboBox());
|
||||
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<Mixer.Info> getInputMixerList() {
|
||||
ArrayList<Mixer.Info> mixers = new ArrayList<Mixer.Info>();
|
||||
ArrayList<Mixer.Info> mixers = new ArrayList<>();
|
||||
AudioSystem.getMixerInfo();
|
||||
Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
|
||||
Mixer mixer;
|
||||
for (int i = 0; i < mixerInfo.length; i++) {
|
||||
mixer = AudioSystem.getMixer(mixerInfo[i]);
|
||||
for (Info element : mixerInfo) {
|
||||
mixer = AudioSystem.getMixer(element);
|
||||
//System.out.println("mixer:"+mixer);
|
||||
//System.out.println(mixer.getClass().getName());
|
||||
//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
|
||||
//cjb 2009-01-05
|
||||
if (mixer.getTargetLineInfo().length > 0){
|
||||
if ( (mixer.getClass().getName().equals("com.sun.media.sound.DirectAudioDevice")) ||
|
||||
(mixer.getClass().getName().equals("com.sun.media.sound.SimpleInputDevice"))) {
|
||||
//System.out.println("Adding to input mixer list:"+mixer.getClass().getName());
|
||||
mixers.add(mixerInfo[i]);
|
||||
mixers.add(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
return mixers;
|
||||
}
|
||||
public static ArrayList<Mixer.Info> getOutputMixerList() {
|
||||
ArrayList<Mixer.Info> mixers = new ArrayList<Mixer.Info>();
|
||||
ArrayList<Mixer.Info> mixers = new ArrayList<>();
|
||||
AudioSystem.getMixerInfo();
|
||||
Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
|
||||
Mixer mixer;
|
||||
for (int i = 0; i < mixerInfo.length; i++) {
|
||||
for (Info element : mixerInfo) {
|
||||
try {
|
||||
mixer = AudioSystem.getMixer(mixerInfo[i]);
|
||||
mixer = AudioSystem.getMixer(element);
|
||||
}
|
||||
catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
//System.out.println("Output mixer list:" + mixer);
|
||||
//System.out.println("Output mixer list:" + mixer.getClass().getName());
|
||||
//extra bit for Mac's where "Line Out" is under mixer "Built-in Line Input"
|
||||
//which gives 0 length array for getSourceLineInfo()
|
||||
//extra bit for Mac's where "Line Out" is under mixer "Built-in Line Input"
|
||||
//which gives 0 length array for getSourceLineInfo()
|
||||
//cjb 2009-01-05
|
||||
if (mixer.getSourceLineInfo().length > 0){
|
||||
if ((mixer.getClass().getName().equals("com.sun.media.sound.DirectAudioDevice")) ||
|
||||
(mixer.getClass().getName().equals("com.sun.media.sound.HeadspaceMixer"))) {
|
||||
//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());
|
||||
}
|
||||
}
|
||||
// else {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<String> getDevicesList() {
|
||||
ArrayList<String> devices = new ArrayList<String>();
|
||||
ArrayList<String> devices = new ArrayList<>();
|
||||
ArrayList<Mixer.Info> mixers = getInputMixerList();
|
||||
for (int i = 0; i < mixers.size(); i++) {
|
||||
//System.out.println("Adding Device:"+mixers.get(i).getName());
|
||||
@ -291,9 +291,9 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
}
|
||||
return devices;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dialogSetParams() {
|
||||
// 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();
|
||||
|
||||
|
||||
audioDevices.removeAllItems();
|
||||
for (int i = 0; i < devices.size(); i++) {
|
||||
for (String element : devices) {
|
||||
//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);
|
||||
if (devices.size() > 0) {
|
||||
audioDevices.setSelectedIndex(soundCardParameters.deviceNumber);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean dialogGetParams() {
|
||||
//System.out.println("soundCardParameters: " + soundCardParameters + "audioDevices: " + audioDevices);
|
||||
if (audioDevices!=null) soundCardParameters.deviceNumber = audioDevices.getSelectedIndex();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSystemType() {
|
||||
return sysType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSystemName() {
|
||||
// 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
|
||||
//i.e. option of 1 or 2 - mono or stereo
|
||||
//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;
|
||||
}
|
||||
|
||||
@ -364,7 +364,7 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
public int getMaxSampleRate() {
|
||||
return PARAMETER_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see Acquisition.DaqSystem#getPeak2PeakVoltage()
|
||||
*/
|
||||
@ -396,24 +396,29 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
return PARAMETER_UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getSettingsReference() {
|
||||
return soundCardParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSettingsVersion() {
|
||||
return SoundCardParameters.serialVersionUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnitName() {
|
||||
// return "Sound Card System";
|
||||
return acquisitionControl.getUnitName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnitType() {
|
||||
// return "Acquisition System";
|
||||
return "Sound Card System";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
|
||||
// if (PamSettingManager.getInstance().isSettingsUnit(this, pamControlledUnitSettings)) {
|
||||
try {
|
||||
@ -428,7 +433,7 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
|
||||
private volatile boolean captureRunning;
|
||||
|
||||
|
||||
|
||||
// /**
|
||||
// * Unpack the byte data into a sensible number.
|
||||
// * @param buffer
|
||||
@ -446,7 +451,8 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
// }
|
||||
|
||||
class CaptureThread implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
stopCapture = false;
|
||||
captureRunning = true;
|
||||
@ -472,10 +478,10 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
count++;
|
||||
// Read data from the internal
|
||||
// buffer of the data line.
|
||||
|
||||
|
||||
int bytesRead = targetDataLine.read(tempBuffer, 0,
|
||||
tempBuffer.length);
|
||||
|
||||
|
||||
// System.out.println("Read in :" + bytesRead + " bytes");
|
||||
/*
|
||||
* 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
|
||||
* to the PamDataBlocks to theoutput data block.
|
||||
*/
|
||||
|
||||
|
||||
if (bytesRead > 0) {
|
||||
// convert byte array to set of double arrays, one per
|
||||
// channel e.g. framesize = 1 for 8 bit sound
|
||||
|
||||
|
||||
// Framesize is bytecost per Sample in time. ie chanels x sampledepth in bygtes
|
||||
newSamplesPerChannel = bytesRead / audioFormat.getFrameSize();
|
||||
double[][] doubleData = new double[daqChannels][newSamplesPerChannel];
|
||||
@ -519,7 +525,7 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}// end while
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
@ -529,30 +535,30 @@ public class SoundCardSystem extends DaqSystem implements PamSettings {
|
||||
stopCapture = false;
|
||||
captureRunning = false;
|
||||
setStreamStatus(STREAM_ENDED);
|
||||
|
||||
|
||||
}// end run
|
||||
}// end inner class CaptureThread
|
||||
@Override
|
||||
public void daqHasEnded() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDeviceName() {
|
||||
return String.format("%d", soundCardParameters.deviceNumber);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DAQSettingsPane getDAQSpecificPane(AcquisitionPaneFX acquisitionPaneFX) {
|
||||
if (soundCardSettingsPane==null) {
|
||||
soundCardSettingsPane = new SoundCardDAQPane(this);
|
||||
soundCardSettingsPane = new SoundCardDAQPane(this);
|
||||
}
|
||||
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
|
||||
*/
|
||||
public SoundCardParameters getSoundCardParameters() {
|
||||
|
@ -18,10 +18,10 @@ public class StandardChannelListPanel implements ChannelListPanel {
|
||||
// public int channelList[] = new int[PamConstants.MAX_CHANNELS];
|
||||
private JLabel panelChannelLabel[] = new JLabel[PamConstants.MAX_CHANNELS];
|
||||
private JComboBox panelChannelList[] = new JComboBox[PamConstants.MAX_CHANNELS];
|
||||
|
||||
|
||||
private JPanel panel;
|
||||
int nChannels = 0;
|
||||
|
||||
|
||||
public StandardChannelListPanel() {
|
||||
super();
|
||||
panel = createStandardChannelListPanel();
|
||||
@ -47,23 +47,23 @@ public class StandardChannelListPanel implements ChannelListPanel {
|
||||
|
||||
@Override
|
||||
public void setNumChannels(int nChannels) {
|
||||
|
||||
|
||||
nChannels = Math.min(nChannels, panelChannelList.length);
|
||||
|
||||
this.nChannels = nChannels;
|
||||
|
||||
|
||||
this.nChannels = nChannels;
|
||||
|
||||
for (int i = 0; i < PamConstants.MAX_CHANNELS; i++) {
|
||||
panelChannelLabel[i].setVisible(i < nChannels);
|
||||
panelChannelList[i].setVisible(i < nChannels);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// for (int iL = 0; iL < nChannels; iL++) {
|
||||
// panelChannelList[iL].removeAllItems();
|
||||
// for (int i = 0; i < PamConstants.MAX_CHANNELS; 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++){
|
||||
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()));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isDataOk() {
|
||||
|
||||
// now check for repeat combinations.
|
||||
|
||||
// now check for repeat combinations.
|
||||
for (int i = 0; i < nChannels-1; i++) {
|
||||
for (int j = i+1; j < nChannels; j++) {
|
||||
if (panelChannelList[i].getSelectedIndex() == panelChannelList[j].getSelectedIndex()) {
|
||||
String w = String.format("Channel %d is used twice\n"+
|
||||
"only use each channel once on each device",
|
||||
panelChannelList[i].getSelectedIndex());
|
||||
JOptionPane.showConfirmDialog(null, w,
|
||||
JOptionPane.showConfirmDialog(null, w,
|
||||
"Error", JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -103,9 +103,9 @@ public class StandardChannelListPanel implements ChannelListPanel {
|
||||
|
||||
/* code for select channel */
|
||||
/*
|
||||
* put this in a separate panel so it can be hidden if
|
||||
* it's not possible to change these parameters.
|
||||
*
|
||||
* put this in a separate panel so it can be hidden if
|
||||
* it's not possible to change these parameters.
|
||||
*
|
||||
* Text information updated DG & JG 12/8/08
|
||||
*/
|
||||
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>";
|
||||
for (int i = 0; i < PamConstants.MAX_CHANNELS; i++){ //Xiao Yan Deng
|
||||
//for (int i = 0; i < getNumChannels(); i++){
|
||||
|
||||
|
||||
if (i%2 ==0){
|
||||
c2.gridx = 0;
|
||||
c2.gridy ++;
|
||||
@ -140,19 +140,19 @@ public class StandardChannelListPanel implements ChannelListPanel {
|
||||
else {
|
||||
spaceStr = "";
|
||||
}
|
||||
PamDialog.addComponent(cP, panelChannelLabel[i] =
|
||||
PamDialog.addComponent(cP, panelChannelLabel[i] =
|
||||
new JLabel(spaceStr + " SW Ch " + i + " = HW Ch "), c2);
|
||||
c2.gridx ++;
|
||||
//constraints.gridwidth = 2;
|
||||
PamDialog.addComponent(cP, panelChannelList[i] = new JComboBox(), c2);
|
||||
panelChannelLabel[i].setToolTipText(s);
|
||||
panelChannelList[i].setToolTipText(s);
|
||||
|
||||
|
||||
// System.out.println(String.format("Fill channel list %d", i));
|
||||
for (int iC = 0; iC < PamConstants.MAX_CHANNELS; iC++) {
|
||||
panelChannelList[i].addItem(iC);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return cP;
|
||||
}
|
||||
@ -162,6 +162,6 @@ public class StandardChannelListPanel implements ChannelListPanel {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package Acquisition;
|
||||
|
||||
public class WavChunkData {
|
||||
|
||||
|
||||
static final byte RIFF[] = {'R','I','F','F'};
|
||||
static final byte WAVE[] = {'W','A','V','E'};
|
||||
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 ICRD[] = {'I','C','R','D'};
|
||||
static final byte DATA[] = {'d','a','t','a'};
|
||||
|
||||
|
||||
static public final int CHUNK_OTHER = 0;
|
||||
static public final int CHUNK_RIFF = 1;
|
||||
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_ICOP = 6;
|
||||
static public final int CHUNK_ICRD = 7;
|
||||
|
||||
|
||||
int chunkSize;
|
||||
long fileOffset;
|
||||
byte[] chunkId;
|
||||
@ -36,7 +36,7 @@ public class WavChunkData {
|
||||
// String str = new String(chunkData);
|
||||
// System.out.println(new String(chunkId) + " " + str);
|
||||
}
|
||||
|
||||
|
||||
public int getType() {
|
||||
return chunkType;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class WavFileFuncs extends AudioFileFuncs {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (wavHead.checkSizes(aFile.length()) == false) {
|
||||
if (!wavHead.checkSizes(aFile.length())) {
|
||||
wavHead.repairSizes(aFile.length());
|
||||
return writeNewSizes(wavHead, aFile);
|
||||
}
|
||||
@ -106,7 +106,7 @@ public class WavFileFuncs extends AudioFileFuncs {
|
||||
|
||||
private static byte[] readChunkId(WindowsFile file) {
|
||||
|
||||
byte[] chunkId = new byte[4];
|
||||
byte[] chunkId = new byte[4];
|
||||
try {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
chunkId[i] = file.readByte();
|
||||
|
@ -28,7 +28,7 @@ public class WavHeader {
|
||||
|
||||
public void addChunkData(WavChunkData chunkData) {
|
||||
if (otherChunks == null) {
|
||||
otherChunks = new ArrayList<WavChunkData>();
|
||||
otherChunks = new ArrayList<>();
|
||||
}
|
||||
otherChunks.add(chunkData);
|
||||
int t = chunkData.getType();
|
||||
@ -39,12 +39,12 @@ public class WavHeader {
|
||||
}
|
||||
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
WindowsBuffer winBuff = new WindowsBuffer(chunkData.chunkData);
|
||||
|
||||
|
||||
try {
|
||||
this.audioformat = 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
|
||||
* 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
|
||||
* length of the file - the data start point.
|
||||
* The second is the data length, which should be equal to the
|
||||
* length of the file - the data start point.
|
||||
* @param length
|
||||
*/
|
||||
public boolean checkSizes(long length) {
|
||||
@ -80,10 +80,10 @@ public class WavHeader {
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the correct sizes into the file data.
|
||||
* @param length total length of file in bytes.
|
||||
|
||||
/**
|
||||
* Write the correct sizes into the file data.
|
||||
* @param length total length of file in bytes.
|
||||
*/
|
||||
public void repairSizes(long length) {
|
||||
riffChunkSize = length - 8;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,32 +19,35 @@ import PamController.positionreference.PositionReference;
|
||||
public class AirgunControl extends PamControlledUnit implements PamSettings, PositionReference {
|
||||
|
||||
AirgunParameters airgunParameters;
|
||||
|
||||
|
||||
AirgunProcess airgunProcess;
|
||||
|
||||
protected boolean initialisationComplete;
|
||||
|
||||
|
||||
public AirgunControl(String unitName) {
|
||||
|
||||
|
||||
super("Airgun Display", unitName);
|
||||
|
||||
airgunParameters = new AirgunParameters();
|
||||
|
||||
|
||||
addPamProcess(airgunProcess = new AirgunProcess(this));
|
||||
|
||||
|
||||
PamSettingManager.getInstance().registerSettings(this);
|
||||
|
||||
|
||||
airgunProcess.findSourceData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getSettingsReference() {
|
||||
return airgunParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSettingsVersion() {
|
||||
return AirgunParameters.serialVersionUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
|
||||
if (pamControlledUnitSettings.getVersionNo() != AirgunParameters.serialVersionUID) {
|
||||
return false;
|
||||
@ -60,15 +63,16 @@ public class AirgunControl extends PamControlledUnit implements PamSettings, Pos
|
||||
menuItem.addActionListener(new AirgunDisplayOptions(parentFrame));
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
|
||||
private class AirgunDisplayOptions implements ActionListener {
|
||||
|
||||
|
||||
Frame frame;
|
||||
|
||||
public AirgunDisplayOptions(Frame frame) {
|
||||
this.frame = frame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
AirgunParameters newParams = AirgunParametersDialog.showDialog(frame, airgunParameters);
|
||||
@ -76,8 +80,8 @@ public class AirgunControl extends PamControlledUnit implements PamSettings, Pos
|
||||
airgunParameters = newParams.clone();
|
||||
airgunProcess.findSourceData();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,11 +91,11 @@ public class AirgunControl extends PamControlledUnit implements PamSettings, Pos
|
||||
switch (changeType) {
|
||||
case PamControllerInterface.INITIALIZATION_COMPLETE:
|
||||
initialisationComplete = true;
|
||||
airgunProcess.findSourceData();
|
||||
airgunProcess.findSourceData();
|
||||
break;
|
||||
case PamControllerInterface.ADD_CONTROLLEDUNIT:
|
||||
if (initialisationComplete) {
|
||||
airgunProcess.findSourceData();
|
||||
airgunProcess.findSourceData();
|
||||
}
|
||||
break;
|
||||
case PamControllerInterface.NEW_SCROLL_TIME:
|
||||
|
@ -13,9 +13,9 @@ public class AirgunDimensionsDrawing extends ShipDimensionsDrawing {
|
||||
|
||||
private double dimE = 0.1;
|
||||
static private double dimF = 0.5;
|
||||
|
||||
|
||||
PamSymbol airgunSymbol;
|
||||
|
||||
|
||||
public AirgunDimensionsDrawing() throws HeadlessException {
|
||||
super();
|
||||
airgunSymbol = new PamSymbol(PamSymbolType.SYMBOL_HEXAGRAM, 10, 10, false, Color.BLUE, Color.BLUE);
|
||||
|
@ -14,21 +14,21 @@ import PamUtils.Coordinate3d;
|
||||
import PamUtils.LatLong;
|
||||
import PamView.BasicKeyItem;
|
||||
import PamView.GeneralProjector;
|
||||
import PamView.GeneralProjector.ParameterType;
|
||||
import PamView.GeneralProjector.ParameterUnits;
|
||||
import PamView.PamKeyItem;
|
||||
import PamView.PamSymbol;
|
||||
import PamView.PamSymbolType;
|
||||
import PamView.PanelOverlayDraw;
|
||||
import PamView.GeneralProjector.ParameterType;
|
||||
import PamView.GeneralProjector.ParameterUnits;
|
||||
import PamView.symbol.SymbolData;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
|
||||
public class AirgunGraphics extends PanelOverlayDraw {
|
||||
|
||||
AirgunControl airgunControl;
|
||||
|
||||
|
||||
// PamSymbol gunsSymbol;
|
||||
|
||||
|
||||
public static final SymbolData defaultSymbol = new SymbolData(PamSymbolType.SYMBOL_CIRCLE, 6, 6, true, Color.RED, Color.RED);
|
||||
|
||||
public AirgunGraphics(AirgunControl airgunControl) {
|
||||
@ -39,18 +39,20 @@ public class AirgunGraphics extends PanelOverlayDraw {
|
||||
|
||||
@Override
|
||||
public boolean canDraw(ParameterType[] parameterTypes, ParameterUnits[] parameterUnits) {
|
||||
return (parameterTypes[0] == GeneralProjector.ParameterType.LATITUDE &&
|
||||
return (parameterTypes[0] == GeneralProjector.ParameterType.LATITUDE &&
|
||||
parameterTypes[1] == GeneralProjector.ParameterType.LONGITUDE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PamKeyItem createKeyItem(GeneralProjector generalProjector,int keyType) {
|
||||
|
||||
return new BasicKeyItem(getPamSymbol(null, generalProjector), airgunControl.getUnitName());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle drawDataUnit(Graphics g, PamDataUnit pamDataUnit, GeneralProjector generalProjector) {
|
||||
|
||||
|
||||
AirgunDataUnit airgunDataUnit = (AirgunDataUnit) pamDataUnit;
|
||||
|
||||
double verticalRotation = 0.;
|
||||
@ -66,7 +68,7 @@ public class AirgunGraphics extends PanelOverlayDraw {
|
||||
return drawRotatedMap(g, airgunDataUnit, generalProjector);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
public Rectangle drawRotatedMap(Graphics g, AirgunDataUnit airgunDataUnit, GeneralProjector generalProjector) {
|
||||
GpsData gpsData = airgunDataUnit.getGpsData();
|
||||
MapRectProjector mapProj = (MapRectProjector) generalProjector;
|
||||
@ -74,156 +76,157 @@ public class AirgunGraphics extends PanelOverlayDraw {
|
||||
double yScale = Math.cos(Math.toRadians(verticalRotation));
|
||||
double radiusX = mapProj.getPixelsPerMetre()*airgunControl.airgunParameters.exclusionRadius;
|
||||
double radiusY = Math.max(radiusX * yScale, 0);
|
||||
|
||||
|
||||
double gunZ = -airgunControl.airgunParameters.gunDepth;
|
||||
|
||||
// need to move from the gps position to the gund position.
|
||||
LatLong gunsGps = gpsData.travelDistanceMeters(gpsData.getCourseOverGround() + 90,
|
||||
airgunControl.airgunParameters.dimF);
|
||||
gunsGps = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround() + 180,
|
||||
airgunControl.airgunParameters.dimE);
|
||||
|
||||
// need to move from the gps position to the gund position.
|
||||
LatLong gunsGps = gpsData.travelDistanceMeters(gpsData.getCourseOverGround() + 90,
|
||||
airgunControl.airgunParameters.dimF);
|
||||
gunsGps = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround() + 180,
|
||||
airgunControl.airgunParameters.dimE);
|
||||
// int mitigationRadius = airgunControl.airgunParameters.exclusionRadius;
|
||||
Coordinate3d gunsCentre = generalProjector.getCoord3d(gunsGps.getLatitude(), gunsGps.getLongitude(), gunZ);
|
||||
// draw the guns
|
||||
Point gc = gunsCentre.getXYPoint();
|
||||
Point gc = gunsCentre.getXYPoint();
|
||||
PamSymbol gunsSymbol = getPamSymbol(airgunDataUnit, generalProjector);
|
||||
gunsSymbol.setFillColor(airgunControl.airgunParameters.exclusionColor);
|
||||
gunsSymbol.setLineColor(airgunControl.airgunParameters.exclusionColor);
|
||||
gunsSymbol.draw(g, gc);
|
||||
generalProjector.addHoverData(gunsCentre, airgunDataUnit);
|
||||
|
||||
|
||||
if (airgunControl.airgunParameters.showExclusionZone) {
|
||||
// LatLong rEnd = gunsGps.addDistanceMeters(mitigationRadius, 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);
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
if (airgunControl.airgunParameters.predictAhead) {
|
||||
double mapAngle = (int) (90 - gpsData.getCourseOverGround() - 90) - mapProj.getMapRotationDegrees();
|
||||
double predictionLengthMiles = airgunControl.airgunParameters.secondsAhead *
|
||||
double predictionLengthMiles = airgunControl.airgunParameters.secondsAhead *
|
||||
gpsData.getSpeed() / 3600;
|
||||
LatLong predictedPos = gunsGps.TravelDistanceMiles(gpsData.getCourseOverGround(), predictionLengthMiles);
|
||||
Coordinate3d pCirc = generalProjector.getCoord3d(predictedPos.getLatitude(), predictedPos.getLongitude(), gunZ);
|
||||
// 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);
|
||||
float[] dashes = {2, 6};
|
||||
((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));
|
||||
// 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);
|
||||
// now need to find the edge points of all this to link up to other circle
|
||||
LatLong ll1, ll2;
|
||||
Coordinate3d p1, p2;
|
||||
ll1 = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround()+90,
|
||||
ll1 = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround()+90,
|
||||
airgunControl.airgunParameters.exclusionRadius);
|
||||
ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()+90,
|
||||
ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()+90,
|
||||
airgunControl.airgunParameters.exclusionRadius);
|
||||
p1 = generalProjector.getCoord3d(ll1.getLatitude(), ll1.getLongitude(), gunZ);
|
||||
p2 = generalProjector.getCoord3d(ll2.getLatitude(), ll2.getLongitude(), gunZ);
|
||||
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);
|
||||
ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()-90,
|
||||
ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()-90,
|
||||
airgunControl.airgunParameters.exclusionRadius);
|
||||
p1 = generalProjector.getCoord3d(ll1.getLatitude(), ll1.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.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));
|
||||
|
||||
|
||||
|
||||
|
||||
// put it back to a solid line, otherwise the next drawn object will be dashed !
|
||||
((Graphics2D) g).setStroke(new BasicStroke(1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
public Rectangle drawFlatMap(Graphics g, AirgunDataUnit airgunDataUnit, GeneralProjector generalProjector) {
|
||||
|
||||
|
||||
GpsData gpsData = airgunDataUnit.getGpsData();
|
||||
|
||||
// need to move from the gps position to the gund position.
|
||||
LatLong gunsGps = gpsData.travelDistanceMeters(gpsData.getCourseOverGround() + 90,
|
||||
airgunControl.airgunParameters.dimF);
|
||||
gunsGps = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround() + 180,
|
||||
airgunControl.airgunParameters.dimE);
|
||||
|
||||
// need to move from the gps position to the gund position.
|
||||
LatLong gunsGps = gpsData.travelDistanceMeters(gpsData.getCourseOverGround() + 90,
|
||||
airgunControl.airgunParameters.dimF);
|
||||
gunsGps = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround() + 180,
|
||||
airgunControl.airgunParameters.dimE);
|
||||
int mitigationRadius = airgunControl.airgunParameters.exclusionRadius;
|
||||
Coordinate3d gunsCentre = generalProjector.getCoord3d(gunsGps.getLatitude(), gunsGps.getLongitude(), 0);
|
||||
// draw the guns
|
||||
Point gc = gunsCentre.getXYPoint();
|
||||
Point gc = gunsCentre.getXYPoint();
|
||||
PamSymbol gunsSymbol = getPamSymbol(airgunDataUnit, generalProjector);
|
||||
gunsSymbol.setFillColor(airgunControl.airgunParameters.exclusionColor);
|
||||
gunsSymbol.setLineColor(airgunControl.airgunParameters.exclusionColor);
|
||||
gunsSymbol.draw(g, gc);
|
||||
generalProjector.addHoverData(gunsCentre, airgunDataUnit);
|
||||
|
||||
|
||||
if (airgunControl.airgunParameters.showExclusionZone) {
|
||||
LatLong rEnd = gunsGps.addDistanceMeters(mitigationRadius, 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);
|
||||
if (radius > 25) {
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
if (airgunControl.airgunParameters.predictAhead) {
|
||||
double predictionLengthMiles = airgunControl.airgunParameters.secondsAhead *
|
||||
double predictionLengthMiles = airgunControl.airgunParameters.secondsAhead *
|
||||
gpsData.getSpeed() / 3600;
|
||||
LatLong predictedPos = gunsGps.TravelDistanceMiles(gpsData.getCourseOverGround(), predictionLengthMiles);
|
||||
Coordinate3d pCirc = generalProjector.getCoord3d(predictedPos.getLatitude(), predictedPos.getLongitude(), 0);
|
||||
// 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);
|
||||
float[] dashes = {2, 6};
|
||||
((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),
|
||||
180);
|
||||
// now need to find the edge points of all this to link up to other circle
|
||||
LatLong ll1, ll2;
|
||||
Coordinate3d p1, p2;
|
||||
ll1 = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround()+90,
|
||||
ll1 = gunsGps.travelDistanceMeters(gpsData.getCourseOverGround()+90,
|
||||
airgunControl.airgunParameters.exclusionRadius);
|
||||
ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()+90,
|
||||
ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()+90,
|
||||
airgunControl.airgunParameters.exclusionRadius);
|
||||
p1 = generalProjector.getCoord3d(ll1.getLatitude(), ll1.getLongitude(), 0);
|
||||
p2 = generalProjector.getCoord3d(ll2.getLatitude(), ll2.getLongitude(), 0);
|
||||
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);
|
||||
ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()-90,
|
||||
ll2 = predictedPos.travelDistanceMeters(gpsData.getCourseOverGround()-90,
|
||||
airgunControl.airgunParameters.exclusionRadius);
|
||||
p1 = generalProjector.getCoord3d(ll1.getLatitude(), ll1.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.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));
|
||||
|
||||
|
||||
|
||||
|
||||
// put it back to a solid line, otherwise the next drawn object will be dashed !
|
||||
((Graphics2D) g).setStroke(new BasicStroke(1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHoverText(GeneralProjector generalProjector, PamDataUnit dataUnit, int iSide) {
|
||||
String str = "<html>" + airgunControl.getUnitName();
|
||||
if (airgunControl.airgunParameters.showExclusionZone) {
|
||||
@ -242,5 +245,5 @@ public class AirgunGraphics extends PanelOverlayDraw {
|
||||
public boolean showOptions(Window parentWindow,
|
||||
GeneralProjector generalProjector) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,15 +17,15 @@ public class AirgunParameters implements Serializable, Cloneable, ManagedParamet
|
||||
public static final int GUNS_FIXEDPOSITION = 2;
|
||||
|
||||
static public final long serialVersionUID = 1;
|
||||
|
||||
|
||||
/**
|
||||
* True if guns are on this vessel
|
||||
*/
|
||||
private boolean gunsThisVessel = true;
|
||||
|
||||
|
||||
public int gunsReferencePosition = GUNS_THIS_VESSEL;
|
||||
private boolean hasGunsReferencePosition = false;
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
double dimE = 20;
|
||||
|
||||
|
||||
/**
|
||||
* distance in m towards the starboard side from the vessels GPS receiver
|
||||
*/
|
||||
double dimF = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Gun depth in metres.
|
||||
* Gun depth in metres.
|
||||
*/
|
||||
double gunDepth = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Show exclusion zone on the map
|
||||
*/
|
||||
boolean showExclusionZone = true;
|
||||
|
||||
|
||||
/**
|
||||
* radius of exclusion xone in m
|
||||
*/
|
||||
int exclusionRadius = 500;
|
||||
|
||||
|
||||
/**
|
||||
* Colour for exclusion zone on map.
|
||||
*/
|
||||
Color exclusionColor = Color.RED;
|
||||
|
||||
|
||||
/**
|
||||
* predict where we'll be in a certain time
|
||||
*/
|
||||
boolean predictAhead = false;
|
||||
|
||||
|
||||
/**
|
||||
* prediction time in seconds
|
||||
*/
|
||||
int secondsAhead = 600;
|
||||
|
||||
|
||||
public LatLong fixedPosition;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public AirgunParameters clone() {
|
||||
try {
|
||||
AirgunParameters np = (AirgunParameters) super.clone();
|
||||
if (np.hasGunsReferencePosition == false) {
|
||||
if (!np.hasGunsReferencePosition) {
|
||||
// sort out what happens if old boolean ref was used
|
||||
// instead of new int type.
|
||||
// instead of new int type.
|
||||
np.hasGunsReferencePosition = true;
|
||||
if (np.gunsThisVessel == false) {
|
||||
if (!np.gunsThisVessel) {
|
||||
np.gunsReferencePosition = GUNS_AIS_VESSEL;
|
||||
}
|
||||
}
|
||||
@ -93,7 +93,7 @@ public class AirgunParameters implements Serializable, Cloneable, ManagedParamet
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PamParameterSet getParameterSet() {
|
||||
PamParameterSet ps = PamParameterSet.autoGenerate(this, ParameterSetType.DISPLAY);
|
||||
|
@ -17,6 +17,7 @@ import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
@ -29,19 +30,19 @@ import PamView.dialog.PamDialog;
|
||||
public class AirgunParametersDialog extends PamDialog {
|
||||
|
||||
private static AirgunParametersDialog airgunParametersDialog;
|
||||
|
||||
|
||||
private AirgunParameters airgunParameters;
|
||||
|
||||
|
||||
private ShipDimensionsPanel shipDrawing;
|
||||
|
||||
|
||||
private ShipDimensionsFields shipDimensionsFields;
|
||||
|
||||
|
||||
private ShipIDPanel shipIDPanel;
|
||||
|
||||
|
||||
private ExclusionPanel exclusionPanel;
|
||||
|
||||
|
||||
private String[] fieldNames = {"E","F","Depth"};
|
||||
|
||||
|
||||
public AirgunParametersDialog(Frame parentFrame) {
|
||||
super(parentFrame, "Airgun display parameters", false);
|
||||
JPanel p = new JPanel();
|
||||
@ -49,7 +50,7 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
AirgunDimensionsDrawing ad = new AirgunDimensionsDrawing();
|
||||
p.add(shipDrawing = new ShipDimensionsPanel(ad,
|
||||
shipDimensionsFields = new ShipDimensionsFields(fieldNames)));
|
||||
|
||||
|
||||
JPanel q = new JPanel();
|
||||
q.setLayout(new BoxLayout(q, BoxLayout.Y_AXIS));
|
||||
q.add(shipIDPanel = new ShipIDPanel());
|
||||
@ -58,7 +59,7 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
setDialogComponent(p);
|
||||
// setModal(true);
|
||||
}
|
||||
|
||||
|
||||
public static AirgunParameters showDialog(Frame parentFrame, AirgunParameters airgunParameters) {
|
||||
if (airgunParametersDialog == null || airgunParametersDialog.getParent() != parentFrame) {
|
||||
airgunParametersDialog = new AirgunParametersDialog(parentFrame);
|
||||
@ -66,16 +67,16 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
airgunParametersDialog.airgunParameters = airgunParameters.clone();
|
||||
airgunParametersDialog.setParams();
|
||||
airgunParametersDialog.setVisible(true);
|
||||
|
||||
|
||||
return airgunParametersDialog.airgunParameters;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void cancelButtonPressed() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setParams() {
|
||||
double[] dim = new double[3];
|
||||
dim[0] = airgunParameters.dimE;
|
||||
@ -84,9 +85,9 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
shipDimensionsFields.setDimensions(dim);
|
||||
shipIDPanel.setParams();
|
||||
exclusionPanel.setParams();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getParams() {
|
||||
double[] dim = shipDimensionsFields.getDimensions();
|
||||
@ -94,23 +95,22 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
airgunParameters.dimE = dim[0];
|
||||
airgunParameters.dimF = dim[1];
|
||||
airgunParameters.gunDepth = dim[2];
|
||||
if (shipIDPanel.getParams() == false) return false;
|
||||
if (exclusionPanel.getParams() == false) return false;
|
||||
if (!shipIDPanel.getParams() || !exclusionPanel.getParams()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void restoreDefaultSettings() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
class ShipIDPanel extends JPanel implements ActionListener {
|
||||
|
||||
private JRadioButton thisVessel, otherVessel, fixedLocation;
|
||||
private JTextField mmsiNumber;
|
||||
private LatLongEditableDialogStrip llStrip;
|
||||
|
||||
|
||||
public ShipIDPanel() {
|
||||
super();
|
||||
setBorder(new TitledBorder("Source Vessel Identification"));
|
||||
@ -131,7 +131,7 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
c.gridy++;
|
||||
c.gridx = 0;
|
||||
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++;
|
||||
addComponent(this, mmsiNumber = new JTextField(7), c);
|
||||
c.gridx = 0;
|
||||
@ -144,18 +144,19 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
addComponent(this, llStrip.getDialogComponent(), c);
|
||||
bg.add(fixedLocation);
|
||||
fixedLocation.addActionListener(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
enableControls();
|
||||
}
|
||||
|
||||
|
||||
public void enableControls() {
|
||||
mmsiNumber.setEnabled(otherVessel.isSelected());
|
||||
llStrip.enableControls(fixedLocation.isSelected());
|
||||
}
|
||||
|
||||
|
||||
public void setParams() {
|
||||
thisVessel.setSelected(airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_THIS_VESSEL);
|
||||
otherVessel.setSelected(airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_AIS_VESSEL);
|
||||
@ -164,7 +165,7 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
llStrip.setLatLong(airgunParameters.fixedPosition);
|
||||
enableControls();
|
||||
}
|
||||
|
||||
|
||||
public boolean getParams() {
|
||||
if (thisVessel.isSelected()) {
|
||||
airgunParameters.gunsReferencePosition = AirgunParameters.GUNS_THIS_VESSEL;
|
||||
@ -192,22 +193,22 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
class ExclusionPanel extends JPanel implements ActionListener {
|
||||
|
||||
JTextField exRadius;
|
||||
|
||||
|
||||
JCheckBox showExclusion;
|
||||
|
||||
|
||||
JPanel exPanel;
|
||||
|
||||
|
||||
JButton exButton;
|
||||
|
||||
|
||||
JCheckBox predictAhead;
|
||||
|
||||
|
||||
JTextField predictionTime;
|
||||
|
||||
|
||||
public ExclusionPanel() {
|
||||
super();
|
||||
setBorder(new TitledBorder("Guns mitigation zone"));
|
||||
@ -229,7 +230,7 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
addComponent(this, exRadius = new JTextField(6), c);
|
||||
c.gridx++;
|
||||
addComponent(this, new JLabel(" m"), c);
|
||||
|
||||
|
||||
c.gridwidth = 1;
|
||||
c.gridy++;
|
||||
c.gridx = 0;
|
||||
@ -239,7 +240,7 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
c.gridx++;
|
||||
addComponent(this, exButton = new JButton("Colour"), c);
|
||||
exButton.addActionListener(this);
|
||||
|
||||
|
||||
c.gridx = 0;
|
||||
c.gridy ++;
|
||||
c.gridwidth = 3;
|
||||
@ -248,13 +249,13 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
c.gridx = 0;
|
||||
c.gridy ++;
|
||||
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++;
|
||||
addComponent(this, predictionTime = new JTextField(6), c);
|
||||
c.gridx++;
|
||||
addComponent(this, new JLabel(" seconds ", JLabel.LEFT), c);
|
||||
|
||||
|
||||
addComponent(this, new JLabel(" seconds ", SwingConstants.LEFT), c);
|
||||
|
||||
|
||||
}
|
||||
public void setParams() {
|
||||
showExclusion.setSelected(airgunParameters.showExclusionZone);
|
||||
@ -282,9 +283,10 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == exButton) {
|
||||
Color newColor = JColorChooser.showDialog(this, "Mitigation zone colour",
|
||||
Color newColor = JColorChooser.showDialog(this, "Mitigation zone colour",
|
||||
airgunParameters.exclusionColor);
|
||||
if (newColor != null) {
|
||||
setColour(newColor);
|
||||
@ -296,7 +298,7 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
else if (e.getSource() == predictAhead) {
|
||||
enableControls();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private void enableControls() {
|
||||
predictAhead.setEnabled(showExclusion.isSelected());
|
||||
@ -305,5 +307,5 @@ public class AirgunParametersDialog extends PamDialog {
|
||||
predictionTime.setEnabled(predictAhead.isSelected() && showExclusion.isSelected());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,11 +7,9 @@ import AIS.AISDataUnit;
|
||||
import AIS.AISPositionReport;
|
||||
import GPS.GpsData;
|
||||
import GPS.GpsDataUnit;
|
||||
import Map.MapCommentOverlayGraphics;
|
||||
import PamController.PamController;
|
||||
import PamUtils.LatLong;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamView.symbol.PamSymbolManager;
|
||||
import PamView.symbol.StandardSymbolManager;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
@ -22,11 +20,11 @@ import PamguardMVC.SingletonDataBlock;
|
||||
public class AirgunProcess extends PamProcess {
|
||||
|
||||
AirgunControl airgunControl;
|
||||
|
||||
|
||||
PamDataBlock<GpsDataUnit> gpsDataBlock;
|
||||
AISDataBlock aisDataBlock;
|
||||
PamDataBlock<AirgunDataUnit> outputDataBlock;
|
||||
|
||||
|
||||
public AirgunProcess(AirgunControl airgunControl) {
|
||||
super(airgunControl, null);
|
||||
this.airgunControl = airgunControl;
|
||||
@ -53,10 +51,10 @@ public class AirgunProcess extends PamProcess {
|
||||
public void newData(PamObservable o, PamDataUnit arg) {
|
||||
useData(o, arg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AIS data are generally updated rather than created new, so
|
||||
* use newData and updateData in the same way,
|
||||
* AIS data are generally updated rather than created new, so
|
||||
* use newData and updateData in the same way,
|
||||
* @param o PamObservable 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void useGpsData(PamDataBlock dataBlock, GpsDataUnit gpsDataUnit) {
|
||||
if (gpsDataUnit == null) {
|
||||
return;
|
||||
@ -80,7 +78,7 @@ public class AirgunProcess extends PamProcess {
|
||||
GpsData gpsData = gpsDataUnit.getGpsData();
|
||||
createAirgunData(gpsData);
|
||||
}
|
||||
|
||||
|
||||
private void useAisData(PamDataBlock dataBlock, AISDataUnit aisDataUnit) {
|
||||
if (aisDataUnit.mmsiNumber != airgunControl.airgunParameters.gunsMMSIVessel) return;
|
||||
// if (aisDataUnit.isComplete() == false) {
|
||||
@ -104,29 +102,29 @@ public class AirgunProcess extends PamProcess {
|
||||
gpsData.setTimeInMillis(aisDataUnit.getTimeMilliseconds());
|
||||
createAirgunData(gpsData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void createAirgunData(GpsData gpsData) {
|
||||
// PamDataUnit nU = outputDataBlock.getNewUnit(0,0,0);
|
||||
AirgunDataUnit nU = new AirgunDataUnit(PamCalendar.getTimeInMillis(), gpsData);
|
||||
outputDataBlock.addPamData(nU);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void noteNewSettings() {
|
||||
// super.noteNewSettings();
|
||||
findSourceData();
|
||||
}
|
||||
synchronized public void findSourceData(){
|
||||
|
||||
|
||||
PamDataBlock newDataBlock = null;
|
||||
if (airgunControl.airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_THIS_VESSEL) {
|
||||
aisDataBlock = null;
|
||||
// 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
|
||||
* airgun unit was before the GPS unit since the airgun data unit is a subclass of GPSDataUnit. Should now get
|
||||
* the correct GPS data.
|
||||
* airgun unit was before the GPS unit since the airgun data unit is a subclass of GPSDataUnit. Should now get
|
||||
* the correct GPS data.
|
||||
*/
|
||||
// newDataBlock = PamController.getInstance().getDataBlock(GpsDataUnit.class, 0);
|
||||
ArrayList<PamDataBlock> gpsBlocks = PamController.getInstance().getDataBlocks(GpsDataUnit.class, false);
|
||||
@ -149,7 +147,7 @@ public class AirgunProcess extends PamProcess {
|
||||
setParentDataBlock(aisDataBlock);
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
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
|
||||
* location based on the new time.
|
||||
* Called when view times change so that the display can update it's
|
||||
* location based on the new time.
|
||||
*/
|
||||
protected void newViewTime(){
|
||||
if (airgunControl.airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_THIS_VESSEL) {
|
||||
@ -195,18 +193,18 @@ public class AirgunProcess extends PamProcess {
|
||||
@Override
|
||||
public void pamStart() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pamStop() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of PositionReference. Will try to return a ref position
|
||||
* for a given time.
|
||||
* Implementation of PositionReference. Will try to return a ref position
|
||||
* for a given time.
|
||||
* @param timeMillis
|
||||
* @return
|
||||
*/
|
||||
@ -220,7 +218,7 @@ public class AirgunProcess extends PamProcess {
|
||||
if (airgunControl.airgunParameters.gunsReferencePosition == AirgunParameters.GUNS_FIXEDPOSITION){
|
||||
return getFixedPosition(timeMillis);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -237,9 +235,9 @@ public class AirgunProcess extends PamProcess {
|
||||
return null;
|
||||
}
|
||||
GpsData gpsData = gpsDataUnit.getGpsData();
|
||||
LatLong gunPos = gpsData.travelDistanceMeters(gpsData.getHeading() + 180,
|
||||
LatLong gunPos = gpsData.travelDistanceMeters(gpsData.getHeading() + 180,
|
||||
airgunControl.airgunParameters.dimE);
|
||||
gunPos = gunPos.travelDistanceMeters(gpsData.getHeading() + 90,
|
||||
gunPos = gunPos.travelDistanceMeters(gpsData.getHeading() + 90,
|
||||
airgunControl.airgunParameters.dimF);
|
||||
GpsData gunGPS = gpsData.clone();
|
||||
gunGPS.setLatitude(gunPos.getLatitude());
|
||||
@ -247,7 +245,7 @@ public class AirgunProcess extends PamProcess {
|
||||
return gunGPS;
|
||||
}
|
||||
|
||||
private GpsData getAISBasedPosition(long timeMillis) {
|
||||
private GpsData getAISBasedPosition(long timeMillis) {
|
||||
if (aisDataBlock == null) {
|
||||
return null;
|
||||
}
|
||||
@ -260,9 +258,9 @@ public class AirgunProcess extends PamProcess {
|
||||
return null;
|
||||
}
|
||||
LatLong gunPos = aisPositionReport.latLong;
|
||||
gunPos = gunPos.travelDistanceMeters(aisPositionReport.courseOverGround + 180,
|
||||
gunPos = gunPos.travelDistanceMeters(aisPositionReport.courseOverGround + 180,
|
||||
airgunControl.airgunParameters.dimE);
|
||||
gunPos = gunPos.travelDistanceMeters(aisPositionReport.courseOverGround + 90,
|
||||
gunPos = gunPos.travelDistanceMeters(aisPositionReport.courseOverGround + 90,
|
||||
airgunControl.airgunParameters.dimF);
|
||||
GpsData gunGPS = new GpsData(gunPos);
|
||||
gunGPS.setCourseOverGround(aisPositionReport.courseOverGround);
|
||||
|
@ -8,6 +8,7 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFileChooser;
|
||||
@ -16,6 +17,7 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
import Acquisition.AcquisitionControl;
|
||||
import Acquisition.AcquisitionParameters;
|
||||
import PamController.PamController;
|
||||
@ -170,7 +172,7 @@ public class ArrayDialog extends PamDialog implements ActionListener {
|
||||
public boolean getParams() {
|
||||
// all OK, so
|
||||
// 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();
|
||||
ArrayManager.getArrayManager().setCurrentArray(array);
|
||||
@ -179,7 +181,7 @@ public class ArrayDialog extends PamDialog implements ActionListener {
|
||||
hydrophoneDialogPanel.getParams();
|
||||
instrumentIdentityPanel.getParams(array);
|
||||
|
||||
if (checkDaqChannels(array) == false) {
|
||||
if (!checkDaqChannels(array)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -198,7 +200,7 @@ public class ArrayDialog extends PamDialog implements ActionListener {
|
||||
ArrayList<AcquisitionControl> daqControllers = AcquisitionControl.getControllers();
|
||||
boolean allOk = true;
|
||||
for (int i = 0; i < daqControllers.size(); i++) {
|
||||
if (checkDaqChannels(daqControllers.get(i), array) == false) {
|
||||
if (!checkDaqChannels(daqControllers.get(i), array)) {
|
||||
allOk = false;
|
||||
}
|
||||
}
|
||||
@ -238,7 +240,7 @@ public class ArrayDialog extends PamDialog implements ActionListener {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (environmentPanel.getParams() == false) {
|
||||
else if (!environmentPanel.getParams()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -274,6 +276,7 @@ public class ArrayDialog extends PamDialog implements ActionListener {
|
||||
deleteArrayButton.setEnabled(ArrayManager.getArrayManager().getArrayCount() > 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == cancelButton) {
|
||||
this.setVisible(false);
|
||||
|
@ -8,11 +8,9 @@ import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import pamMaths.PamQuaternion;
|
||||
import pamMaths.PamVector;
|
||||
import userDisplay.UserDisplayControl;
|
||||
import Array.importHydrophoneData.HydrophoneImport;
|
||||
import Array.importHydrophoneData.StreamerImport;
|
||||
import Array.layoutFX.ArrayGUIFX;
|
||||
@ -26,6 +24,7 @@ import PamController.PamControlledUnit;
|
||||
import PamController.PamControlledUnitGUI;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
import PamController.PamController;
|
||||
import PamController.PamControllerInterface;
|
||||
import PamController.PamGUIManager;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
@ -40,6 +39,9 @@ import PamguardMVC.PamDataUnit;
|
||||
import PamguardMVC.PamObservable;
|
||||
import PamguardMVC.PamObserver;
|
||||
import dataPlotsFX.data.TDDataProviderRegisterFX;
|
||||
import pamMaths.PamQuaternion;
|
||||
import pamMaths.PamVector;
|
||||
import userDisplay.UserDisplayControl;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
@Override
|
||||
public void notifyModelChanged(int changeType) {
|
||||
if (changeType == PamController.INITIALIZATION_COMPLETE) {
|
||||
if (changeType == PamControllerInterface.INITIALIZATION_COMPLETE) {
|
||||
initComplete = true;
|
||||
}
|
||||
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 ?
|
||||
// if (PamController.getInstance().getRunMode() == PamController.RUN_NORMAL) {
|
||||
hydrophonesProcess.createArrayData();
|
||||
// }
|
||||
}
|
||||
|
||||
if (changeType == PamController.OFFLINE_DATA_LOADED){
|
||||
if (changeType == PamControllerInterface.OFFLINE_DATA_LOADED){
|
||||
if (isViewer) {
|
||||
getHydrophoneDataBlock().clearChannelIterators();
|
||||
}
|
||||
}
|
||||
|
||||
if (changeType == PamController.HYDROPHONE_ARRAY_CHANGED){
|
||||
if (changeType == PamControllerInterface.HYDROPHONE_ARRAY_CHANGED){
|
||||
if (isViewer) {
|
||||
getHydrophoneDataBlock().clearChannelIterators();
|
||||
}
|
||||
}
|
||||
|
||||
if (changeType == PamController.GLOBAL_MEDIUM_UPDATE){
|
||||
if (changeType == PamControllerInterface.GLOBAL_MEDIUM_UPDATE){
|
||||
this.getCurrentArray().setSpeedOfSound(this.getPamController().getGlobalMediumManager().getDefaultSoundSpeed());
|
||||
this.getCurrentArray().setDefaultSensitivity(this.getPamController().getGlobalMediumManager().getDefaultRecieverSens());
|
||||
}
|
||||
@ -229,7 +232,7 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
|
||||
if (selectedArray != null) {
|
||||
hydrophonesProcess.createArrayData();
|
||||
// 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)
|
||||
* @see PamController.PamSettings#GetSettingsReference()
|
||||
*/
|
||||
@Override
|
||||
public Serializable getSettingsReference() {
|
||||
/*
|
||||
* Save the entire array classes in the serialised file
|
||||
@ -275,6 +279,7 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
|
||||
/* (non-Javadoc)
|
||||
* @see PamController.PamSettings#GetSettingsVersion()
|
||||
*/
|
||||
@Override
|
||||
public long getSettingsVersion() {
|
||||
return ArrayParameters.serialVersionUID;
|
||||
}
|
||||
@ -282,6 +287,7 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
|
||||
/* (non-Javadoc)
|
||||
* @see PamController.PamSettings#GetUnitName()
|
||||
*/
|
||||
@Override
|
||||
public String getUnitName() {
|
||||
return "Array Manager";
|
||||
}
|
||||
@ -289,6 +295,7 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
|
||||
/* (non-Javadoc)
|
||||
* @see PamController.PamSettings#getUnitType()
|
||||
*/
|
||||
@Override
|
||||
public String getUnitType() {
|
||||
return "Array Manager";
|
||||
}
|
||||
@ -296,6 +303,7 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
|
||||
/* (non-Javadoc)
|
||||
* @see PamController.PamSettings#RestoreSettings(PamController.PamControlledUnitSettings)
|
||||
*/
|
||||
@Override
|
||||
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
|
||||
try {
|
||||
if (pamControlledUnitSettings.getSettings() != null) {
|
||||
@ -385,23 +393,28 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String getObserverName() {
|
||||
return "Array Manager";
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
return 3600*1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noteNewSettings() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeObservable(PamObservable o) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSampleRate(float sampleRate, boolean notify) {
|
||||
// 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.
|
||||
// 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 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]);
|
||||
break;
|
||||
}
|
||||
@ -771,7 +784,7 @@ public class ArrayManager extends PamControlledUnit implements PamSettings, PamO
|
||||
int nPairs = pvs.length;
|
||||
for (int i = 0; i < nPairs; i++) {
|
||||
for (int j = i+1; j < nPairs; j++) {
|
||||
if (pvs[i].isInLine(pvs[j]) == false) {
|
||||
if (!pvs[i].isInLine(pvs[j])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package Array;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import PamModel.parametermanager.ManagedParameters;
|
||||
|
@ -9,7 +9,7 @@ import Array.sensors.swing.ArrayDisplayParamsDialog;
|
||||
import Array.swing.sidepanel.ArraySidePanel;
|
||||
import PamController.PamControlledUnit;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
import PamController.PamController;
|
||||
import PamController.PamControllerInterface;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
import PamUtils.PamCalendar;
|
||||
@ -45,13 +45,13 @@ public class ArraySidePanelControl extends PamControlledUnit implements ArrayDis
|
||||
public void notifyModelChanged(int changeType) {
|
||||
super.notifyModelChanged(changeType);
|
||||
switch (changeType) {
|
||||
case PamController.INITIALIZATION_COMPLETE:
|
||||
case PamController.HYDROPHONE_ARRAY_CHANGED:
|
||||
case PamControllerInterface.INITIALIZATION_COMPLETE:
|
||||
case PamControllerInterface.HYDROPHONE_ARRAY_CHANGED:
|
||||
if (arraySidePanel != null) {
|
||||
arraySidePanel.update();
|
||||
}
|
||||
break;
|
||||
case PamController.NEW_SCROLL_TIME:
|
||||
case PamControllerInterface.NEW_SCROLL_TIME:
|
||||
if (isViewer()) {
|
||||
arraySidePanel.updateViewerTime(PamCalendar.getTimeInMillis());
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ public class ChannelPanel implements ActionListener, ListSelectionListener {
|
||||
channelTableData.fireTableDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == daqControllerList) {
|
||||
selectDaqController();
|
||||
@ -167,10 +168,12 @@ public class ChannelPanel implements ActionListener, ListSelectionListener {
|
||||
|
||||
class ChannelTableData extends AbstractTableModel {
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return channelColumns.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
if (acquisitionControl == null) return 0;
|
||||
return (acquisitionControl.acquisitionParameters.nChannels);
|
||||
@ -181,6 +184,7 @@ public class ChannelPanel implements ActionListener, ListSelectionListener {
|
||||
return channelColumns[column];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
if (acquisitionControl == null) return null;
|
||||
// see if the controller has a hydrophone list
|
||||
@ -247,6 +251,7 @@ public class ChannelPanel implements ActionListener, ListSelectionListener {
|
||||
/* (non-Javadoc)
|
||||
* @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
enableButtons();
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package Array;
|
||||
|
||||
import GPS.GpsData;
|
||||
|
||||
public class EmptyLocatorSettings extends LocatorSettings {
|
||||
|
||||
public EmptyLocatorSettings(Class locatorClass) {
|
||||
|
@ -30,9 +30,9 @@ import PamModel.parametermanager.ManagedParameters;
|
||||
import PamModel.parametermanager.PamParameterSet;
|
||||
import PamModel.parametermanager.PamParameterSet.ParameterSetType;
|
||||
import PamModel.parametermanager.PrivatePamParameterData;
|
||||
import pamMaths.PamVector;
|
||||
import PamView.PamSymbol;
|
||||
import PamView.PamSymbolType;
|
||||
import pamMaths.PamVector;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -3,12 +3,11 @@ package Array;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import GPS.NavDataSynchronisation;
|
||||
import pamScrollSystem.ViewLoadObserver;
|
||||
import PamController.PamController;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import PamguardMVC.dataOffline.OfflineDataLoadInfo;
|
||||
import pamScrollSystem.ViewLoadObserver;
|
||||
|
||||
public class HydrophoneDataBlock extends PamDataBlock<HydrophoneDataUnit> {
|
||||
|
||||
@ -104,7 +103,7 @@ public class HydrophoneDataBlock extends PamDataBlock<HydrophoneDataUnit> {
|
||||
long difference;
|
||||
|
||||
ListIterator<HydrophoneDataUnit> listIterator = getListIterator(ITERATOR_END);
|
||||
if (listIterator.hasPrevious() == false) {
|
||||
if (!listIterator.hasPrevious()) {
|
||||
return null;
|
||||
}
|
||||
unit = listIterator.previous();
|
||||
|
@ -9,17 +9,19 @@ import java.awt.Point;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import Acquisition.AcquisitionControl;
|
||||
import GPS.GpsData;
|
||||
import Layout.PamAxis;
|
||||
import Layout.PamAxisPanel;
|
||||
import PamController.PamController;
|
||||
import PamUtils.LatLong;
|
||||
import PamView.PamColors.PamColor;
|
||||
import PamView.PamSymbol;
|
||||
import PamView.PamSymbolType;
|
||||
import PamView.PamColors.PamColor;
|
||||
import PamView.panel.PamBorder;
|
||||
import pamMaths.PamVector;
|
||||
|
||||
|
@ -25,8 +25,6 @@ import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
|
||||
|
||||
import Array.streamerOrigin.HydrophoneOriginMethod;
|
||||
import PamController.PamController;
|
||||
|
||||
@ -219,6 +217,7 @@ public class HydrophoneDialogPanel implements ActionListener, ListSelectionListe
|
||||
hydrophoneTableData.fireTableDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == recentArrays) {
|
||||
arrayDialog.newArraySelection();
|
||||
@ -573,7 +572,7 @@ public class HydrophoneDialogPanel implements ActionListener, ListSelectionListe
|
||||
/**
|
||||
* and the hydrophones ...
|
||||
*/
|
||||
if (phonesToo == false) {
|
||||
if (!phonesToo) {
|
||||
return;
|
||||
}
|
||||
int nPhones = currentArray.getHydrophoneCount();
|
||||
@ -694,11 +693,13 @@ public class HydrophoneDialogPanel implements ActionListener, ListSelectionListe
|
||||
|
||||
class HydrophoneTableData extends AbstractTableModel {
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return hydrophoneColumns.length;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
PamArray currentArray = getDialogSelectedArray();
|
||||
if (currentArray == null) return 0;
|
||||
@ -710,6 +711,7 @@ public class HydrophoneDialogPanel implements ActionListener, ListSelectionListe
|
||||
return hydrophoneColumns[column];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
PamArray array = getDialogSelectedArray();
|
||||
Hydrophone hydrophone = array.getHydrophone(rowIndex);
|
||||
@ -750,6 +752,7 @@ public class HydrophoneDialogPanel implements ActionListener, ListSelectionListe
|
||||
/* (non-Javadoc)
|
||||
* @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
enableButtons();
|
||||
}
|
||||
|
@ -110,8 +110,8 @@ public class HydrophoneElementDialog extends PamDialog {
|
||||
|
||||
@Override
|
||||
public boolean getParams() {
|
||||
if (generalPanel.getParams() == false) return false;
|
||||
if (coordinatePanel.getParams() == false) return false;
|
||||
if (!generalPanel.getParams()) return false;
|
||||
if (!coordinatePanel.getParams()) return false;
|
||||
// if (sensitivityPanel.getParams() == false) return false;
|
||||
int hi = interpolationDialogPanel.getSelection();
|
||||
if (hi >= 0) {
|
||||
@ -158,7 +158,7 @@ public class HydrophoneElementDialog extends PamDialog {
|
||||
constraints.gridwidth = 1;
|
||||
constraints.gridx = 0;
|
||||
constraints.gridy++;
|
||||
addComponent(this, recieverTypeLabel = new JLabel("", JLabel.RIGHT), constraints);
|
||||
addComponent(this, recieverTypeLabel = new JLabel("", SwingConstants.RIGHT), constraints);
|
||||
constraints.gridx++;
|
||||
constraints.gridwidth = 2;
|
||||
addComponent(this, type = new JTextField(12), constraints);
|
||||
@ -169,7 +169,7 @@ public class HydrophoneElementDialog extends PamDialog {
|
||||
constraints.gridx = 0;
|
||||
constraints.gridy++;
|
||||
constraints.anchor = GridBagConstraints.EAST;
|
||||
addComponent(this, recieverSensLabel = new JLabel("", JLabel.RIGHT), constraints);
|
||||
addComponent(this, recieverSensLabel = new JLabel("", SwingConstants.RIGHT), constraints);
|
||||
constraints.gridx++;
|
||||
constraints.anchor = GridBagConstraints.WEST;
|
||||
addComponent(this, hSens = new JTextField(5), constraints);
|
||||
@ -181,7 +181,7 @@ public class HydrophoneElementDialog extends PamDialog {
|
||||
constraints.gridx = 0;
|
||||
constraints.gridy++;
|
||||
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.anchor = GridBagConstraints.WEST;
|
||||
addComponent(this, preampGain = new JTextField(5), constraints);
|
||||
@ -380,7 +380,7 @@ public class HydrophoneElementDialog extends PamDialog {
|
||||
double zCoeff = PamController.getInstance().getGlobalMediumManager().getZCoeff();
|
||||
setRecieverLabelText();
|
||||
|
||||
if (newHydrophone == false) {
|
||||
if (!newHydrophone) {
|
||||
x.setText(formatDouble(hydrophone.getX()));
|
||||
y.setText(formatDouble(hydrophone.getY()));
|
||||
depth.setText(formatDouble(zCoeff*hydrophone.getZ()));
|
||||
|
@ -3,14 +3,12 @@ package Array;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import Array.streamerOrigin.StreamerDataIterator;
|
||||
import GPS.GpsData;
|
||||
import PamModel.parametermanager.ManagedParameters;
|
||||
import PamModel.parametermanager.PamParameterSet;
|
||||
import PamModel.parametermanager.PamParameterSet.ParameterSetType;
|
||||
import PamModel.parametermanager.PrivatePamParameterData;
|
||||
import PamUtils.LatLong;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import pamMaths.PamQuaternion;
|
||||
import pamMaths.PamVector;
|
||||
|
||||
|
@ -3,7 +3,6 @@ package Array;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import PamController.PamController;
|
||||
import PamController.PamguardVersionInfo;
|
||||
|
||||
public class HydrophoneLocators {
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
package Array;
|
||||
|
||||
import pamScrollSystem.AbstractScrollManager;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamView.symbol.StandardSymbolManager;
|
||||
import PamguardMVC.PamConstants;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamProcess;
|
||||
import pamScrollSystem.AbstractScrollManager;
|
||||
|
||||
public class HydrophoneProcess extends PamProcess{
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package Array;
|
||||
|
||||
import generalDatabase.SQLLogging;
|
||||
import generalDatabase.SQLTypes;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import generalDatabase.SQLLogging;
|
||||
import generalDatabase.SQLTypes;
|
||||
|
||||
public class HydrophoneSQLLogging extends SQLLogging {
|
||||
|
||||
|
@ -7,6 +7,7 @@ import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import PamView.dialog.PamGridBagContraints;
|
||||
@ -30,12 +31,12 @@ public class InstrumentIdentityPanel {
|
||||
mainPanel.setBorder(new TitledBorder("Instrument information"));
|
||||
mainPanel.setLayout(new GridBagLayout());
|
||||
GridBagConstraints c = new PamGridBagContraints();
|
||||
mainPanel.add(new JLabel("Instrument Type ", JLabel.RIGHT), c);
|
||||
mainPanel.add(new JLabel("Instrument Type ", SwingConstants.RIGHT), c);
|
||||
c.gridx++;
|
||||
mainPanel.add(instrumentType = new JTextField(20), c);
|
||||
c.gridx = 0;
|
||||
c.gridy++;
|
||||
mainPanel.add(new JLabel("Instrument Id ", JLabel.RIGHT), c);
|
||||
mainPanel.add(new JLabel("Instrument Id ", SwingConstants.RIGHT), c);
|
||||
c.gridx++;
|
||||
mainPanel.add(instrumentId = new JTextField(20), c);
|
||||
|
||||
|
@ -2,23 +2,12 @@ package Array;
|
||||
|
||||
import java.io.Serializable;
|
||||
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.GpsDataUnit;
|
||||
import PamController.PamController;
|
||||
import PamController.PamSettingsSource;
|
||||
import PamController.SettingsObject;
|
||||
import PamController.masterReference.MasterReferencePoint;
|
||||
import PamController.PamControllerInterface;
|
||||
import PamModel.parametermanager.ManagedParameters;
|
||||
import PamModel.parametermanager.PamParameterSet;
|
||||
import PamModel.parametermanager.PrivatePamParameterData;
|
||||
import PamUtils.LatLong;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
// }
|
||||
if (initComplete) switch (changeType) {
|
||||
case PamController.HYDROPHONE_ARRAY_CHANGED:
|
||||
case PamController.INITIALIZATION_COMPLETE:
|
||||
case PamControllerInterface.HYDROPHONE_ARRAY_CHANGED:
|
||||
case PamControllerInterface.INITIALIZATION_COMPLETE:
|
||||
setupLocators(ArrayManager.getArrayManager().getCurrentArray());
|
||||
}
|
||||
}
|
||||
@ -238,7 +227,7 @@ public class MasterLocator extends HydrophoneLocator implements Serializable, Cl
|
||||
boolean isStat = true;
|
||||
for (int i = 0; i < n; i++) {
|
||||
Streamer streamer = pamArray.getStreamer(i);
|
||||
if (streamer.getHydrophoneLocator().isStatic() == false) {
|
||||
if (!streamer.getHydrophoneLocator().isStatic()) {
|
||||
isStat = false;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,5 @@
|
||||
package Array;
|
||||
|
||||
import GPS.GpsData;
|
||||
import GPS.GpsDataUnit;
|
||||
import PamUtils.LatLong;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
|
||||
abstract public class MovingHydrophoneLocator extends SimpleHydrophoneLocator {
|
||||
|
||||
/**
|
||||
|
@ -23,27 +23,21 @@ package Array;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import Acquisition.AcquisitionControl;
|
||||
import pamMaths.PamVector;
|
||||
import Array.streamerOrigin.HydrophoneOriginMethod;
|
||||
import Array.streamerOrigin.OriginSettings;
|
||||
import Array.streamerOrigin.StreamerDataIterator;
|
||||
import GPS.GpsData;
|
||||
import PamModel.parametermanager.ManagedParameters;
|
||||
import PamModel.parametermanager.PamParameterSet;
|
||||
import PamModel.parametermanager.PamParameterSet.ParameterSetType;
|
||||
import PamModel.parametermanager.PrivatePamParameterData;
|
||||
import PamUtils.LatLong;
|
||||
import PamUtils.PamArrayUtils;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamView.PamSymbol;
|
||||
import PamguardMVC.ChannelIterator;
|
||||
import PamguardMVC.PamConstants;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import pamMaths.PamVector;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -1281,7 +1275,7 @@ public class PamArray implements Serializable, Cloneable, ManagedParameters {
|
||||
return preceeding.getStreamerData();
|
||||
}
|
||||
// otherwise, we also want the next one ...
|
||||
if (streamerIterator.hasNext() == false) {
|
||||
if (!streamerIterator.hasNext()) {
|
||||
return preceeding.getStreamerData();
|
||||
}
|
||||
nextUnit = streamerIterator.next();
|
||||
@ -1293,7 +1287,7 @@ public class PamArray implements Serializable, Cloneable, ManagedParameters {
|
||||
double w1 = nextUnit.getTimeMilliseconds()-timeMilliseconds;
|
||||
double w2 = timeMilliseconds-preceeding.getTimeMilliseconds();
|
||||
double wTot = w1+w2;
|
||||
if (wTot == 0 || Double.isFinite(wTot) == false) {
|
||||
if (wTot == 0 || !Double.isFinite(wTot)) {
|
||||
w1 = w2 = 0.5;
|
||||
}
|
||||
else {
|
||||
|
@ -73,7 +73,7 @@ public class Preamplifier implements Serializable, Cloneable, ManagedParameters
|
||||
return (Preamplifier) super.clone();
|
||||
}
|
||||
catch (CloneNotSupportedException Ex) {
|
||||
Ex.printStackTrace();;
|
||||
Ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,6 @@ package Array;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.vecmath.Point3d;
|
||||
import javax.vecmath.Point3f;
|
||||
|
||||
import GPS.GpsData;
|
||||
|
||||
import pamMaths.PamVector;
|
||||
|
||||
/**
|
||||
|
@ -1,21 +1,13 @@
|
||||
package Array;
|
||||
|
||||
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.GpsDataUnit;
|
||||
import PamModel.parametermanager.ManagedParameters;
|
||||
import PamModel.parametermanager.PamParameterSet;
|
||||
import PamModel.parametermanager.PrivatePamParameterData;
|
||||
import PamUtils.LatLong;
|
||||
import PamUtils.PamUtils;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamObservable;
|
||||
|
||||
/**
|
||||
* Straight Hydrophone Locator, uses GPS heading information from
|
||||
|
@ -13,7 +13,7 @@ import Array.streamerOrigin.GPSOriginSettings;
|
||||
import Array.streamerOrigin.HydrophoneOriginMethod;
|
||||
import Array.streamerOrigin.HydrophoneOriginMethods;
|
||||
import Array.streamerOrigin.OriginSettings;
|
||||
import PamController.PamController;
|
||||
import PamController.PamControllerInterface;
|
||||
import PamController.masterReference.MasterReferencePoint;
|
||||
import PamModel.parametermanager.ManagedParameters;
|
||||
import PamModel.parametermanager.PamParameterSet;
|
||||
@ -560,7 +560,7 @@ public class Streamer implements Serializable, Cloneable, ManagedParameters {
|
||||
hydrophoneOrigin.prepare();
|
||||
}
|
||||
switch (changeType) {
|
||||
case PamController.INITIALIZATION_COMPLETE:
|
||||
case PamControllerInterface.INITIALIZATION_COMPLETE:
|
||||
// if (PamController.getInstance().getRunMode() == PamController.RUN_NORMAL) {
|
||||
// makeStreamerDataUnit();
|
||||
// }
|
||||
@ -886,7 +886,7 @@ public class Streamer implements Serializable, Cloneable, ManagedParameters {
|
||||
break;
|
||||
case HEIGHT:
|
||||
if (value != null) {
|
||||
setZ(value);;
|
||||
setZ(value);
|
||||
}
|
||||
break;
|
||||
case PITCH:
|
||||
|
@ -94,6 +94,7 @@ public class StreamerDataBlock extends PamDataBlock<StreamerDataUnit>{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadViewerData(OfflineDataLoadInfo offlineDataLoadInfo, ViewLoadObserver loadObserver) {
|
||||
return super.loadViewerData(offlineDataLoadInfo, loadObserver);
|
||||
}
|
||||
|
@ -2,9 +2,7 @@ package Array;
|
||||
|
||||
import Array.sensors.ArrayParameterType;
|
||||
import Array.sensors.ArraySensorFieldType;
|
||||
import Array.streamerOrigin.HydrophoneOriginMethod;
|
||||
import Array.streamerOrigin.OriginSettings;
|
||||
import Array.streamerOrigin.StaticOriginMethod;
|
||||
import Array.streamerOrigin.StaticOriginSettings;
|
||||
import GPS.GpsData;
|
||||
import GPS.GpsDataUnit;
|
||||
|
@ -7,16 +7,15 @@ import java.awt.Insets;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
@ -123,7 +122,7 @@ public class StreamerDialog extends PamDialog {
|
||||
addComponent(p, new JLabel("Error"), c);
|
||||
c.gridx = 0;
|
||||
c.gridy ++;
|
||||
addComponent(p, new JLabel("x ", JLabel.RIGHT), c);
|
||||
addComponent(p, new JLabel("x ", SwingConstants.RIGHT), c);
|
||||
c.gridx++;
|
||||
addComponent(p, x = new JTextField(textLength), c);
|
||||
c.gridx++;
|
||||
@ -133,7 +132,7 @@ public class StreamerDialog extends PamDialog {
|
||||
|
||||
c.gridx = 0;
|
||||
c.gridy ++;
|
||||
addComponent(p, new JLabel("y ", JLabel.RIGHT), c);
|
||||
addComponent(p, new JLabel("y ", SwingConstants.RIGHT), c);
|
||||
c.gridx++;
|
||||
addComponent(p, y = new JTextField(textLength), c);
|
||||
c.gridx++;
|
||||
@ -143,7 +142,7 @@ public class StreamerDialog extends PamDialog {
|
||||
|
||||
c.gridx = 0;
|
||||
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++;
|
||||
addComponent(p, z = new JTextField(textLength), c);
|
||||
c.gridx++;
|
||||
@ -196,29 +195,29 @@ public class StreamerDialog extends PamDialog {
|
||||
String degsLab = LatLong.deg + " ";
|
||||
c.gridx = 0;
|
||||
c.gridy++;
|
||||
addComponent(headPanel, new JLabel("Heading ", JLabel.RIGHT), c);
|
||||
addComponent(headPanel, new JLabel("Heading ", SwingConstants.RIGHT), c);
|
||||
c.gridx++;
|
||||
addComponent(headPanel, heading = new JTextField(orWidth), c);
|
||||
c.gridx++;
|
||||
addComponent(headPanel, new JLabel(degsLab, JLabel.LEFT), c);
|
||||
addComponent(headPanel, new JLabel(degsLab, SwingConstants.LEFT), c);
|
||||
c.gridx++;
|
||||
addComponent(headPanel, sensorComponents[ArraySensorFieldType.HEADING.ordinal()].getComponent(), c);
|
||||
c.gridx = 0;
|
||||
c.gridy++;
|
||||
addComponent(headPanel, new JLabel("Pitch ", JLabel.RIGHT), c);
|
||||
addComponent(headPanel, new JLabel("Pitch ", SwingConstants.RIGHT), c);
|
||||
c.gridx++;
|
||||
addComponent(headPanel, pitch = new JTextField(orWidth), c);
|
||||
c.gridx++;
|
||||
addComponent(headPanel, new JLabel(degsLab, JLabel.LEFT), c);
|
||||
addComponent(headPanel, new JLabel(degsLab, SwingConstants.LEFT), c);
|
||||
c.gridx++;
|
||||
addComponent(headPanel, sensorComponents[ArraySensorFieldType.PITCH.ordinal()].getComponent(), c);
|
||||
c.gridx = 0;
|
||||
c.gridy++;
|
||||
addComponent(headPanel, new JLabel("Roll ", JLabel.RIGHT), c);
|
||||
addComponent(headPanel, new JLabel("Roll ", SwingConstants.RIGHT), c);
|
||||
c.gridx++;
|
||||
addComponent(headPanel, roll = new JTextField(orWidth), c);
|
||||
c.gridx++;
|
||||
addComponent(headPanel, new JLabel(degsLab, JLabel.LEFT), c);
|
||||
addComponent(headPanel, new JLabel(degsLab, SwingConstants.LEFT), c);
|
||||
c.gridx++;
|
||||
addComponent(headPanel, sensorComponents[ArraySensorFieldType.ROLL.ordinal()].getComponent(), c);
|
||||
|
||||
@ -240,7 +239,7 @@ public class StreamerDialog extends PamDialog {
|
||||
locPanel.setLayout(new BorderLayout());
|
||||
locPanel.setBorder(locateRecieverBorder = new TitledBorder("")); //set by steStreamerLabels
|
||||
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);
|
||||
getMainPanel().add(locPanel);
|
||||
getMainPanel().add(interpolationPanel.getComponent(getOwner()));
|
||||
@ -403,7 +402,7 @@ public class StreamerDialog extends PamDialog {
|
||||
}
|
||||
OriginDialogComponent mthDialogComponent = currentOriginMethod.getDialogComponent();
|
||||
if (mthDialogComponent != null) {
|
||||
if (mthDialogComponent.getParams() == false) {
|
||||
if (!mthDialogComponent.getParams()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -517,7 +516,7 @@ public class StreamerDialog extends PamDialog {
|
||||
}
|
||||
|
||||
public void newOriginMethod() {
|
||||
if (constructed == false) {
|
||||
if (!constructed) {
|
||||
return;
|
||||
}
|
||||
int methInd = originMethod.getSelectedIndex();
|
||||
|
@ -1,6 +1,5 @@
|
||||
package Array;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.Types;
|
||||
|
||||
import Array.sensors.ArrayParameterType;
|
||||
@ -8,11 +7,6 @@ import Array.sensors.ArraySensorFieldType;
|
||||
import Array.streamerOrigin.HydrophoneOriginMethod;
|
||||
import Array.streamerOrigin.HydrophoneOriginMethods;
|
||||
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 PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
|
@ -5,18 +5,16 @@ import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Window;
|
||||
|
||||
import Array.streamerOrigin.HydrophoneOriginMethod;
|
||||
import GPS.GpsData;
|
||||
import GPS.GpsDataUnit;
|
||||
import PamUtils.Coordinate3d;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamView.GeneralProjector;
|
||||
import PamView.GeneralProjector.ParameterType;
|
||||
import PamView.GeneralProjector.ParameterUnits;
|
||||
import PamView.PamKeyItem;
|
||||
import PamView.PamSymbol;
|
||||
import PamView.PamSymbolType;
|
||||
import PamView.PanelOverlayDraw;
|
||||
import PamView.GeneralProjector.ParameterType;
|
||||
import PamView.GeneralProjector.ParameterUnits;
|
||||
import PamView.symbol.SymbolData;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
|
||||
|
@ -1,15 +1,10 @@
|
||||
package Array;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ListIterator;
|
||||
import pamMaths.PamVector;
|
||||
import Array.sensors.StreamerSensorManager;
|
||||
|
||||
import Array.streamerOrigin.HydrophoneOriginMethod;
|
||||
import Array.streamerOrigin.OriginIterator;
|
||||
import GPS.GPSControl;
|
||||
import GPS.GPSDataBlock;
|
||||
import GPS.GpsData;
|
||||
import GPS.GpsDataUnit;
|
||||
import GPS.NavDataSynchronisation;
|
||||
import PamModel.parametermanager.ManagedParameters;
|
||||
import PamModel.parametermanager.PamParameterSet;
|
||||
@ -92,7 +87,7 @@ public class ThreadingHydrophoneLocator extends StraightHydrophoneLocator implem
|
||||
*/
|
||||
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
|
||||
* interpolate backwards.
|
||||
|
@ -7,13 +7,13 @@ import java.io.Serializable;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
|
||||
import mcc.MccJniInterface;
|
||||
import PamController.PamControlledUnit;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
import PamView.PamSidePanel;
|
||||
import PamView.dialog.warn.WarnOnce;
|
||||
import mcc.MccJniInterface;
|
||||
|
||||
public class ArrayAccelControl extends PamControlledUnit implements PamSettings {
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package ArrayAccelerometer;
|
||||
|
||||
import pamMaths.PamVector;
|
||||
import Array.sensors.ArraySensorDataUnit;
|
||||
import Array.sensors.ArraySensorFieldType;
|
||||
import PamUtils.PamUtils;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import pamMaths.PamVector;
|
||||
|
||||
public class ArrayAccelDataUnit extends PamDataUnit implements ArraySensorDataUnit {
|
||||
|
||||
|
@ -9,18 +9,18 @@ import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import PamView.dialog.PamDialog;
|
||||
import PamView.dialog.PamGridBagContraints;
|
||||
import mcc.MccJniInterface;
|
||||
import mcc.MccPanel;
|
||||
import mcc.mccjna.MCCException;
|
||||
import mcc.mccjna.MCCUtils;
|
||||
import PamView.dialog.PamDialog;
|
||||
import PamView.dialog.PamGridBagContraints;
|
||||
|
||||
public class ArrayAccelDialog extends PamDialog {
|
||||
|
||||
@ -52,17 +52,17 @@ public class ArrayAccelDialog extends PamDialog {
|
||||
JPanel rPanel = new JPanel(new GridBagLayout());
|
||||
rPanel.setBorder(new TitledBorder("Readout"));
|
||||
GridBagConstraints c = new PamGridBagContraints();
|
||||
rPanel.add(new JLabel("Read interval ", JLabel.RIGHT), c);
|
||||
rPanel.add(new JLabel("Read interval ", SwingConstants.RIGHT), c);
|
||||
c.gridx++;
|
||||
rPanel.add(readInterval = new JTextField(5), c);
|
||||
readInterval.setToolTipText("Readout interval in seconds");
|
||||
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++) {
|
||||
c.gridx = 0;
|
||||
c.gridy++;
|
||||
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.fill = GridBagConstraints.NONE;
|
||||
rPanel.add(dimChannel[i] = new JTextField(3), c);
|
||||
@ -75,23 +75,23 @@ public class ArrayAccelDialog extends PamDialog {
|
||||
calPanel.setBorder(new TitledBorder("Calibration"));
|
||||
c = new PamGridBagContraints();
|
||||
c.gridx = 1;
|
||||
calPanel.add(new JLabel("Zero", JLabel.CENTER), c);
|
||||
calPanel.add(new JLabel("Zero", SwingConstants.CENTER), c);
|
||||
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++) {
|
||||
c.gridy ++;
|
||||
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++;
|
||||
calPanel.add(zeroVolts[i] = new JTextField(5), c);
|
||||
zeroVolts[i].setToolTipText(String.format("Offset voltage for %s coordinate", ArrayAccelParams.DIMENSIONNAME[i]));
|
||||
c.gridx++;
|
||||
calPanel.add(new JLabel(" V, ", JLabel.LEFT), c);
|
||||
calPanel.add(new JLabel(" V, ", SwingConstants.LEFT), c);
|
||||
c.gridx++;
|
||||
calPanel.add(voltsPerG[i] = new JTextField(5), c);
|
||||
voltsPerG[i].setToolTipText(String.format("Voltage scale for %s coordinate", ArrayAccelParams.DIMENSIONNAME[i]));
|
||||
c.gridx++;
|
||||
calPanel.add(new JLabel(" V/g ", JLabel.LEFT), c);
|
||||
calPanel.add(new JLabel(" V/g ", SwingConstants.LEFT), c);
|
||||
}
|
||||
c.gridx = 0;
|
||||
c.gridwidth = 3;
|
||||
@ -103,23 +103,23 @@ public class ArrayAccelDialog extends PamDialog {
|
||||
c.gridy++;
|
||||
c.gridx = 0;
|
||||
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.gridwidth = 1;
|
||||
calPanel.add(rollOffset = new JTextField(5), c);
|
||||
rollOffset.setToolTipText("This value gets ADDED to the measured roll");
|
||||
c.gridx++;
|
||||
calPanel.add(new JLabel(" deg.", JLabel.LEFT), c);
|
||||
calPanel.add(new JLabel(" deg.", SwingConstants.LEFT), c);
|
||||
c.gridy++;
|
||||
c.gridx = 0;
|
||||
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.gridwidth = 1;
|
||||
calPanel.add(pitchOffset = new JTextField(5), c);
|
||||
pitchOffset.setToolTipText("This value gets ADDED to the measured pitch");
|
||||
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.
|
||||
*/
|
||||
public void findZero() {
|
||||
if (getParams() == false) {
|
||||
if (!getParams()) {
|
||||
return;
|
||||
}
|
||||
// read the voltages from the three channels and set as
|
||||
|
@ -15,12 +15,10 @@ import PamUtils.LatLong;
|
||||
import PamView.PamColors;
|
||||
import PamView.PamColors.PamColor;
|
||||
import PamView.panel.PamBorder;
|
||||
import PamView.panel.PamBorderPanel;
|
||||
import PamView.panel.PamPanel;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import PamguardMVC.PamObservable;
|
||||
import PamguardMVC.PamObserver;
|
||||
import PamguardMVC.PamObserverAdapter;
|
||||
|
||||
/*
|
||||
@ -36,7 +34,7 @@ public class ArrayAccelPanel {
|
||||
private long zeroGraphTime;
|
||||
private ArrayAccelDataBlock accelDataBlock;
|
||||
private int panelDurationSecs = 300;
|
||||
private double timeScale = 1;;
|
||||
private double timeScale = 1;
|
||||
|
||||
|
||||
public ArrayAccelPanel(ArrayAccelControl accelControl) {
|
||||
|
@ -1,12 +1,10 @@
|
||||
package ArrayAccelerometer;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
import PamModel.parametermanager.ManagedParameters;
|
||||
import PamModel.parametermanager.PamParameterSet;
|
||||
import PamModel.parametermanager.PamParameterSet.ParameterSetType;
|
||||
import mcc.MccJniInterface;
|
||||
import mcc.mccjna.MCCConstants;
|
||||
|
||||
public class ArrayAccelParams implements Serializable, Cloneable, ManagedParameters {
|
||||
|
@ -5,17 +5,12 @@ import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.Timer;
|
||||
|
||||
import PamController.PamController;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamguardMVC.PamProcess;
|
||||
import mcc.MccJniInterface;
|
||||
import mcc.mccjna.MCCException;
|
||||
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 {
|
||||
|
@ -1,11 +1,8 @@
|
||||
package ArrayAccelerometer;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import PamView.PamColors.PamColor;
|
||||
import PamView.panel.PamPanel;
|
||||
import PamView.PamSidePanel;
|
||||
|
||||
public class ArrayAccelSidePanel implements PamSidePanel {
|
||||
|
@ -2,8 +2,6 @@ package Azigram;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import Acquisition.AcquisitionProcess;
|
||||
import PamUtils.PamUtils;
|
||||
import PamUtils.complex.ComplexArray;
|
||||
import fftManager.FFTDataUnit;
|
||||
|
||||
|
@ -8,8 +8,6 @@ import PamModel.parametermanager.PamParameterSet;
|
||||
import PamModel.parametermanager.PamParameterSet.ParameterSetType;
|
||||
import PamModel.parametermanager.PrivatePamParameterData;
|
||||
import PamView.GroupedSourceParameters;
|
||||
import PamguardMVC.PamConstants;
|
||||
import whistlesAndMoans.WhistleToneParameters;
|
||||
|
||||
public class AzigramParameters implements Serializable, ManagedParameters, Cloneable {
|
||||
|
||||
|
@ -8,19 +8,14 @@ import java.io.Serializable;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import Filters.layoutFX.FilterGUIFX;
|
||||
import PamController.PamControlledUnit;
|
||||
import PamController.PamControlledUnitGUI;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
import PamController.PamController;
|
||||
import PamController.PamControllerInterface;
|
||||
import PamController.PamGUIManager;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
import fftManager.layoutFX.FFTGuiFX;
|
||||
|
||||
/**
|
||||
* Filters raw data using a specified filter.
|
||||
@ -71,6 +66,7 @@ public class FilterControl extends PamControlledUnit implements PamSettings {
|
||||
this.parentFrame = parentFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
FilterParameters_2 newParams = FilterDataSourceDialog.showDialog(filterParams, parentFrame, filterProcess.outputData);
|
||||
@ -90,6 +86,7 @@ public class FilterControl extends PamControlledUnit implements PamSettings {
|
||||
super();
|
||||
this.parentFrame = parentFrame;
|
||||
}
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
FilterParams newParams = FilterDialog.showDialog(parentFrame,
|
||||
@ -109,7 +106,7 @@ public class FilterControl extends PamControlledUnit implements PamSettings {
|
||||
public void notifyModelChanged(int changeType) {
|
||||
//System.out.println("FFTControl: notifyModelChanged : " +changeType);
|
||||
super.notifyModelChanged(changeType);
|
||||
if (changeType == PamController.INITIALIZATION_COMPLETE) {
|
||||
if (changeType == PamControllerInterface.INITIALIZATION_COMPLETE) {
|
||||
filterProcess.setupProcess();
|
||||
}
|
||||
if (filterGUIFX!=null) {
|
||||
@ -117,14 +114,17 @@ public class FilterControl extends PamControlledUnit implements PamSettings {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getSettingsReference() {
|
||||
return filterParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSettingsVersion() {
|
||||
return FilterParams.serialVersionUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
|
||||
filterParams = ((FilterParameters_2) pamControlledUnitSettings.getSettings()).clone();
|
||||
return true;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package Filters;
|
||||
|
||||
import java.awt.Frame;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
package Filters;
|
||||
|
||||
import java.awt.Window;
|
||||
|
||||
import PamView.dialog.PamDialog;
|
||||
|
||||
public class FilterDialog extends PamDialog {
|
||||
|
@ -37,10 +37,14 @@ import javax.swing.JRadioButton;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
import com.opencsv.CSVReader;
|
||||
import com.opencsv.exceptions.CsvException;
|
||||
|
||||
import Layout.PamAxis;
|
||||
import PamUtils.PamFileChooser;
|
||||
import PamUtils.PamFileFilter;
|
||||
@ -49,9 +53,6 @@ import PamView.PamColors.PamColor;
|
||||
import PamView.dialog.PamDialog;
|
||||
import PamView.dialog.PamGridBagContraints;
|
||||
import PamView.panel.PamPanel;
|
||||
import com.opencsv.CSVReader;
|
||||
import com.opencsv.exceptions.CsvException;
|
||||
|
||||
import fftManager.Complex;
|
||||
|
||||
/**
|
||||
@ -188,8 +189,9 @@ public class FilterDialogPanel implements ActionListener {
|
||||
repaintAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (isSetup == false) {
|
||||
if (!isSetup) {
|
||||
return;
|
||||
}
|
||||
if (e.getSource() == filterTypes) {
|
||||
@ -235,7 +237,7 @@ public class FilterDialogPanel implements ActionListener {
|
||||
break;
|
||||
}
|
||||
boolean isArb = filterType == 4;
|
||||
normalPanel.setVisible(isArb == false);
|
||||
normalPanel.setVisible(!isArb);
|
||||
arbPanel.setVisible(isArb);
|
||||
}
|
||||
|
||||
@ -321,14 +323,14 @@ public class FilterDialogPanel implements ActionListener {
|
||||
c.gridwidth = 1;
|
||||
c.gridy++;
|
||||
c.gridx = xc;
|
||||
normalPanel.add(new JLabel(" High Pass", JLabel.RIGHT), c);
|
||||
normalPanel.add(new JLabel(" High Pass", SwingConstants.RIGHT), c);
|
||||
c.gridx++;
|
||||
normalPanel.add(highCut, c);
|
||||
c.gridx++;
|
||||
normalPanel.add(new JLabel(" Hz"), c);
|
||||
c.gridy++;
|
||||
c.gridx = xc;
|
||||
normalPanel.add(new JLabel(" Low Pass", JLabel.RIGHT), c);
|
||||
normalPanel.add(new JLabel(" Low Pass", SwingConstants.RIGHT), c);
|
||||
c.gridx++;
|
||||
normalPanel.add(lowCut, c);
|
||||
c.gridx++;
|
||||
@ -702,10 +704,10 @@ public class FilterDialogPanel implements ActionListener {
|
||||
if (filterMethod == null) {
|
||||
return;
|
||||
}
|
||||
if (IIRFilterMethod.class.isAssignableFrom(filterMethod.getClass()) == true) {
|
||||
if (IIRFilterMethod.class.isAssignableFrom(filterMethod.getClass())) {
|
||||
paintPoleZeros(g);
|
||||
}
|
||||
else if (FIRFilterMethod.class.isAssignableFrom(filterMethod.getClass()) == true) {
|
||||
else if (FIRFilterMethod.class.isAssignableFrom(filterMethod.getClass())) {
|
||||
paintImpulseResponse(g);
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,6 @@
|
||||
*/
|
||||
package Filters;
|
||||
|
||||
import fftManager.Complex;
|
||||
|
||||
/**
|
||||
* @author Doug Gillespie
|
||||
* <p>
|
||||
|
@ -2,9 +2,6 @@ package Filters;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import PamModel.parametermanager.ManagedParameters;
|
||||
import PamModel.parametermanager.PamParameterSet;
|
||||
import PamModel.parametermanager.PamParameterSet.ParameterSetType;
|
||||
|
@ -22,12 +22,7 @@ package Filters;
|
||||
|
||||
import java.io.File;
|
||||
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.PamParameterSet;
|
||||
import PamModel.parametermanager.PamParameterSet.ParameterSetType;
|
||||
|
@ -28,7 +28,7 @@ public class FilterSpeed {
|
||||
data[i] = r.nextGaussian();
|
||||
}
|
||||
testData = data.clone();
|
||||
long sn, en, mn = 0;;
|
||||
long sn, en, mn = 0;
|
||||
double a;
|
||||
long startTime = System.currentTimeMillis();
|
||||
for (int i = 0; i < nTrials; i++) {
|
||||
|
@ -229,6 +229,7 @@ public abstract class IIRFilterMethod extends FilterMethod {
|
||||
* Get coefficients from poles and zeros for fast filter computations.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public double[] getFastFilterCoefficients() {
|
||||
Complex[] poles = getPoles(filterParams);
|
||||
Complex[] zeros = getZeros(filterParams);
|
||||
|
@ -195,6 +195,7 @@ public class IirfFilter implements Filter {
|
||||
/* (non-Javadoc)
|
||||
* @see Filters.Filter#runFilter(double[])
|
||||
*/
|
||||
@Override
|
||||
synchronized public void runFilter(double[] inputData) {
|
||||
int f;
|
||||
for (int i = 0; i < inputData.length; i++) {
|
||||
@ -208,6 +209,7 @@ public class IirfFilter implements Filter {
|
||||
/* (non-Javadoc)
|
||||
* @see Filters.Filter#runFilter(double[], double[])
|
||||
*/
|
||||
@Override
|
||||
synchronized public void runFilter(double[] inputData, double[] outputData) {
|
||||
int f;
|
||||
if (outputData == null || outputData.length != inputData.length) {
|
||||
@ -225,6 +227,7 @@ public class IirfFilter implements Filter {
|
||||
/* (non-Javadoc)
|
||||
* @see Filters.Filter#runFilter(double)
|
||||
*/
|
||||
@Override
|
||||
synchronized public double runFilter(double aData) {
|
||||
double newData = aData;
|
||||
for (int f = 0; f < nFilterUnits; f++) {
|
||||
|
@ -52,14 +52,14 @@ public class FormatGpsData {
|
||||
Date dateO;
|
||||
|
||||
FormatGpsData() {
|
||||
};
|
||||
}
|
||||
|
||||
FormatGpsData(StringBuffer nmeaString) {
|
||||
/*
|
||||
* Unpack the string buffer to populate the above datas
|
||||
*/
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public static String formatTime(int intTime) {
|
||||
SimpleDateFormat gpsTimeFormat = new SimpleDateFormat("HHmmss");
|
||||
|
@ -9,11 +9,6 @@ import java.util.ListIterator;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import warnings.PamWarning;
|
||||
import warnings.WarningSystem;
|
||||
import NMEA.NMEADataBlock;
|
||||
import PamController.PamControlledUnit;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
@ -21,9 +16,10 @@ import PamController.PamController;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
import PamController.positionreference.PositionReference;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamView.dialog.warn.WarnOnce;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import warnings.PamWarning;
|
||||
import warnings.WarningSystem;
|
||||
|
||||
public class GPSControl extends PamControlledUnit implements PamSettings, PositionReference {
|
||||
|
||||
@ -144,7 +140,9 @@ public class GPSControl extends PamControlledUnit implements PamSettings, Positi
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
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();
|
||||
|
||||
@ -168,6 +166,7 @@ public class GPSControl extends PamControlledUnit implements PamSettings, Positi
|
||||
this.parentFrame = parentFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
GPSParameters newP = GPSParametersDialog.showDialog(parentFrame, gpsParameters);
|
||||
if (newP != null) {
|
||||
@ -184,6 +183,7 @@ public class GPSControl extends PamControlledUnit implements PamSettings, Positi
|
||||
this.parentFrame = parentFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
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>" +
|
||||
@ -195,13 +195,16 @@ public class GPSControl extends PamControlledUnit implements PamSettings, Positi
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Serializable getSettingsReference() {
|
||||
return gpsParameters;
|
||||
}
|
||||
@Override
|
||||
public long getSettingsVersion() {
|
||||
return GPSParameters.serialVersionUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
|
||||
|
||||
if (pamControlledUnitSettings.getUnitType().equals(this.getUnitType())
|
||||
@ -260,7 +263,7 @@ public class GPSControl extends PamControlledUnit implements PamSettings, Positi
|
||||
* @return interpolated gps position.
|
||||
*/
|
||||
public GpsDataUnit getShipPosition(long timeMilliseconds, boolean interpolate) {
|
||||
if (interpolate == false) {
|
||||
if (!interpolate) {
|
||||
return getGpsDataBlock().getClosestUnitMillis(timeMilliseconds);
|
||||
}
|
||||
// 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
Loading…
Reference in New Issue
Block a user