XML Settings

Added a new log of XML settings / Effort for each module to the
database. Had to make a lot of changes so that the base table in
SQLLogging is of type EmptyTableDefinition, not PamTableDefinition.
Needs a lot of testing and may break plugins using logging features.
This commit is contained in:
Douglas Gillespie 2022-12-12 17:04:20 +00:00
parent 29230a5c5f
commit 48716cb366
50 changed files with 554 additions and 132 deletions

View File

@ -665,7 +665,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings{
if (currentFile > 0 && currentFile >= allFiles.size()) {
fileListComplete();
}
// System.out.println("FolderinputSytem: daqHasEnded");
System.out.println("FolderinputSytem: daqHasEnded");
}
private void setFolderProgress() {

View File

@ -295,7 +295,8 @@ public class GpsLogger extends SQLLogging {
* time from the UTC column which is NOT the GpsData time which was the real GPS time.
*/
int gpsIntTimeVal = gpsTime.getIntegerValue();
Object ts = getTableDefinition().getTimeStampItem().getValue();
PamTableDefinition pamTableDef = (PamTableDefinition) getTableDefinition();
Object ts = pamTableDef.getTimeStampItem().getValue();
long gpsDate = sqlTypes.millisFromTimeStamp(ts);
if (gpsDate%1000 == 0) {
// some databases may have stored the milliseconds, in which

View File

@ -8,14 +8,13 @@ import java.sql.Types;
import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
//import pamDatabase.SQLLogging;
//import PamguardMVC.RecyclingDataBlock;
import generalDatabase.PamDetectionLogging;
public class IshLogger extends PamDetectionLogging {
IshDetControl ishDetControl;
PamTableDefinition tableDefinition;
PamTableItem systemDate, durationSecs, secSinceStart, peakHeight;
// Peak is more important than start time for matched filter & spectrogram correlation
PamTableItem peakSample, peakDelaySecs;
@ -25,7 +24,7 @@ public class IshLogger extends PamDetectionLogging {
super(pamDataBlock, UPDATE_POLICY_WRITENEW);
this.ishDetControl = ishDetControl;
tableDefinition = getTableDefinition();
EmptyTableDefinition tableDefinition = getTableDefinition();
// PamTableItem tableItem;
// setUpdatePolicy(UPDATE_POLICY_WRITENEW);

View File

@ -14,14 +14,13 @@ import IshmaelDetector.IshDetection;
import PamUtils.LatLong;
import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
//import pamDatabase.SQLLogging;
//import PamguardMVC.RecyclingDataBlock;
import generalDatabase.PamDetectionLogging;
public class IshLocSqlLogging extends PamDetectionLogging {
IshLocControl ishLocControl;
PamTableDefinition tableDefinition;
PamTableItem systemDate, durationSecs, secSinceStart, peakHeight;
private PamTableItem latitude, longitude, refLatitude, refLongitude, x, y, z;
@ -30,7 +29,7 @@ public class IshLocSqlLogging extends PamDetectionLogging {
super(pamDataBlock, UPDATE_POLICY_WRITENEW);
this.ishLocControl = ishDetControl;
tableDefinition = getTableDefinition();
EmptyTableDefinition tableDefinition = getTableDefinition();
tableDefinition.addTableItem(latitude = new PamTableItem("Latitude", Types.DOUBLE));
tableDefinition.addTableItem(longitude = new PamTableItem("Longitude", Types.DOUBLE));
tableDefinition.addTableItem(refLatitude = new PamTableItem("ReferenceLatitude", Types.DOUBLE));

View File

@ -13,6 +13,7 @@ import javax.swing.JOptionPane;
import PamUtils.LatLong;
import PamUtils.PamFileChooser;
import PamView.dialog.warn.WarnOnce;
public class GebcoMapFile implements MapFileManager {
@ -83,8 +84,16 @@ public class GebcoMapFile implements MapFileManager {
* @see Map.MapFile#readFileData(java.io.File)
*/
public boolean readFileData(File file) {
try {
return readMapFile(file, true);
}
catch (Exception e) {
// trap error someone reported at end November 22. Suspect it was their corrupt map file causing problems.
String err = String.format("Map file %s is missing or corrupt and cannot be loaded", file.getName());
WarnOnce.showWarning("Map File Error", err, WarnOnce.OK_OPTION);
return false;
}
}
private boolean readMapFile(File gebcoFile, boolean readContours) {

View File

@ -1192,6 +1192,8 @@ public class PamController implements PamControllerInterface, PamSettings {
}
if (saveSettings) {
startTime = PamCalendar.getSessionStartTime();
// System.out.printf("Saving settings for start time %s\n", PamCalendar.formatDBDateTime(startTime));
saveSettings(PamCalendar.getSessionStartTime());
}
@ -1342,6 +1344,9 @@ public class PamController implements PamControllerInterface, PamSettings {
}
guiFrameManager.pamEnded();
long stopTime = PamCalendar.getTimeInMillis();
saveEndSettings(stopTime);
// no good having this here since it get's called at the end of every file.
// if (GlobalArguments.getParam(PamController.AUTOEXIT) != null) {
//// can exit here, since we've auto started, can auto exit.
@ -1467,6 +1472,25 @@ public class PamController implements PamControllerInterface, PamSettings {
PamguardXMLWriter.getXMLWriter().writeStartSettings(timeNow);
}
/**
* Gets called in pamStart and may / will attempt to store all
* PAMGUARD settings via the database and binary storage modules.
*/
private void saveEndSettings(long timeNow) {
// System.out.printf("Updating settings with end time %s\n", PamCalendar.formatDBDateTime(timeNow));
PamControlledUnit pcu;
PamSettingsSource settingsSource;
for (int iU = 0; iU < pamControlledUnits.size(); iU++) {
pcu = pamControlledUnits.get(iU);
if (PamSettingsSource.class.isAssignableFrom(pcu.getClass())) {
settingsSource = (PamSettingsSource) pcu;
settingsSource.saveEndSettings(timeNow);
}
}
}
/**
* Export configuration into an XML file
* @param parentFrame

View File

@ -20,6 +20,14 @@ public interface PamSettingsSource {
*/
public boolean saveStartSettings(long timeNow);
/**
* Save settings when processing ends.
* This may just be an update of the settings saves with saveStartSettings, e.g. an end time.
* @param timeNow
* @return true if saved correctly.
*/
public boolean saveEndSettings(long timeNow);
/**
* Get the number of different settings
* within the settings source.

View File

@ -371,6 +371,32 @@ public class PamguardXMLWriter implements PamSettings {
* @return xml content as a a string.
*/
public String getAsString(Document doc) {
return getAsString(doc, true);
// try {
// DOMSource domSource = new DOMSource(doc);
// StringWriter writer = new StringWriter();
// StreamResult result = new StreamResult(writer);
// TransformerFactory tf = TransformerFactory.newInstance();
// Transformer transformer = tf.newTransformer();
// transformer.setOutputProperty(OutputKeys.METHOD, "xml");
// transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
//// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
// transformer.setOutputProperty(OutputKeys.INDENT, "yes");
// transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
// transformer.transform(domSource, result);
// return writer.toString();
// } catch (TransformerException e) {
// e.printStackTrace();
// return null;
// }
}
/**
* Get the xml document as a String.
* @param doc xml document
* @param indent Indent / format the document.
* @return xml content as a a string.
*/
public String getAsString(Document doc, boolean indent) {
try {
DOMSource domSource = new DOMSource(doc);
StringWriter writer = new StringWriter();
@ -380,7 +406,7 @@ public class PamguardXMLWriter implements PamSettings {
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.INDENT, indent ? "yes" : "no");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
transformer.transform(domSource, result);
return writer.toString();

View File

@ -7,6 +7,7 @@ import PamDetection.AcousticSQLLogging;
import PamUtils.PamUtils;
import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLTypes;
@ -26,7 +27,7 @@ public class RWESQLLogging extends AcousticSQLLogging {
angles = new PamTableItem[maxAngles];
angleErrors = new PamTableItem[maxAngles];
PamTableDefinition tableDef = getTableDefinition();
EmptyTableDefinition tableDef = getTableDefinition();
tableDef.addTableItem(score = new PamTableItem("score", Types.INTEGER));
tableDef.addTableItem(signal = new PamTableItem("signal", Types.DOUBLE));
tableDef.addTableItem(noise = new PamTableItem("noise", Types.DOUBLE));

View File

@ -56,7 +56,8 @@ public class ArraySensorLogging extends SQLLogging {
AnalogSensorData aData = new AnalogSensorData(rawValue, calValue);
sensorData[i] = aData;
}
int chanMap = getTableDefinition().getChannelBitmap().getIntegerValue();
PamTableDefinition pamTableDef = (PamTableDefinition) getTableDefinition();
int chanMap = pamTableDef.getChannelBitmap().getIntegerValue();
int streamer = PamUtils.getSingleChannel(chanMap);
if (streamer < 0) streamer = 0;
AnalogArraySensorDataUnit asdu = new AnalogArraySensorDataUnit(timeMilliseconds, streamer, sensorData);

View File

@ -3,6 +3,7 @@ package annotation.calcs.snr;
import java.sql.Types;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLLoggingAddon;
@ -21,13 +22,13 @@ public class SnrSqlAddon implements SQLLoggingAddon {
}
@Override
public void addTableItems(PamTableDefinition pamTableDefinition) {
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
pamTableDefinition.addTableItem(snr);
}
@Override
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
PamDataUnit pamDataUnit) {
SNRAnnotation snrAnnotation = (SNRAnnotation) pamDataUnit.findDataAnnotation(SNRAnnotation.class);
if (snrAnnotation == null) {
@ -40,7 +41,7 @@ public class SnrSqlAddon implements SQLLoggingAddon {
}
@Override
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
PamDataUnit pamDataUnit) {
Double snrVal = (Double) snr.getValue();
if (snrVal != null) {

View File

@ -3,6 +3,7 @@ package annotation.calcs.spl;
import java.sql.Types;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLLoggingAddon;
@ -25,7 +26,7 @@ public class SPLSqlAddon implements SQLLoggingAddon {
}
@Override
public void addTableItems(PamTableDefinition pamTableDefinition) {
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
pamTableDefinition.addTableItem(rms);
pamTableDefinition.addTableItem(zeroPeak);
pamTableDefinition.addTableItem(peakPeak);
@ -33,7 +34,7 @@ public class SPLSqlAddon implements SQLLoggingAddon {
}
@Override
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
PamDataUnit pamDataUnit) {
SPLAnnotation splAnnotation = (SPLAnnotation) pamDataUnit.findDataAnnotation(SPLAnnotation.class);
if (splAnnotation == null) {
@ -52,7 +53,7 @@ public class SPLSqlAddon implements SQLLoggingAddon {
}
@Override
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
PamDataUnit pamDataUnit) {
SPLAnnotation splAnnotation = new SPLAnnotation(splAnnotationType);
if (splAnnotation != null) {

View File

@ -3,6 +3,7 @@ package annotation.calcs.wav;
import java.sql.Types;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLLoggingAddon;
@ -21,13 +22,13 @@ public class WavSqlAddon implements SQLLoggingAddon {
}
@Override
public void addTableItems(PamTableDefinition pamTableDefinition) {
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
pamTableDefinition.addTableItem(wavFileName);
}
@Override
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
PamDataUnit pamDataUnit) {
WavAnnotation annotation = (WavAnnotation) pamDataUnit.findDataAnnotation(WavAnnotation.class);
if (annotation == null) {
@ -40,7 +41,7 @@ public class WavSqlAddon implements SQLLoggingAddon {
}
@Override
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
PamDataUnit pamDataUnit) {
String fileName = (String) wavFileName.getValue();
if (fileName != null) {

View File

@ -15,6 +15,7 @@ import PamView.dialog.GenericSwingDialog;
import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit;
import generalDatabase.DBControlUnit;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.SQLLogging;
@ -126,7 +127,7 @@ public abstract class OneStopAnnotationHandler extends AnnotationChoiceHandler i
return;
}
// get, modify and set the modified tabelDef
PamTableDefinition tableDef = logging.getBaseTableDefinition();
EmptyTableDefinition tableDef = logging.getBaseTableDefinition();
logging.setTableDefinition(tableDef);
addAnnotationSqlAddons(logging); // this will add the additional columns.
DBControlUnit dbc = DBControlUnit.findDatabaseControl();

View File

@ -3,6 +3,7 @@ package annotation.localise.targetmotion;
import Localiser.detectionGroupLocaliser.GroupLocalisation;
import PamDetection.AbstractLocalisation;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.SQLTypes;
import targetMotionOld.TargetMotionSQLLogging;
@ -17,7 +18,7 @@ public class TMAnnotationLogging extends TargetMotionSQLLogging {
}
@Override
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
boolean ans = super.loadData(sqlTypes, pamTableDefinition, pamDataUnit);
if (ans == false) return false;
AbstractLocalisation loc = pamDataUnit.getLocalisation();

View File

@ -3,6 +3,7 @@ package annotation.string;
import java.sql.Types;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLLoggingAddon;
@ -24,12 +25,12 @@ public class StringSQLLogging implements SQLLoggingAddon {
}
@Override
public void addTableItems(PamTableDefinition pamTableDefinition) {
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
pamTableDefinition.addTableItem(notes);
}
@Override
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
StringAnnotation stringAnnotation = (StringAnnotation) pamDataUnit.findDataAnnotation(StringAnnotation.class,
stringAnnotationType.getAnnotationName());
if (stringAnnotation == null) {
@ -42,7 +43,7 @@ public class StringSQLLogging implements SQLLoggingAddon {
}
@Override
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
try {
String note = notes.getDeblankedStringValue();
if (note != null && note.length() > 0) {

View File

@ -3,6 +3,7 @@ package annotation.timestamp;
import java.sql.Types;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLLoggingAddon;
@ -22,12 +23,12 @@ public class TimestampSQLLogging implements SQLLoggingAddon {
}
@Override
public void addTableItems(PamTableDefinition pamTableDefinition) {
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
pamTableDefinition.addTableItem(timestamp);
}
@Override
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
TimestampAnnotation timestampAnnotation = (TimestampAnnotation) pamDataUnit.findDataAnnotation(TimestampAnnotation.class,
timestampAnnotationType.getAnnotationName());
if (timestampAnnotation == null) {
@ -40,7 +41,7 @@ public class TimestampSQLLogging implements SQLLoggingAddon {
}
@Override
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
try {
TimestampAnnotation timestampAnnotation = new TimestampAnnotation(timestampAnnotationType);
Long note = sqlTypes.millisFromTimeStamp(timestamp.getValue());

View File

@ -3,6 +3,7 @@ package annotation.userforms;
import java.util.ArrayList;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLLoggingAddon;
@ -31,7 +32,7 @@ public class UserFormSQLAddon implements SQLLoggingAddon {
@Override
public void addTableItems(PamTableDefinition pamTableDefinition) {
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
loggerTableItems.clear();
FormDescription formDescription = userFormAnnotationType.findFormDescription();
if (formDescription == null) {
@ -51,7 +52,7 @@ public class UserFormSQLAddon implements SQLLoggingAddon {
}
@Override
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
if (pamDataUnit == null) {
clearTableItems();
return false;
@ -86,7 +87,7 @@ public class UserFormSQLAddon implements SQLLoggingAddon {
}
@Override
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
FormDescription formDescription = userFormAnnotationType.findFormDescription();
if (formDescription == null) {
return false;

View File

@ -6,6 +6,7 @@ import PamDetection.LocContents;
import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit;
import beamformer.loc.BeamFormerLocalisation;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLLoggingAddon;
@ -29,7 +30,7 @@ public class BFAnnotationLogging implements SQLLoggingAddon {
}
@Override
public void addTableItems(PamTableDefinition pamTableDefinition) {
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
pamTableDefinition.addTableItem(bfPhones);
pamTableDefinition.addTableItem(bfArrayType);
pamTableDefinition.addTableItem(bfContents);
@ -38,7 +39,7 @@ public class BFAnnotationLogging implements SQLLoggingAddon {
}
@Override
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
bfPhones.setValue(null);
bfArrayType.setValue(null);
bfContents.setValue(null);
@ -64,7 +65,7 @@ public class BFAnnotationLogging implements SQLLoggingAddon {
}
@Override
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
Float[] Angles = new Float[2];
for (int i = 0; i < 2; i++) {
Angles[i] = (Float) angle[i].getFloatValue();

View File

@ -4,6 +4,7 @@ import java.sql.Types;
import PamguardMVC.PamDataUnit;
import bearinglocaliser.BearingLocalisation;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLLoggingAddon;
@ -34,7 +35,7 @@ public class BearingAnnotationSQL implements SQLLoggingAddon {
}
@Override
public void addTableItems(PamTableDefinition pamTableDefinition) {
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
pamTableDefinition.addTableItem(algoName);
pamTableDefinition.addTableItem(bfPhones);
pamTableDefinition.addTableItem(bfArrayType);
@ -48,7 +49,7 @@ public class BearingAnnotationSQL implements SQLLoggingAddon {
}
@Override
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
algoName.setValue(null);
bfPhones.setValue(null);
bfArrayType.setValue(null);
@ -96,7 +97,7 @@ public class BearingAnnotationSQL implements SQLLoggingAddon {
}
@Override
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
Float[] Angles = new Float[2];
int nNans = 0;
for (int i = 0; i < 2; i++) {

View File

@ -110,6 +110,12 @@ public class BinarySettingsStorage implements PamSettingsSource {
return false;*/
}
@Override
public boolean saveEndSettings(long timeNow) {
// do nothing at the end of a run with binary store.
return true;
}
// private boolean writeData(DataOutputStream dos, int objectId, byte[] data) {
// int totalLen = data.length + 16;
// int dataLen = data.length;

View File

@ -537,6 +537,12 @@ PamSettingsSource, OfflineDataStore {
return binarySettingsStorage.saveStartSettings(timeNow);
}
@Override
public boolean saveEndSettings(long timeNow) {
// TODO Auto-generated method stub
return false;
}
@Override
public int getNumSettings() {
if (binarySettingsStorage == null) {

View File

@ -46,7 +46,8 @@ public class BinaryStoreProcess extends PamProcess {
startTime = PamCalendar.getTimeInMillis();
long round = binaryStore.binaryStoreSettings.fileSeconds * 1000;
nextFileTime = (startTime/round) * round + round;
System.out.println("Next file start at " + PamCalendar.formatDateTime(nextFileTime));
// this was a print of the time of the NEXT binary file. Not really of interest.
// System.out.println("Next file start at " + PamCalendar.formatDateTime(nextFileTime));
timer = new Timer();
timer.schedule(new FileTimerTask(), 1000, 1000);

View File

@ -3,6 +3,7 @@ package clickDetector.ClickClassifiers.annotation;
import java.sql.Types;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLLoggingAddon;
@ -33,12 +34,12 @@ public class ClickAnnotationSQL implements SQLLoggingAddon {
}
@Override
public void addTableItems(PamTableDefinition pamTableDefinition) {
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
pamTableDefinition.addTableItem(classifierSetTable);
}
@Override
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
ClickClassifierAnnotation clickAnnotation = (ClickClassifierAnnotation) pamDataUnit.findDataAnnotation(ClickClassificationType.class);
//create a comma delimited string
@ -53,7 +54,7 @@ public class ClickAnnotationSQL implements SQLLoggingAddon {
@Override
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
String array = classifierSetTable.getDeblankedStringValue();
//read in the classification set. This a list of all the classifiers the clicks passed.

View File

@ -1,5 +1,6 @@
package clickDetector;
import generalDatabase.PamTableDefinition;
import generalDatabase.SQLTypes;
import PamguardMVC.PamDataUnit;
import clickDetector.offlineFuncs.OfflineEventDataUnit;
@ -30,7 +31,8 @@ public class TrackedClickGroupLogging extends ClickGroupLogging {
boolean isUpdate = true;
// Timestamp ts = (Timestamp) getTableDefinition().getTimeStampItem().getValue();
// long t = PamCalendar.millisFromTimeStamp(ts);
int updateIndex = (Integer) getTableDefinition().getUpdateReference().getValue();
PamTableDefinition tableDef = (PamTableDefinition) getTableDefinition();
int updateIndex = (Integer) tableDef.getUpdateReference().getValue();
if (updateIndex > 0) {
tcg = this.clickGroupDataBlock.findByDatabaseIndex(updateIndex);
}

View File

@ -82,7 +82,7 @@ public class ClickTrainDataSelector2 extends DataSelector {
}
SQLLogging logging = getPamDataBlock().getLogging();
if (logging == null) return null; //cannot happen!
PamTableDefinition tableDef = logging.getTableDefinition();
EmptyTableDefinition tableDef = logging.getTableDefinition();
if (params.isIncludeUnclassified()) {
return null;
}

View File

@ -102,16 +102,17 @@ public class DatabaseChecks {
long resultTime;
long firstTime = Long.MAX_VALUE;
long lastTime = Long.MIN_VALUE;
PamTableDefinition pamTableDef = (PamTableDefinition) clickLogging.getTableDefinition();
try {
Statement stmt = con.getConnection().createStatement();
ResultSet result = stmt.executeQuery(sqlStr);
while (result.next()) {
nClicks++;
clickLogging.transferDataFromResult(sqlTypes, result);
ts = clickLogging.getTableDefinition().getTimeStampItem().getValue();
ts = pamTableDef.getTimeStampItem().getValue();
resultTime = sqlTypes.millisFromTimeStamp(ts);
if (resultTime%1000 == 0) {
resultTime += clickLogging.getTableDefinition().getTimeStampMillis().getIntegerValue();
resultTime += pamTableDef.getTimeStampMillis().getIntegerValue();
}
firstTime = Math.min(firstTime, resultTime);
lastTime = Math.max(lastTime, resultTime);
@ -188,7 +189,7 @@ public class DatabaseChecks {
eventDataBlock.addPamData(event);
PamConnection con = DBControlUnit.findConnection();
// now find a cursor and save it.
PamTableDefinition eventTableDef = eventDataBlock.getLogging().getTableDefinition();
PamTableDefinition eventTableDef = (PamTableDefinition) eventDataBlock.getLogging().getTableDefinition();
PamCursor cursor = eventDataBlock.getLogging().getViewerCursorFinder().getCursor(con, eventTableDef);
cursor.immediateInsert(con);
int newId = event.getDatabaseIndex();

View File

@ -277,13 +277,14 @@ public class OfflineClickLogging extends SQLLogging {
Integer millis;
Object ts;
SQLTypes sqlTypes = dbControl.getConnection().getSqlTypes();
PamTableDefinition tableDef = (PamTableDefinition) getTableDefinition();
try {
while (resultSet.next()) {
transferDataFromResult(sqlTypes, resultSet);
ts = getTableDefinition().getTimeStampItem().getValue();
ts = tableDef.getTimeStampItem().getValue();
long m = SQLTypes.millisFromTimeStamp(ts);
if (m%1000 == 0) {
millis = (Integer) getTableDefinition().getTimeStampMillis().getValue();
millis = (Integer) tableDef.getTimeStampMillis().getValue();
if (millis != null) {
m += millis;
}

View File

@ -148,7 +148,7 @@ public class RainbowDatabseConverter {
ClickDataBlock clickDataBlock = clickControl.getClickDataBlock();
clickLogging = new ClickImportLogging(clickControl);
PamTableDefinition tableDef = clickLogging.getTableDefinition();
PamTableDefinition tableDef = (PamTableDefinition) clickLogging.getTableDefinition();
boolean ok = checkTable(pamConnection, tableDef);
if (!ok) {
System.out.println("Error in Pamguard clicks table");
@ -156,7 +156,7 @@ public class RainbowDatabseConverter {
}
eventLogging = new OfflineEventLogging(clickControl, clickControl.getClickDetector().getOfflineEventDataBlock());
tableDef = eventLogging.getTableDefinition();
tableDef = (PamTableDefinition) eventLogging.getTableDefinition();
ok = checkTable(pamConnection, tableDef);
if (!ok) {
System.out.println("Error in Pamguard events table");

View File

@ -125,7 +125,7 @@ public class TrackedGroupSqlLogging extends SQLLogging {
*/
protected void updateData(SQLTypes sqlTypes, PamDataUnit pamDataUnit) {
PamTableDefinition tableDef = getTableDefinition();
PamTableDefinition tableDef = (PamTableDefinition) getTableDefinition();
PamTableItem tableItem;
tableDef.getIndexItem().setValue(pamDataUnit.getDatabaseIndex());

View File

@ -572,10 +572,16 @@ PamSettingsSource {
*/
@Override
public boolean saveStartSettings(long timeNow) {
return dbProcess.saveStartSettings();
return dbProcess.saveStartSettings(timeNow);
}
@Override
public boolean saveEndSettings(long timeNow) {
// TODO Auto-generated method stub
return true;
}
@Override
public int getNumSettings() {
if (dbSettingsStore == null) {

View File

@ -97,6 +97,8 @@ public class DBProcess extends PamProcess {
dbSpecials.add(logLastSettings = new LogSettings(databaseControll, "Pamguard Settings Last", true));
dbSpecials.add(logViewerSettings = new LogSettings(databaseControll, "Pamguard Settings Viewer", true));
dbSpecials.add(new LogXMLSettings(databaseControll));
}
@Override
@ -107,9 +109,13 @@ public class DBProcess extends PamProcess {
}
}
protected boolean saveStartSettings() {
protected boolean saveStartSettings(long timeNow) {
PamConnection con = databaseControll.getConnection();
if (con != null) {
/**
* This first one is the 'old' pre 2022 method which saves a serialised lump of all
* the settings in the database. It ain't broke, so not fixing it.
*/
for (int i = 0; i < dbSpecials.size(); i++) {
dbSpecials.get(i).pamStart(con);
}
@ -118,6 +124,11 @@ public class DBProcess extends PamProcess {
return false;
}
protected boolean saveEndSettings(long timeNow) {
return true;
}
@Override
public void pamStop() {
PamConnection con = databaseControll.getConnection();
@ -206,7 +217,7 @@ public class DBProcess extends PamProcess {
}
dataBlocks = PamController.getInstance().getDataBlocks();
PamTableDefinition tableDefinition;
EmptyTableDefinition tableDefinition;
SQLLogging logging;
// for each datablock, check that the process can log (ignoring GPS process)

View File

@ -48,7 +48,7 @@ public class DBSchemaWriter {
}
PamTableDefinition tableDef = logging.getTableDefinition();
EmptyTableDefinition tableDef = logging.getTableDefinition();
tableDef = logging.getBaseTableDefinition();
if (tableDef instanceof PamTableDefinition) {
@ -63,7 +63,7 @@ public class DBSchemaWriter {
return true;
}
private void exportDatabaseSchema(File outputFolder, PamDataBlock dataBlock, SQLLogging logging, PamTableDefinition tableDef) {
private void exportDatabaseSchema(File outputFolder, PamDataBlock dataBlock, SQLLogging logging, EmptyTableDefinition tableDef) {
/**
* write a parent item, e.g. if tableDef is a sub class of PamTableDefinition

View File

@ -300,7 +300,7 @@ public class EmptyTableDefinition implements Cloneable {
* @param tableName
* @return reference to the database deinition if it exists, or null
*/
static PamTableDefinition findTableDefinition(String tableName) {
static EmptyTableDefinition findTableDefinition(String tableName) {
String searchName = EmptyTableDefinition.deblankString(tableName);
SQLLogging log = SQLLogging.findLogger(searchName);
if (log == null) return null;
@ -389,6 +389,15 @@ public class EmptyTableDefinition implements Cloneable {
this.updatePolicy = updatePolicy;
}
public PamConnection getCheckedConnection() {
return checkedConnection;
}
public void setCheckedConnection(PamConnection checkedConnection) {
this.checkedConnection = checkedConnection;
}
@Override
protected EmptyTableDefinition clone() {
try {

View File

@ -23,7 +23,7 @@ import PamUtils.PamCalendar;
import PamguardMVC.PamDataUnit;
/**
* Functions for writing Pamguard Settings into any database as character data
* Functions for writing serialised Pamguard Settings into any database as character data
* Runs at DAQ start, goes through the settings manager list and for each
* set of settings, it serialises the settings data into a binary array, this
* is then converted from binary data to 6 bit ascii data (using the character set
@ -185,6 +185,7 @@ public class LogSettings extends DbSpecial {
DeserialisationWarning dsWarning = new DeserialisationWarning(getDbControl().getDatabaseName());
SQLTypes sqlTypes = con.getSqlTypes();
boolean haveData;
if (result != null) try {
haveData = result.next();
@ -193,7 +194,7 @@ public class LogSettings extends DbSpecial {
// transfer data back into the tableItems store.
transferDataFromResult(sqlTypes, result);
tableItem = getTableDefinition().getTimeStampItem();
tableItem = tableDef.getTimeStampItem();
// timestamp = (Timestamp) tableItem.getTimestampValue();
timeMillis = sqlTypes.millisFromTimeStamp(tableItem.getValue());

View File

@ -0,0 +1,75 @@
package generalDatabase;
import PamController.PamSettings;
import PamguardMVC.PamDataUnit;
/**
* simple data unit for use with the LogXMLSettings class
* @author dg50
*
*/
public class LogXMLDataUnit extends PamDataUnit {
private long processTime;
private PamSettings pamSettings;
private String xml;
private Long dataEnd, processEnd;
public LogXMLDataUnit(long timeMilliseconds, long processTime, PamSettings pamSettings, String xml) {
super(timeMilliseconds);
this.processTime = processTime;
this.pamSettings = pamSettings;
this.xml = xml;
}
/**
* @return the dataEnd
*/
public Long getDataEnd() {
return dataEnd;
}
/**
* @param dataEnd the dataEnd to set
*/
public void setDataEnd(Long dataEnd) {
this.dataEnd = dataEnd;
}
/**
* @return the processEnd
*/
public Long getProcessEnd() {
return processEnd;
}
/**
* @param processEnd the processEnd to set
*/
public void setProcessEnd(Long processEnd) {
this.processEnd = processEnd;
}
/**
* @return the processTime
*/
public long getProcessTime() {
return processTime;
}
/**
* @return the pamSettings
*/
public PamSettings getPamSettings() {
return pamSettings;
}
/**
* @return the xml
*/
public String getXml() {
return xml;
}
}

View File

@ -0,0 +1,123 @@
package generalDatabase;
import java.io.Serializable;
import java.util.HashMap;
import org.w3c.dom.Document;
import PamController.PamControlledUnit;
import PamController.PamController;
import PamController.PamSettings;
import PamController.PamguardVersionInfo;
import PamController.settings.output.xml.PamguardXMLWriter;
import PamUtils.PamCalendar;
import PamguardMVC.PamDataUnit;
/**
* 2022 Additional say of saving settings for each module into the database in more human readable
* XML format. <p>
* In other ways, similar to LogSettings which saves serialised Java. This will write a line
* per module. A main difference is that on pamStop it will update the end time for each line, so
* that we have a record of analysis effort for each module. Will therefore need to store the last
* index of the entry for each module, so that we can update the appropriate row.
* @author dg50
*
*/
public class LogXMLSettings extends DbSpecial {
private XMLSettingsTableDefinition xmlTableDef;
private HashMap<String, LogXMLDataUnit> moduleRows;
private PamguardXMLWriter xmlWriter;
public LogXMLSettings(DBControl dbControl) {
super(dbControl);
xmlTableDef = new XMLSettingsTableDefinition("Module Effort");
setTableDefinition(xmlTableDef);
moduleRows = new HashMap<>();
xmlWriter = PamguardXMLWriter.getXMLWriter();
}
@Override
public void pamStart(PamConnection con) {
long time = PamCalendar.getTimeInMillis();
saveModuleSettings(con, time);
}
@Override
public void pamStop(PamConnection con) {
long time = PamCalendar.getTimeInMillis();
updateModuleSettings(con, time);
}
private void saveModuleSettings(PamConnection con, long dataTime) {
int n = PamController.getInstance().getNumControlledUnits();
long now = System.currentTimeMillis();
for (int i = 0; i < n; i++) {
saveModuleSettings(con, dataTime, now, PamController.getInstance().getControlledUnit(i));
}
}
private void saveModuleSettings(PamConnection con, long dataTime, long now, PamControlledUnit controlledUnit) {
if (controlledUnit instanceof PamSettings == false) {
return;
}
PamSettings pamSettings = (PamSettings) controlledUnit;
Serializable settings = pamSettings.getSettingsReference();
Document doc = xmlWriter.writeOneModule(pamSettings, dataTime);
String xmlString = xmlWriter.getAsString(doc, true);
LogXMLDataUnit logXMLDataUnit = new LogXMLDataUnit(dataTime, now, pamSettings, xmlString);
logData(logXMLDataUnit);
int dbIndex = logXMLDataUnit.getDatabaseIndex();
moduleRows.put(getModuleHash(pamSettings), logXMLDataUnit);
}
private void updateModuleSettings(PamConnection con, long dataTime) {
int n = PamController.getInstance().getNumControlledUnits();
long now = System.currentTimeMillis();
for (int i = 0; i < n; i++) {
updateModuleSettings(con, dataTime, now, PamController.getInstance().getControlledUnit(i));
}
}
private void updateModuleSettings(PamConnection con, long dataTime, long now, PamControlledUnit controlledUnit) {
if (controlledUnit instanceof PamSettings == false) {
return;
}
PamSettings pamSettings = (PamSettings) controlledUnit;
LogXMLDataUnit logXMLDataUnit = moduleRows.get(getModuleHash(pamSettings));
if (logXMLDataUnit == null) {
return;
}
logXMLDataUnit.setDataEnd(dataTime);
logXMLDataUnit.setProcessEnd(now);
reLogData(con, logXMLDataUnit);
}
private String getModuleHash(PamSettings pamSettings) {
if (pamSettings == null) {
return null;
}
return pamSettings.getUnitName()+pamSettings.getUnitType();
}
@Override
public void setTableData(SQLTypes sqlTypes, PamDataUnit pamDataUnit) {
LogXMLDataUnit logXMLDataUnit = (LogXMLDataUnit) pamDataUnit;
PamSettings pamSettings = logXMLDataUnit.getPamSettings();
xmlTableDef.getDataStart().setValue(sqlTypes.getTimeStamp(pamDataUnit.getTimeMilliseconds()));
xmlTableDef.getDataEnd().setValue(sqlTypes.getTimeStamp(logXMLDataUnit.getDataEnd()));
xmlTableDef.getProcessStart().setValue(sqlTypes.getTimeStamp(logXMLDataUnit.getProcessTime()));
xmlTableDef.getProcessEnd().setValue(sqlTypes.getTimeStamp(logXMLDataUnit.getProcessEnd()));
xmlTableDef.getName().setValue(pamSettings.getUnitName());
xmlTableDef.getType().setValue(pamSettings.getUnitType());
xmlTableDef.getPamGuardVersion().setValue(PamguardVersionInfo.version);
xmlTableDef.getSettingsVersion().setValue(pamSettings.getSettingsVersion());
xmlTableDef.getXmlSettings().setValue(logXMLDataUnit.getXml());
}
}

View File

@ -192,13 +192,6 @@ public class PamTableDefinition extends EmptyTableDefinition implements Cloneabl
public PamTableItem getUidItem() {
return uid;
}
public PamConnection getCheckedConnection() {
return checkedConnection;
}
public void setCheckedConnection(PamConnection checkedConnection) {
this.checkedConnection = checkedConnection;
}
public PamTableItem getUpdateReference() {
return updateReference;

View File

@ -374,7 +374,7 @@ public class PamTableItem implements Cloneable {
* column for use in cross referencing.
*/
public static PamTableItem findTableItem(String tableName, String columnName) {
PamTableDefinition tableDef = EmptyTableDefinition.
EmptyTableDefinition tableDef = EmptyTableDefinition.
findTableDefinition(EmptyTableDefinition.deblankString(tableName));
if (tableDef == null) return null;
return tableDef.findTableItem(EmptyTableDefinition.deblankString(columnName));

View File

@ -92,7 +92,7 @@ public abstract class SQLLogging {
* Reference to the table definition object.
* This MUST be set from within the concrete logging class.
*/
private PamTableDefinition pamTableDefinition;
private EmptyTableDefinition pamTableDefinition;
/**
* More and more data blocks are starting to use annotations, which require
@ -102,7 +102,7 @@ public abstract class SQLLogging {
* table definition is set, so that it can be got and modified by the
* annotation handler shortly after the main table is created.
*/
private PamTableDefinition baseTableDefinition;
private EmptyTableDefinition baseTableDefinition;
// private long selectT1, selectT2;
private PamViewParameters currentViewParameters;
@ -190,7 +190,7 @@ public abstract class SQLLogging {
ArrayList<PamDataBlock> blockList = PamController.getInstance()
.getDataBlocks();
SQLLogging logger;
PamTableDefinition tableDef;
EmptyTableDefinition tableDef;
for (int i = 0; i < blockList.size(); i++) {
if ((logger = blockList.get(i).getLogging()) != null) {
tableDef = logger.getTableDefinition();
@ -234,7 +234,7 @@ public abstract class SQLLogging {
* @return a Pamguard database table definition object
* @see PamTableDefinition
*/
public final PamTableDefinition getTableDefinition() {
public final EmptyTableDefinition getTableDefinition() {
return pamTableDefinition;
}
@ -243,7 +243,7 @@ public abstract class SQLLogging {
*
* @param pamTableDefinition PamTableDefinition to set
*/
public void setTableDefinition(PamTableDefinition pamTableDefinition) {
public void setTableDefinition(EmptyTableDefinition pamTableDefinition) {
this.pamTableDefinition = pamTableDefinition;
if (baseTableDefinition == null && pamTableDefinition != null) {
baseTableDefinition = pamTableDefinition.clone();
@ -294,10 +294,14 @@ public abstract class SQLLogging {
*/
protected void fillTableData(SQLTypes sqlTypes, PamDataUnit pamDataUnit, PamDataUnit superDetection) {
PamTableDefinition tableDef = getTableDefinition();
EmptyTableDefinition emptyTableDef = getTableDefinition();
PamTableItem tableItem;
tableDef.getIndexItem().setValue(pamDataUnit.getDatabaseIndex());
emptyTableDef.getIndexItem().setValue(pamDataUnit.getDatabaseIndex());
if (emptyTableDef instanceof PamTableDefinition) {
PamTableDefinition tableDef = (PamTableDefinition) emptyTableDef;
/*
* All tables have a timestamp near the front of the table. And all data
* units have a time in milliseconds, so always fill this in !
@ -320,10 +324,11 @@ public abstract class SQLLogging {
if (tableDef.getUpdateReference() != null) {
tableDef.getUpdateReference().setValue(pamDataUnit.getDatabaseIndex());
}
}
for (int i = 0; i < tableDef.getTableItemCount(); i++) {
for (int i = 0; i < emptyTableDef.getTableItemCount(); i++) {
tableItem = tableDef.getTableItem(i);
tableItem = emptyTableDef.getTableItem(i);
// if (tableItem.isCounter()) {
// tableItem.setValue(1);
// }
@ -333,8 +338,8 @@ public abstract class SQLLogging {
}
}
if (tableDef instanceof PamSubtableDefinition) {
PamSubtableDefinition subTableDef = (PamSubtableDefinition) tableDef;
if (emptyTableDef instanceof PamSubtableDefinition) {
PamSubtableDefinition subTableDef = (PamSubtableDefinition) emptyTableDef;
fillSubTableData(subTableDef, pamDataUnit, superDetection);
}
@ -525,7 +530,7 @@ public abstract class SQLLogging {
}
// now put some sql into the statement
// if (resultSet == null) {
PamTableDefinition tableDef = getTableDefinition();
EmptyTableDefinition tableDef = getTableDefinition();
String sqlString = tableDef.getSQLSelectString(con.getSqlTypes());
// sqlString = "select \"comment\" from userinput";
try {
@ -1067,7 +1072,7 @@ public abstract class SQLLogging {
public boolean transferDataFromResult(SQLTypes sqlTypes, ResultSet resultSet) {
PamTableDefinition tableDef = getTableDefinition();
EmptyTableDefinition tableDef = getTableDefinition();
PamTableItem tableItem;
try {
for (int i = 0; i < tableDef.getTableItemCount(); i++) {
@ -1078,17 +1083,20 @@ public abstract class SQLLogging {
// Timestamp ts = (Timestamp) getTableDefinition().getTimeStampItem().getValue();
// Timestamp ts = getTableDefinition().getTimeStampItem().getTimestampValue();
// lastTime = sqlTypes.millisFromTimeStamp(ts);
lastTime = sqlTypes.millisFromTimeStamp(getTableDefinition().getTimeStampItem().getValue());
lastLoadIndex = getTableDefinition().getIndexItem().getIntegerValue();
if (tableDef instanceof PamTableDefinition) {
PamTableDefinition pamTableDef = (PamTableDefinition) tableDef;
lastTime = sqlTypes.millisFromTimeStamp(pamTableDef.getTimeStampItem().getValue());
if (lastTime%1000 == 0) {
// some databases may have stored the milliseconds, in which
// case this next bit is redundant.
lastTime += getTableDefinition().getTimeStampMillis().getIntegerValue();
lastTime += pamTableDef.getTimeStampMillis().getIntegerValue();
}
lastLoadIndex = getTableDefinition().getIndexItem().getIntegerValue();
lastLoadUID = getTableDefinition().getUidItem().getLongObject();
lastChannelBitmap = getTableDefinition().getChannelBitmap().getIntegerValue();
lastSequenceBitmap = getTableDefinition().getSequenceBitmap().getIntegerObject();
lastLoadUID = pamTableDef.getUidItem().getLongObject();
lastChannelBitmap = pamTableDef.getChannelBitmap().getIntegerValue();
lastSequenceBitmap = pamTableDef.getSequenceBitmap().getIntegerObject();
}
return true;
} catch (SQLException ex) {
@ -1745,7 +1753,7 @@ public abstract class SQLLogging {
* annotation handler shortly after the main table is created.
* @return the baseTableDefinition
*/
public PamTableDefinition getBaseTableDefinition() {
public EmptyTableDefinition getBaseTableDefinition() {
return baseTableDefinition;
}

View File

@ -15,7 +15,7 @@ public interface SQLLoggingAddon {
* Add a load of columns to an existing table definition
* @param pamTableDefinition
*/
public void addTableItems(PamTableDefinition pamTableDefinition);
public void addTableItems(EmptyTableDefinition pamTableDefinition);
/**
* Save data - that is transfer data from the pamDataUnit to the data objects
@ -24,7 +24,7 @@ public interface SQLLoggingAddon {
* @param pamDataUnit data unit
* @return true if successful
*/
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit);
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit);
/**
* Load data - that is read data from the table definition and turn it into something sensible
@ -33,7 +33,7 @@ public interface SQLLoggingAddon {
* @param pamDataUnit data unit
* @return true if successful
*/
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit);
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit);
/**
* Get a name for the SQLLogging Addon. this is used

View File

@ -0,0 +1,94 @@
package generalDatabase;
import java.sql.Types;
import PamguardMVC.PamConstants;
public class XMLSettingsTableDefinition extends EmptyTableDefinition {
private PamTableItem dataStart, dataEnd, processStart, processEnd, type, name, pamGuardVersion, settingsVersion, xmlSettings;
public XMLSettingsTableDefinition(String tableName) {
super(tableName, SQLLogging.UPDATE_POLICY_WRITENEW);
pamTableItems.add(dataStart = new PamTableItem("Data Start", Types.TIMESTAMP, "Data start time"));
pamTableItems.add(dataEnd = new PamTableItem("Data End", Types.TIMESTAMP, "Data end time"));
pamTableItems.add(processStart = new PamTableItem("Process Start", Types.TIMESTAMP, "Process start time"));
pamTableItems.add(processEnd = new PamTableItem("Process End", Types.TIMESTAMP, "Process end time"));
addTableItem(type = new PamTableItem("unitType", Types.CHAR, PamConstants.MAX_ITEM_NAME_LENGTH));
addTableItem(name = new PamTableItem("unitName", Types.CHAR, PamConstants.MAX_ITEM_NAME_LENGTH));
addTableItem(pamGuardVersion = new PamTableItem("PAMGuardVersion", Types.INTEGER));
addTableItem(settingsVersion = new PamTableItem("SettingsVersion", Types.INTEGER));
addTableItem(xmlSettings = new PamTableItem("XMLSettings", Types.VARCHAR));
setUseCheatIndexing(false);
}
/**
* @return the dataStart
*/
public PamTableItem getDataStart() {
return dataStart;
}
/**
* @return the dataEnd
*/
public PamTableItem getDataEnd() {
return dataEnd;
}
/**
* @return the processStart
*/
public PamTableItem getProcessStart() {
return processStart;
}
/**
* @return the processEnd
*/
public PamTableItem getProcessEnd() {
return processEnd;
}
/**
* @return the type
*/
public PamTableItem getType() {
return type;
}
/**
* @return the name
*/
public PamTableItem getName() {
return name;
}
/**
* @return the pamGuardVersion
*/
public PamTableItem getPamGuardVersion() {
return pamGuardVersion;
}
/**
* @return the settingsVersion
*/
public PamTableItem getSettingsVersion() {
return settingsVersion;
}
/**
* @return the xmlSettings
*/
public PamTableItem getXmlSettings() {
return xmlSettings;
}
}

View File

@ -5,6 +5,7 @@ import java.sql.Types;
import PamDetection.AcousticSQLLogging;
import PamguardMVC.PamDataBlock;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLTypes;
@ -22,7 +23,7 @@ public class GPLLogging extends AcousticSQLLogging {
super(gplDetectionBlock, gplControlledUnit.getUnitName() + " Detections");
this.gplControlledUnit = gplControlledUnit;
PamTableDefinition pamTable = getTableDefinition();
EmptyTableDefinition pamTable = getTableDefinition();
pamTable.addTableItem(peakValue = new PamTableItem("PeakValue", Types.REAL));
pamTable.addTableItem(contourArea = new PamTableItem("ContourArea", Types.REAL));
}

View File

@ -1,5 +1,6 @@
package loc3d_Thode;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamDetectionLogging;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
@ -17,7 +18,6 @@ public class TowedArray3DSQLLogging extends PamDetectionLogging {
TowedArray3DController towedArray3DController;
PamTableDefinition tableDefinition;
PamTableItem dateItem, range_boat_Item, range_f_Item, range_r_Item, depthItem, azi_boat_Item,azi_f_Item, azi_r_Item, tdd_Item,
bearing_f_Item,bearing_r_Item, tds_f_Item, tds_r_Item, za_f_Item, za_r_Item;
@ -34,14 +34,14 @@ public class TowedArray3DSQLLogging extends PamDetectionLogging {
this.towedArray3DController = towedArray3DController;
// create the table definition.
tableDefinition = createTableDefinition();
EmptyTableDefinition tableDefinition = createTableDefinition();
}
public PamTableDefinition createTableDefinition() {
public EmptyTableDefinition createTableDefinition() {
// PamTableDefinition tableDef = new PamTableDefinition(towedArray3DController.getUnitName(), getUpdatePolicy());
PamTableDefinition tableDef = super.getTableDefinition();
EmptyTableDefinition tableDef = super.getTableDefinition();
tableDef.setUpdatePolicy(SQLLogging.UPDATE_POLICY_WRITENEW);
// PamTableItem tableItem;

View File

@ -7,6 +7,7 @@ import java.util.List;
import PamUtils.PamArrayUtils;
import PamguardMVC.PamDataUnit;
import PamguardMVC.debug.Debug;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLLoggingAddon;
@ -49,7 +50,7 @@ public class MatchedClickAnnotationSQL implements SQLLoggingAddon {
}
@Override
public void addTableItems(PamTableDefinition pamTableDefinition) {
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
pamTableDefinition.addTableItem(typeTable);
pamTableDefinition.addTableItem(mtThresholdsTable);
pamTableDefinition.addTableItem(mtMatchCorrsTable);
@ -58,7 +59,7 @@ public class MatchedClickAnnotationSQL implements SQLLoggingAddon {
}
@Override
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
MatchedClickAnnotation clickAnnotation =
(MatchedClickAnnotation) pamDataUnit.findDataAnnotation(MatchedClickAnnotation.class);
@ -95,7 +96,7 @@ public class MatchedClickAnnotationSQL implements SQLLoggingAddon {
}
@Override
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
String threshold = mtThresholdsTable.getDeblankedStringValue();
String mtMatchCorrs = mtMatchCorrsTable.getDeblankedStringValue();

View File

@ -3,6 +3,7 @@ package nidaqdev.networkdaq;
import java.sql.Types;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLLoggingAddon;
@ -20,12 +21,12 @@ public class NIDaqLogging implements SQLLoggingAddon {
}
@Override
public void addTableItems(PamTableDefinition pamTableDefinition) {
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
pamTableDefinition.addTableItem(crioTemperature);
}
@Override
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
Double lastTemp = niNetworkDaq.getLastTemperature();
if (lastTemp == null) {
crioTemperature.setValue(null);
@ -38,7 +39,7 @@ public class NIDaqLogging implements SQLLoggingAddon {
}
@Override
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
// TODO Auto-generated method stub
return false;
}

View File

@ -1,6 +1,7 @@
package rawDeepLearningClassifier.logging;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.SQLLoggingAddon;
import generalDatabase.SQLTypes;
@ -12,19 +13,19 @@ public class DLAnnotationSQL implements SQLLoggingAddon {
}
@Override
public void addTableItems(PamTableDefinition pamTableDefinition) {
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
// TODO Auto-generated method stub
}
@Override
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition, PamDataUnit pamDataUnit) {
// TODO Auto-generated method stub
return false;
}

View File

@ -15,6 +15,7 @@ import PamDetection.AbstractLocalisation;
import PamDetection.LocContents;
import PamUtils.LatLong;
import PamguardMVC.PamDataUnit;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
import generalDatabase.SQLLoggingAddon;
@ -119,7 +120,7 @@ public class TargetMotionSQLLogging implements SQLLoggingAddon {
}
@Override
public void addTableItems(PamTableDefinition pamTableDefinition) {
public void addTableItems(EmptyTableDefinition pamTableDefinition) {
pamTableDefinition.addTableItem(modelName);
@ -146,7 +147,7 @@ public class TargetMotionSQLLogging implements SQLLoggingAddon {
}
@Override
public boolean saveData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
public boolean saveData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
PamDataUnit pamDataUnit) {
AbstractLocalisation tmResult = pamDataUnit.getLocalisation();
clearEverything();
@ -218,7 +219,7 @@ public class TargetMotionSQLLogging implements SQLLoggingAddon {
return true;
}
private boolean saveGroupLocalisation(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
private boolean saveGroupLocalisation(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
PamDataUnit pamDataUnit, GroupLocalisation groupLocalisation) {
int nAmbiguities = groupLocalisation.getAmbiguityCount();
@ -239,7 +240,7 @@ public class TargetMotionSQLLogging implements SQLLoggingAddon {
return true;
}
private boolean saveGroupLocalisation(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
private boolean saveGroupLocalisation(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
PamDataUnit pamDataUnit, int resultIndex, GroupLocResult tmResult) {
@ -323,7 +324,7 @@ public class TargetMotionSQLLogging implements SQLLoggingAddon {
}
@Override
public boolean loadData(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
public boolean loadData(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
PamDataUnit pamDataUnit) {
GroupLocalisation tml = new GroupLocalisation(pamDataUnit, null);
@ -341,7 +342,7 @@ public class TargetMotionSQLLogging implements SQLLoggingAddon {
return true;
}
private GroupLocResult loadLocResult(SQLTypes sqlTypes, PamTableDefinition pamTableDefinition,
private GroupLocResult loadLocResult(SQLTypes sqlTypes, EmptyTableDefinition pamTableDefinition,
PamDataUnit pamDataUnit, GroupLocalisation tml, int resultIndex) {
double latVal, longVal;

View File

@ -1,5 +1,6 @@
package whistleDetector;
import generalDatabase.EmptyTableDefinition;
import generalDatabase.PamDetectionLogging;
import generalDatabase.PamTableDefinition;
import generalDatabase.PamTableItem;
@ -24,7 +25,7 @@ public class WhistleLogger extends PamDetectionLogging {
this.whistleControl = whistleControl;
PamTableDefinition tableDefinition = getTableDefinition();
EmptyTableDefinition tableDefinition = getTableDefinition();
tableDefinition.addTableItem(sliceCount = new PamTableItem("SliceCount", Types.INTEGER));
tableDefinition.addTableItem(length = new PamTableItem("WhistleLength", Types.DOUBLE));
tableDefinition.addTableItem(minFreq = new PamTableItem("MinFreq", Types.DOUBLE));