From 915026c0becb8c9bec800118d23ba51ccc53fc5e Mon Sep 17 00:00:00 2001 From: gac-iss Date: Thu, 23 Oct 2025 10:10:28 +0200 Subject: [PATCH] Minimum step time (default=42ms) --- src/main/java/Scienta.java | 28 +++++++++++++++++++---- src/main/java/ScientaPanel.java | 4 +--- src/main/java/ScientaParametersPanel.java | 4 +--- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/main/java/Scienta.java b/src/main/java/Scienta.java index b0c30a4..4308bd9 100644 --- a/src/main/java/Scienta.java +++ b/src/main/java/Scienta.java @@ -28,6 +28,7 @@ public class Scienta extends AreaDetector { final Stats[] stats; final String channelCtrl; int frameTime = 14; + int minStepTime = 42; public Scienta(final String name, final String channelPrefix) { this(name, channelPrefix + ":cam1", channelPrefix + ":image1"); @@ -130,7 +131,8 @@ public class Scienta extends AreaDetector { public void onValueChanged(Device device, Object value, Object former) { int time_ms = (int) (((Double) value) * 1000); int num_frames = time_ms / getFrameTimeMs(); - if (num_frames != frames.take()){ + Integer cur = frames.take(); + if ((cur==null) || (num_frames != cur)){ frames.writeAsync(num_frames); } } @@ -139,9 +141,7 @@ public class Scienta extends AreaDetector { public void onValueChanging(Device device, Object value, Object former) throws Exception { //Value must be multiple of getFrameTimeMs() int val_ms = (int) (((Double) value) * 1000); - if ((val_ms % getFrameTimeMs()) != 0){ - throw new IOException("Value must be multiple of " + getFrameTimeMs() + "ms"); - } + checkTimeValue(val_ms); } }); @@ -161,12 +161,30 @@ public class Scienta extends AreaDetector { public int getFrameTimeMs() { return frameTime; - } + } public void setFrameTimeMs(int value) { frameTime = value; } + public int getMinStepTimeMs() { + return minStepTime; + } + + public void setMinStepTimeMs(int value) { + minStepTime = value; + } + + public void checkTimeValue(int val_ms) throws IOException{ + if ((val_ms % getFrameTimeMs()) != 0){ + throw new IOException("Value must be multiple of " + getFrameTimeMs() + "ms"); + } + if (val_ms < getMinStepTimeMs()){ + throw new IOException("Value must be equal or greater than " + getMinStepTimeMs() + "ms"); + } + + } + public class ScientaSpectrum extends ChannelDoubleArray implements ReadableCalibratedArray { ScientaSpectrum() { diff --git a/src/main/java/ScientaPanel.java b/src/main/java/ScientaPanel.java index 05f6a12..9e31bd3 100644 --- a/src/main/java/ScientaPanel.java +++ b/src/main/java/ScientaPanel.java @@ -44,9 +44,7 @@ public final class ScientaPanel extends DevicePanel { getDevice().getHighEnergy().writeAsync(value); } else if (origin == valueTime) { int val_ms = (int) (((Double) value) * 1000); - if ((val_ms % getDevice().getFrameTimeMs()) != 0){ - throw new IOException("Value must be multiple of " + getDevice().getFrameTimeMs() + "ms"); - } + getDevice().checkTimeValue(val_ms); getDevice().getStepTime().writeAsync(value); } else if (origin == valueSize) { getDevice().getStepSize().writeAsync(value); diff --git a/src/main/java/ScientaParametersPanel.java b/src/main/java/ScientaParametersPanel.java index 1d087cd..ae8f548 100644 --- a/src/main/java/ScientaParametersPanel.java +++ b/src/main/java/ScientaParametersPanel.java @@ -38,9 +38,7 @@ public final class ScientaParametersPanel extends DevicePanel { if (editing) { try{ int val_ms = (int) (((Double) value) * 1000); - if ((val_ms % getDevice().getFrameTimeMs()) != 0){ - throw new IOException("Value must be multiple of " + getDevice().getFrameTimeMs() + "ms"); - } + getDevice().checkTimeValue(val_ms); } catch (Exception ex) { showException(ex); }