From ae6e2f947b886810a5ebf35f8b2e2e6e9cd822cc Mon Sep 17 00:00:00 2001 From: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com> Date: Tue, 13 Sep 2022 09:12:34 +0100 Subject: [PATCH] Merge Dougs fork (#53) * Variable sound output level Mods to SoundPlayback module to allow additional parameters. Implemented system for NI cards to allow changes to selected output voltage range meaning output can be boosted to level higher than current default. * Code to support nogui operations when no screens present on headless system * Fix problem of nogui headless operation trying to access screen size. * Click detector display fixes 1. ICI not displaying correctly 2. Component sizes in display dialog on hres monitors * Work on batch processing, after testing of options to autostart, autoexit and set wav file folder, database and binary store. * Update MHTClickTrainAlgorithm.java Fix unsynchronised access to a datablock in click train detector which was causing index errors. * Revamp of offline process messaging and control Includes some databsae logging of completed tasks * Offline task logging Bit more work, including notes and database storage of task reprocessing. Guess this could all become 'proper' PAMGuard data and be shown in a table on the display but that not priority enough. * Dialog packing Fix a couple of dialogs which don't back well on HDPI monitors * UDP Control Added multiport functionality * Java version Changes unpacker to deal with non numeric characters on Linux * Fix to getVersion() So new version of this command should now work on Linux and Windows. * Multiport test Quick tester for multiport comms * Spectrogram display Stop spectrogram display continually recreating panels since it was unsubscribing discarded ones and sometimes causing crash in observable notifications. * Backup manager bug Error if no database. Fixed. * Daylight saving problem Fix daylight saving problem in generation of timestamps in SQLTypes. See long explanation in SQLTypes.java. Only occurred in the hour after daylight saving starts. --- src/PamUtils/PamCalendar.java | 3 ++- src/generalDatabase/SQLTypes.java | 23 +++++++++++++++++++++-- src/pamguard/Pamguard.java | 3 +++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/PamUtils/PamCalendar.java b/src/PamUtils/PamCalendar.java index 8a43bb74..3ce2eebc 100644 --- a/src/PamUtils/PamCalendar.java +++ b/src/PamUtils/PamCalendar.java @@ -83,7 +83,8 @@ public class PamCalendar { * viewPositions which is the number of milliseconds from the sessionsStartTime. */ private static long viewPosition; - + + /** * If files are being analysed, return the time based on the file * position. Otherwise just take the normal system time. diff --git a/src/generalDatabase/SQLTypes.java b/src/generalDatabase/SQLTypes.java index b8746472..a81edd89 100644 --- a/src/generalDatabase/SQLTypes.java +++ b/src/generalDatabase/SQLTypes.java @@ -337,11 +337,30 @@ public class SQLTypes { * @return Appropriate object (Generally TimeStamp, but SWLite uses Long) */ public Object getTimeStamp(Long timeMillis) { + /** + * This has just got nasty WRT time zones. + * When the TimeStamp is written to database it uses the default time zone correction, which of course + * I don't want since I only do UTC. I was therefore subtracting this off before creating the ts + * so that it all worked fine when it was added back on again. + * This was fine for many years until someone processed data from exactly when the clocks went + * forward in the spring. Because the data were just after the clocks going forward, it took off + * an hour, then failed to add it back on again since the time was now before daylight saving. + * Amazed this has never happened before. Well done G and E ! I can fix it by setting the + * default time zone to UTC when PAMGuard starts, but note that all future references to local time + * will then be UTC. If I try to change it temporarily it doesn't help since the Timestamp always + * goes to the default, so it needs to be on UTC at the moment data are written to the database, not + * just in this function. + */ if (timeMillis == null) { return null; } - TimeZone tz = TimeZone.getDefault(); - return new Timestamp(timeMillis - tz.getOffset(timeMillis)); +// TimeZone tz = TimeZone.getDefault(); +// TimeZone.setDefault(PamCalendar.defaultTimeZone); +// Timestamp ts = new Timestamp(timeMillis - tz.getOffset(timeMillis)); + Timestamp ts = new Timestamp(timeMillis); +// TimeZone.setDefault(tz); +// Timestamp newTS = ts.toLocalDateTime(); + return ts; } /** diff --git a/src/pamguard/Pamguard.java b/src/pamguard/Pamguard.java index c955192a..d5825b26 100644 --- a/src/pamguard/Pamguard.java +++ b/src/pamguard/Pamguard.java @@ -33,6 +33,7 @@ import PamController.pamBuoyGlobals; import PamController.command.TerminalController; import PamModel.SMRUEnable; import PamUtils.FileFunctions; +import PamUtils.PamCalendar; import PamUtils.PamExceptionHandler; import PamUtils.PlatformInfo; import PamUtils.Splash; @@ -134,6 +135,8 @@ public class Pamguard { Thread folderSizeThread = new Thread(folderSizeMon); folderSizeThread.start(); + TimeZone.setDefault(PamCalendar.defaultTimeZone); + System.out.println("**********************************************************"); try { // get the java runnable file name.