Squashed commit of the following:

commit 577670ccd0
Merge: 6510d226 8b5b5b2f
Author: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com>
Date:   Mon Jul 22 09:35:01 2024 +0100

    Merge branch 'main' of https://github.com/PAMGuard/PAMGuard

commit 6510d2260e
Author: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com>
Date:   Mon Jul 22 09:34:58 2024 +0100

    Remove unnecessary text output

commit 3da8401756
Author: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com>
Date:   Mon Jul 22 09:29:38 2024 +0100

    updates to Daq

    New DLL, and some LED control, but hasn't fixed stalling problem.

commit 8b5b5b2f18
Author: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com>
Date:   Fri Jul 19 17:14:28 2024 +0100

    Updated data selectors for BT display

    Merging old status bar and new DataSelector options so that they work more consistently on the BT display.

commit bad2255710
Author: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com>
Date:   Thu Jul 18 09:47:47 2024 +0100

    Better symbol options

    Add clearer options button to multi option symbol manager panel.
This commit is contained in:
Jamie Mac 2024-07-22 11:50:50 +01:00
parent 747a2b2284
commit a993b27155
4 changed files with 81 additions and 19 deletions

Binary file not shown.

View File

@ -19,6 +19,9 @@ public class SmruDaqJNI {
static public final int SMRU_VAL_SLAVE_MASTERED = 3;
static public final int SMRU_RET_OK = 0;
static public final int GREEN_LED = 1;
static public final int RED_LED = 0;
/**
* Have rebuilt SAIL Daq interface in 2022, but in principle this was
@ -29,11 +32,6 @@ public class SmruDaqJNI {
private static final String SILIB = "SailDaqJNI";
// private static final String SILIB = "SailDaqV7";
/**
* this is the verbose level for the C code part.
*/
private static final int verboseLevel = 0;
private static final String DEVNAME = "/dev/cypress_smru0";
private static final int MINJNIVERSION = 5;
@ -265,7 +263,7 @@ public class SmruDaqJNI {
this.smruDaqSystem = smruDaqSystem;
loadLibrary();
if (haveLibrary()) {
setVerbose(verboseLevel);
setVerbose(SmruDaqSystem.VERBOSELEVEL);
/**
* List the devices, but don't do any resetting and
@ -492,7 +490,7 @@ public class SmruDaqJNI {
public int toggleLED(int board, int led) {
board = boardOrder[board];
int state = getLED(board, led);
System.out.println("state="+state);
// System.out.println("LED state="+state);
if (state == 0) {
state = 1;
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -13,6 +14,7 @@ import soundPlayback.PlaybackControl;
import soundPlayback.PlaybackSystem;
import Acquisition.AcquisitionControl;
import Acquisition.AcquisitionDialog;
import Acquisition.AcquisitionProcess;
import Acquisition.DaqSystem;
import Acquisition.AudioDataQueue;
import PamController.PamControlledUnitSettings;
@ -49,7 +51,8 @@ public class SmruDaqSystem extends DaqSystem implements PamSettings {
public static final String oldCardName = "SMRU Ltd DAQ Card";
private static final int VERBOSELEVEL = 0;
public static final int VERBOSELEVEL = 0;
/**
* @param daqControl
@ -61,6 +64,11 @@ public class SmruDaqSystem extends DaqSystem implements PamSettings {
smruDaqJNI = new SmruDaqJNI(this);
nDaqCards = smruDaqJNI.getnDevices();
for (int i = 0; i < nDaqCards; i++) {
for (int l = 0; l < 2; l++) {
smruDaqJNI.setLED(i, l, 0);
}
}
smruDaqDialogPanel = new SmruDaqDialogPanel(this);
PamSettingManager.getInstance().registerSettings(this);
@ -275,6 +283,8 @@ public class SmruDaqSystem extends DaqSystem implements PamSettings {
boolean prepareDaqCard(int iBoard, boolean fullReset) {
// devices are left closed, so will need to reopen them.
// of course, there is a vile lookup table, so...
smruDaqJNI.setLED(iBoard, SmruDaqJNI.GREEN_LED, 0);
smruDaqJNI.setLED(iBoard, SmruDaqJNI.RED_LED, 0);
int hardId = smruDaqJNI.getBoardOrder(iBoard);
int prepOk = smruDaqJNI.prepareDevice(hardId, fullReset);
terminalPrint("Opened daq card returned " + prepOk, 1);
@ -313,6 +323,7 @@ public class SmruDaqSystem extends DaqSystem implements PamSettings {
if (ans) {
Thread t = new Thread(new DaqThread());
t.setPriority(Thread.MAX_PRIORITY);
t.start();
keepRunning = true;
daqThreadRunning = true;
@ -371,18 +382,43 @@ public class SmruDaqSystem extends DaqSystem implements PamSettings {
boolean first = true;
boolean needRestart = false;
int iChan;
// some flags on checks of incoming data rate
// long recentSamples = 0;
// long recentCheckTime = System.currentTimeMillis();
int loopCount = 0;
for (int iBoard = 0; iBoard < nDaqCards; iBoard++) {
smruDaqJNI.setLED(iBoard, SmruDaqJNI.GREEN_LED, 1);
smruDaqJNI.setLED(iBoard, SmruDaqJNI.RED_LED, 0);
}
while (keepRunning) {
iChan = 0;
dataMillis = daqControl.getAcquisitionProcess().absSamplesToMilliseconds(totalSamples);
if (isStalled()) {
needRestart = true;
for (int iBoard = 0; iBoard < nDaqCards; iBoard++) {
smruDaqJNI.setLED(iBoard, SmruDaqJNI.GREEN_LED, 0);
smruDaqJNI.setLED(iBoard, SmruDaqJNI.RED_LED, 1);
}
// don't set this false or the shutdown doesn't work properly.
// keepRunning = false;
break;
}
loopCount++;
for (int iBoard = 0; iBoard < nDaqCards && keepRunning; iBoard++) {
if ((loopCount % 10000) == 0) {
// toggleLED(iBoard, 0);
smruDaqJNI.setLED(iBoard, SmruDaqJNI.GREEN_LED, 1);
}
for (int i = 0; i < boardChannels[iBoard] && keepRunning; i++) {
newData = smruDaqJNI.readSamples(iBoard, i, wantedSamples);
if (newData == null) {
smruDaqJNI.setLED(iBoard, SmruDaqJNI.RED_LED, 1);
System.out.println(String.format("Null data read from smruDaqJNI.readSamples board %d, chan %d, samples %d",
iBoard, i, wantedSamples));
// System.out.println("Issue restart ...");
needRestart = true;
keepRunning = false;
// keepRunning = false;
break;
}
readSamples = newData.length;
@ -409,19 +445,47 @@ public class SmruDaqSystem extends DaqSystem implements PamSettings {
if (++dcOffsetCalls == 100) {
dcOffsetScale = 100.; // after a bit, increase the time constant.
}
totalSamples += readSamples;
}
};
daqThreadRunning = false;
if (needRestart) {
PamController pamController = PamController.getInstance();
pamController.pamStop();
PamDialog.showWarning(daqControl.getGuiFrame(), daqControl.getUnitName(), "Problem with one or more SAIL DAQ Cards.\n"
+ "Restart PAMGuard, check connections and try again." );
// pamController.startLater();
for (int iBoard = 0; iBoard < nDaqCards; iBoard++) {
smruDaqJNI.setLED(iBoard, SmruDaqJNI.GREEN_LED, 0);
}
if (needRestart) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
PamController pamController = PamController.getInstance();
pamController.pamStop();
System.out.println("Problem with one or more SAIL DAQ Cards. "
+ "Restart PAMGuard, check connections and try again." );
// PamDialog.showWarning(daqControl.getGuiFrame(), daqControl.getUnitName(), "Problem with one or more SAIL DAQ Cards.\n"
// + "Restart PAMGuard, check connections and try again." );
pamController.startLater();
}
});
}
}
// private long lastFakeStall = 0;
private boolean isStalled() {
// if (lastFakeStall == 0) {
// lastFakeStall = System.currentTimeMillis();
// }
// long now = System.currentTimeMillis();
// if (now-lastFakeStall > 10000) {
// System.out.println("Random pretend stalled");
// lastFakeStall = 0;
// return true;
// }
return daqControl.getAcquisitionProcess().isStalled();
}
public static short getSample(byte[] buffer, int position) {

View File

@ -236,9 +236,9 @@ public class NoiseBandControl extends PamControlledUnit implements PamSettings {
@Override
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
noiseBandSettings = ((NoiseBandSettings)pamControlledUnitSettings.getSettings()).clone();
System.out.println("********************************************************");
System.out.println("NOISE BAND SETTINGS: " + noiseBandSettings.rawDataSource);
System.out.println("********************************************************");
// System.out.println("********************************************************");
// System.out.println("NOISE BAND SETTINGS: " + noiseBandSettings.rawDataSource);
// System.out.println("********************************************************");
return true;
}