numass cryotemp update
This commit is contained in:
parent
f3ecec7dfc
commit
4e179d6814
@ -5,6 +5,8 @@ if (!hasProperty('mainClass')) {
|
||||
}
|
||||
mainClassName = mainClass
|
||||
|
||||
version = "0.1.1";
|
||||
|
||||
//mainClassName = "inr.numass.readvac.Main"
|
||||
|
||||
dependencies {
|
||||
|
@ -38,7 +38,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @author darksnake
|
||||
@ -76,7 +75,7 @@ public class PKT8App extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws IOException, ControlException, ParseException {
|
||||
Locale.setDefault(Locale.US);// чтобы отделение десятичных знаков было точкой
|
||||
// Locale.setDefault(Locale.US);// чтобы отделение десятичных знаков было точкой
|
||||
ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
|
||||
rootLogger.setLevel(Level.INFO);
|
||||
new StorageManager().startGlobal();
|
||||
|
@ -36,9 +36,9 @@ import hep.dataforge.storage.commons.LoaderFactory;
|
||||
import hep.dataforge.tables.DataPoint;
|
||||
import hep.dataforge.tables.PointListener;
|
||||
import hep.dataforge.tables.TableFormatBuilder;
|
||||
import hep.dataforge.utils.DateTimeUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -261,7 +261,7 @@ public class PKT8Device extends PortSensor<PKT8Result> {
|
||||
.map(it -> ((StorageConnection) it.getKey()).getStorage()).collect(Collectors.toList());
|
||||
|
||||
storages.forEach(storage -> {
|
||||
String suffix = Integer.toString((int) Instant.now().toEpochMilli());
|
||||
String suffix = Integer.toString((int) DateTimeUtils.now().toEpochMilli());
|
||||
|
||||
PointLoader pointLoader = null;
|
||||
try {
|
||||
|
@ -18,6 +18,9 @@ package inr.numass.control.magnet;
|
||||
import hep.dataforge.control.ports.PortHandler;
|
||||
import hep.dataforge.control.ports.PortTimeoutException;
|
||||
import hep.dataforge.exceptions.PortException;
|
||||
import hep.dataforge.utils.DateTimeUtils;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
@ -25,7 +28,6 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -34,46 +36,28 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class MagnetController implements PortHandler.PortController {
|
||||
|
||||
private static final DecimalFormat LAMBDAformat = new DecimalFormat("###.##");
|
||||
public static double CURRENT_PRECISION = 0.05;
|
||||
// public static double CURRENT_STEP = 0.05;
|
||||
public static int DEFAULT_DELAY = 1;
|
||||
public static int DEFAULT_MONITOR_DELAY = 2000;
|
||||
|
||||
public static double MAX_STEP_SIZE = 0.2;
|
||||
public static double MIN_UP_STEP_SIZE = 0.005;
|
||||
public static double MIN_DOWN_STEP_SIZE = 0.05;
|
||||
public static double MAX_SPEED = 5d; // 5 A per minute
|
||||
|
||||
private static final DecimalFormat LAMBDAformat = new DecimalFormat("###.##");
|
||||
|
||||
/**
|
||||
* Method converts double to LAMBDA string
|
||||
*
|
||||
* @param d double that should be converted to string
|
||||
* @return string
|
||||
*/
|
||||
private static String d2s(double d) {
|
||||
return LAMBDAformat.format(d);
|
||||
}
|
||||
|
||||
public static double MAX_SPEED = 5d; // 5 A per minute
|
||||
private final String name;
|
||||
|
||||
private final PortHandler port;
|
||||
private final int address;
|
||||
private final ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(1);
|
||||
protected MagnetStateListener listener;
|
||||
private volatile double current = 0;
|
||||
|
||||
private int timeout = 200;
|
||||
private Future monitorTask;
|
||||
private Future updateTask;
|
||||
|
||||
protected MagnetStateListener listener;
|
||||
|
||||
private Instant lastUpdate = null;
|
||||
|
||||
private double speed = MAX_SPEED;
|
||||
|
||||
private final ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(1);
|
||||
|
||||
/**
|
||||
* This method creates an element of class MegnetController with exact
|
||||
* parameters. If you have two parameters for your method - the next
|
||||
@ -104,6 +88,16 @@ public class MagnetController implements PortHandler.PortController {
|
||||
this(name, port, address, 300);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method converts double to LAMBDA string
|
||||
*
|
||||
* @param d double that should be converted to string
|
||||
* @return string
|
||||
*/
|
||||
private static String d2s(double d) {
|
||||
return LAMBDAformat.format(d);
|
||||
}
|
||||
|
||||
public void setListener(MagnetStateListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
@ -180,7 +174,7 @@ public class MagnetController implements PortHandler.PortController {
|
||||
if (!setState("PC", current)) {
|
||||
error("Can't set the current", null);
|
||||
} else {
|
||||
lastUpdate = Instant.now();
|
||||
lastUpdate = DateTimeUtils.now();
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,7 +193,6 @@ public class MagnetController implements PortHandler.PortController {
|
||||
* Gets status of magnet for current moment
|
||||
*
|
||||
* @return status of magnet
|
||||
* @throws inr.numass.control.magnet.PortException
|
||||
*/
|
||||
private MagnetStatus getStatus() throws PortException {
|
||||
try {
|
||||
@ -326,7 +319,7 @@ public class MagnetController implements PortHandler.PortController {
|
||||
} else {
|
||||
//Choose optimal speed but do not exceed maximum speed
|
||||
step = Math.min(MAX_STEP_SIZE,
|
||||
(double) lastUpdate.until(Instant.now(), ChronoUnit.MILLIS) / 60000d * getSpeed());
|
||||
(double) lastUpdate.until(DateTimeUtils.now(), ChronoUnit.MILLIS) / 60000d * getSpeed());
|
||||
}
|
||||
|
||||
double res;
|
||||
|
@ -19,12 +19,14 @@ import ch.qos.logback.classic.Level;
|
||||
import hep.dataforge.control.ports.PortFactory;
|
||||
import hep.dataforge.control.ports.PortHandler;
|
||||
import hep.dataforge.exceptions.PortException;
|
||||
import hep.dataforge.utils.DateTimeUtils;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Locale;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -57,10 +59,10 @@ public class Talk {
|
||||
|
||||
while (!"exit".equals(nextString)) {
|
||||
try {
|
||||
Instant start = Instant.now();
|
||||
Instant start = DateTimeUtils.now();
|
||||
String answer = handler.sendAndWait(nextString + "\r", null, 1000);
|
||||
//String answer = controller.request(nextString);
|
||||
System.out.printf("ANSWER (latency = %s): %s;%n", Duration.between(start, Instant.now()), answer.trim());
|
||||
System.out.printf("ANSWER (latency = %s): %s;%n", Duration.between(start, DateTimeUtils.now()), answer.trim());
|
||||
} catch (PortException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import hep.dataforge.tables.DataPoint;
|
||||
import hep.dataforge.tables.MapPoint;
|
||||
import hep.dataforge.tables.TableFormat;
|
||||
import hep.dataforge.tables.TableFormatBuilder;
|
||||
import hep.dataforge.utils.DateTimeUtils;
|
||||
import hep.dataforge.values.Value;
|
||||
|
||||
import java.time.Instant;
|
||||
@ -405,7 +406,7 @@ public class MspDevice extends SingleMeasurementDevice implements PortHandler.Po
|
||||
|
||||
TableFormat format = builder.build();
|
||||
|
||||
String suffix = Integer.toString((int) Instant.now().toEpochMilli());
|
||||
String suffix = Integer.toString((int) DateTimeUtils.now().toEpochMilli());
|
||||
PointLoader loader = LoaderFactory
|
||||
.buildPointLoder(storage, "msp" + suffix, "", "timestamp", format);
|
||||
return loader;
|
||||
@ -491,7 +492,7 @@ public class MspDevice extends SingleMeasurementDevice implements PortHandler.Po
|
||||
throw new IllegalStateException("Peal map is not initialized");
|
||||
}
|
||||
|
||||
Instant time = Instant.now();
|
||||
Instant time = DateTimeUtils.now();
|
||||
|
||||
MapPoint.Builder point = new MapPoint.Builder();
|
||||
point.putValue("timestamp", time);
|
||||
|
@ -14,7 +14,7 @@ import hep.dataforge.storage.api.Storage;
|
||||
import hep.dataforge.storage.commons.LoaderFactory;
|
||||
import hep.dataforge.tables.TableFormatBuilder;
|
||||
import hep.dataforge.values.ValueType;
|
||||
import inr.numass.client.NumassClient;
|
||||
import inr.numass.client.ClientUtils;
|
||||
import inr.numass.readvac.devices.*;
|
||||
import inr.numass.readvac.fx.VacCollectorController;
|
||||
import javafx.application.Application;
|
||||
@ -35,6 +35,13 @@ public class ReadVac extends Application {
|
||||
VacCollectorController controller;
|
||||
Logger logger = LoggerFactory.getLogger("ReadVac");
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
String configFileName = getParameters().getNamed().get("config");
|
||||
@ -78,18 +85,18 @@ public class ReadVac extends Application {
|
||||
|
||||
controller.setLoaderFactory((VacCollectorDevice device, Storage localStorage) -> {
|
||||
try {
|
||||
String runName = device.meta().getString("numass.run", "");
|
||||
if (config.hasMeta("numass")) {
|
||||
try {
|
||||
logger.info("Obtaining run information from cetral server...");
|
||||
NumassClient client = new NumassClient(config.getString("numass.ip", "192.168.111.1"),
|
||||
config.getInt("numass.port", 8335));
|
||||
runName = client.getCurrentRun().getString("path", "");
|
||||
logger.info("Run name is '{}'", runName);
|
||||
} catch (Exception ex) {
|
||||
logger.warn("Failed to download current run information", ex);
|
||||
}
|
||||
}
|
||||
String runName = ClientUtils.getRunName(config);
|
||||
// String runName = device.meta().getString("numass.run", "");
|
||||
// if (config.hasMeta("numass.server")) {
|
||||
// try {
|
||||
// logger.info("Obtaining run information from cetral server...");
|
||||
// NumassClient client = new NumassClient(get);
|
||||
// runName = client.getCurrentRun().getString("path", "");
|
||||
// logger.info("Run name is '{}'", runName);
|
||||
// } catch (Exception ex) {
|
||||
// logger.warn("Failed to download current run information", ex);
|
||||
// }
|
||||
// }
|
||||
|
||||
TableFormatBuilder format = new TableFormatBuilder().setType("timestamp", ValueType.TIME);
|
||||
device.getSensors().stream().forEach((s) -> {
|
||||
@ -120,11 +127,4 @@ public class ReadVac extends Application {
|
||||
super.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import hep.dataforge.exceptions.MeasurementException;
|
||||
import hep.dataforge.tables.DataPoint;
|
||||
import hep.dataforge.tables.MapPoint;
|
||||
import hep.dataforge.tables.PointListener;
|
||||
import hep.dataforge.utils.DateTimeUtils;
|
||||
import hep.dataforge.values.Value;
|
||||
|
||||
import java.time.Instant;
|
||||
@ -134,7 +135,7 @@ public class VacCollectorDevice extends Sensor<DataPoint> {
|
||||
|
||||
private DataPoint terminator() {
|
||||
MapPoint.Builder p = new MapPoint.Builder();
|
||||
p.putValue("timestamp", Instant.now());
|
||||
p.putValue("timestamp", DateTimeUtils.now());
|
||||
sensorMap.keySet().stream().forEach((n) -> {
|
||||
p.putValue(n, null);
|
||||
});
|
||||
|
@ -1,25 +1,23 @@
|
||||
/*
|
||||
* Copyright 2015 Alexander Nozik.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2015 Alexander Nozik.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package inr.numass.readvac;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
import hep.dataforge.utils.DateTimeUtils;
|
||||
|
||||
import java.time.*;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -31,7 +29,7 @@ public class TimeShiftTest {
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Instant now = Instant.now();
|
||||
Instant now = DateTimeUtils.now();
|
||||
System.out.println(now.toString());
|
||||
LocalDateTime ldt = LocalDateTime.now();
|
||||
System.out.println(ldt.toString());
|
||||
|
@ -8,17 +8,17 @@ import java.io.IOException;
|
||||
* Created by darksnake on 09-Oct-16.
|
||||
*/
|
||||
public class ClientUtils {
|
||||
public String getRunName(Meta config) {
|
||||
public static String getRunName(Meta config) {
|
||||
if (config.hasValue("numass.run")) {
|
||||
return config.getString("numass.run");
|
||||
} else if (config.hasMeta("numass.server")) {
|
||||
try {
|
||||
return new NumassClient(config.getMeta("numass.server")).getCurrentRun().getString("path");
|
||||
} catch (IOException e) {
|
||||
return "default";
|
||||
return "";
|
||||
}
|
||||
} else {
|
||||
return "default";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ package inr.numass.server;
|
||||
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.meta.MetaBuilder;
|
||||
import hep.dataforge.utils.DateTimeUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
|
||||
@ -17,20 +19,9 @@ import java.time.Instant;
|
||||
*/
|
||||
public class NumassNote implements Serializable {
|
||||
|
||||
public static NumassNote buildFrom(Meta meta) {
|
||||
String text = meta.getString("text", "");
|
||||
if (meta.hasValue("time")) {
|
||||
Instant time = meta.getValue("time").timeValue();
|
||||
return new NumassNote(text, time);
|
||||
} else {
|
||||
return new NumassNote(text);
|
||||
}
|
||||
}
|
||||
|
||||
private final String content;
|
||||
private final String ref;
|
||||
private final Instant time;
|
||||
|
||||
public NumassNote(String content, Instant time) {
|
||||
this.content = content;
|
||||
this.time = time;
|
||||
@ -39,10 +30,20 @@ public class NumassNote implements Serializable {
|
||||
|
||||
public NumassNote(String content) {
|
||||
this.content = content;
|
||||
this.time = Instant.now();
|
||||
this.time = DateTimeUtils.now();
|
||||
this.ref = "#" + time.hashCode();
|
||||
}
|
||||
|
||||
public static NumassNote buildFrom(Meta meta) {
|
||||
String text = meta.getString("text", "");
|
||||
if (meta.hasValue("time")) {
|
||||
Instant time = meta.getValue("time").timeValue();
|
||||
return new NumassNote(text, time);
|
||||
} else {
|
||||
return new NumassNote(text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Text content
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user