Global cleanup
This commit is contained in:
parent
d444f2b12b
commit
4fd269e8ff
@ -1,14 +0,0 @@
|
||||
apply plugin: 'application'
|
||||
|
||||
if (!hasProperty('mainClass')) {
|
||||
ext.mainClass = 'inr.numass.client.Cli'
|
||||
}
|
||||
|
||||
mainClassName = mainClass
|
||||
|
||||
dependencies {
|
||||
compile project(':numass-core')
|
||||
compile 'commons-cli:commons-cli:1.4'
|
||||
compile "hep.dataforge:dataforge-messages"
|
||||
compile 'org.zeroturnaround:zt-zip:1.13'
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package inr.numass.client;
|
||||
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.storage.commons.StorageManager;
|
||||
import hep.dataforge.values.Value;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* CLI interface for numass client
|
||||
* @author Alexander Nozik
|
||||
*/
|
||||
public class Cli {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new StorageManager().startGlobal();
|
||||
|
||||
Options options = buildOptions();
|
||||
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
|
||||
CommandLine cli;
|
||||
try {
|
||||
cli = parser.parse(options, args, false);
|
||||
} catch (ParseException ex) {
|
||||
System.out.println("Error: command line");
|
||||
LoggerFactory.getLogger("NumassClient").error("Error while parsing command line", ex);
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
runComand(cli.getOptionValue("a", "192.168.11.1"), Integer.valueOf(cli.getOptionValue("p", "8335")), cli.getArgs());
|
||||
|
||||
}
|
||||
|
||||
public static void runComand(String ip, int port, String... args) {
|
||||
checkArgLength(1, args);
|
||||
try (NumassClient client = new NumassClient(ip, port)) {
|
||||
switch (args[0]) {
|
||||
case "getRun":
|
||||
Meta getRun = client.getCurrentRun();
|
||||
if (getRun.getBoolean("success", true)) {
|
||||
System.out.println(getRun.getString("run.path"));
|
||||
} else {
|
||||
System.out.println("Error: operaton failed");
|
||||
}
|
||||
return;
|
||||
case "setRun":
|
||||
checkArgLength(2, args);
|
||||
Meta setRun = client.startRun(args[1]);
|
||||
if (setRun.getBoolean("success", true)) {
|
||||
System.out.println(setRun.getString("run.path"));
|
||||
} else {
|
||||
System.out.println("Error: operaton failed");
|
||||
}
|
||||
return;
|
||||
case "getState":
|
||||
checkArgLength(2, args);
|
||||
String stateName = args[1];
|
||||
Map<String, Value> states = client.getStates(stateName);
|
||||
if (states != null) {
|
||||
System.out.println(states.get(stateName).getString());
|
||||
} else {
|
||||
System.out.println("Error: operaton failed");
|
||||
}
|
||||
return;
|
||||
case "setState":
|
||||
checkArgLength(3, args);
|
||||
String setStateName = args[1];
|
||||
String setStateValue = args[2];
|
||||
Meta setStateMeta = client.setState(setStateName, setStateValue);
|
||||
if (setStateMeta.getBoolean("success", true)) {
|
||||
System.out.println("OK");
|
||||
} else {
|
||||
System.out.println("Error: operaton failed");
|
||||
}
|
||||
return;
|
||||
case "pushPoint":
|
||||
checkArgLength(2, args);
|
||||
String path;
|
||||
String fileName;
|
||||
if (args.length == 2) {
|
||||
path = "";
|
||||
fileName = args[1];
|
||||
} else {
|
||||
path = args[1];
|
||||
fileName = args[2];
|
||||
}
|
||||
|
||||
Meta pushPoint = client.sendNumassData(path, fileName);
|
||||
// LoggerFactory.getLogger("Numass-client").debug(pushPoint.toString());
|
||||
if (pushPoint.getBoolean("success", true)) {
|
||||
System.out.println("OK");
|
||||
} else {
|
||||
System.out.println("Error: operaton failed");
|
||||
}
|
||||
return;
|
||||
case "addNote":
|
||||
// checkArgLength(2, args);
|
||||
// String note = args[1];
|
||||
String note = new BufferedReader(new InputStreamReader(System.in)).readLine();
|
||||
Meta addNote = client.addNote(note, null);
|
||||
if (addNote.getBoolean("success", true)) {
|
||||
System.out.println("OK");
|
||||
} else {
|
||||
System.out.println("Error: operaton failed");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException ex) {
|
||||
System.out.println("Error: connection failed");
|
||||
LoggerFactory.getLogger("NumassClient").error("Error while initializing connection", ex);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkArgLength(int length, String... args) {
|
||||
if (args.length < length) {
|
||||
LoggerFactory.getLogger("NumassClient").error("Command line to short");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static Options buildOptions() {
|
||||
Options options = new Options();
|
||||
|
||||
options.addOption("a", "ip", true, "IP address of the server. Default: 192.168.111.1");
|
||||
options.addOption("p", "port", true, "Server port. Default: 8335");
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package inr.numass.client;
|
||||
|
||||
import hep.dataforge.meta.Meta;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by darksnake on 09-Oct-16.
|
||||
*/
|
||||
public class ClientUtils {
|
||||
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 "";
|
||||
}
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,258 +0,0 @@
|
||||
/*
|
||||
* 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.client;
|
||||
|
||||
import hep.dataforge.io.envelopes.DefaultEnvelopeReader;
|
||||
import hep.dataforge.io.envelopes.DefaultEnvelopeType;
|
||||
import hep.dataforge.io.envelopes.Envelope;
|
||||
import hep.dataforge.io.envelopes.EnvelopeBuilder;
|
||||
import hep.dataforge.messages.Responder;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.meta.MetaBuilder;
|
||||
import hep.dataforge.values.Value;
|
||||
import hep.dataforge.values.Values;
|
||||
import inr.numass.data.storage.NumassStorage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static hep.dataforge.messages.MessagesKt.*;
|
||||
|
||||
/**
|
||||
* @author darksnake
|
||||
*/
|
||||
public class NumassClient implements AutoCloseable, Responder {
|
||||
|
||||
Socket socket;
|
||||
|
||||
public NumassClient(String address, int port) throws IOException {
|
||||
socket = new Socket(address, port);
|
||||
socket.setSoTimeout(300);
|
||||
}
|
||||
|
||||
|
||||
public NumassClient(Meta meta) throws IOException {
|
||||
this(meta.getString("ip", "192.168.111.1"), meta.getInt("port", 8335));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (!socket.isClosed()) {
|
||||
write(getTerminator(), socket.getOutputStream());
|
||||
}
|
||||
socket.close();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Envelope respond(@NotNull Envelope message) {
|
||||
try {
|
||||
write(message, socket.getOutputStream());
|
||||
return read(socket.getInputStream());
|
||||
} catch (IOException ex) {
|
||||
LoggerFactory.getLogger(getClass()).error("Error in envelope exchange", ex);
|
||||
return errorResponseBase(message, ex).build();
|
||||
}
|
||||
}
|
||||
|
||||
private Envelope read(InputStream is) throws IOException {
|
||||
return new DefaultEnvelopeReader().readWithData(is);
|
||||
}
|
||||
|
||||
private void write(Envelope envelope, OutputStream os) throws IOException {
|
||||
DefaultEnvelopeType.Companion.getINSTANCE().getWriter().write(os, envelope);
|
||||
os.flush();
|
||||
}
|
||||
|
||||
private EnvelopeBuilder requestActionBase(String type, String action) {
|
||||
return requestBase(type).setMetaValue("action", action);
|
||||
}
|
||||
|
||||
public Meta getCurrentRun() {
|
||||
return respond(requestActionBase("numass.run", "get").build()).getMeta();
|
||||
}
|
||||
|
||||
public Meta startRun(String name) {
|
||||
return respond(requestActionBase("numass.run", "start")
|
||||
.setMetaValue("path", name)
|
||||
.build()).getMeta();
|
||||
}
|
||||
|
||||
public Meta resetRun() {
|
||||
return respond(requestActionBase("numass.run", "reset")
|
||||
.build()).getMeta();
|
||||
}
|
||||
|
||||
public Meta sendNumassData(String path, String fileName) {
|
||||
try {
|
||||
File file = new File(fileName);
|
||||
ByteBuffer buffer;
|
||||
String zipName = null;
|
||||
if (file.isDirectory()) {
|
||||
File tmpFile = File.createTempFile(file.getName(), NumassStorage.NUMASS_ZIP_EXTENSION);
|
||||
tmpFile.deleteOnExit();
|
||||
ZipUtil.pack(file, tmpFile);
|
||||
zipName = file.getName();
|
||||
file = tmpFile;
|
||||
}
|
||||
|
||||
if (file.toString().endsWith(NumassStorage.NUMASS_ZIP_EXTENSION)) {
|
||||
FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ);
|
||||
buffer = ByteBuffer.allocate((int) channel.size());
|
||||
channel.read(buffer);
|
||||
if (zipName == null) {
|
||||
zipName = file.getName().replace(NumassStorage.NUMASS_ZIP_EXTENSION, "");
|
||||
}
|
||||
} else {
|
||||
return getErrorMeta(new FileNotFoundException(fileName));
|
||||
}
|
||||
|
||||
Envelope bin = requestBase("numass.data")
|
||||
.setMetaValue("action", "push")
|
||||
.setMetaValue("path", path)
|
||||
.setMetaValue("name", zipName)
|
||||
.data(buffer)
|
||||
.build();
|
||||
|
||||
return respond(bin).getMeta();
|
||||
} catch (IOException ex) {
|
||||
return getErrorMeta(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get state map for given state names from the root state loader. If
|
||||
* stateNames is empty, return all states.
|
||||
*
|
||||
* @param stateNames
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Value> getStates(String... stateNames) {
|
||||
EnvelopeBuilder env = requestActionBase("numass.state", "get");
|
||||
|
||||
if (stateNames.length > 0) {
|
||||
env.setMetaValue("name", Arrays.asList(stateNames));
|
||||
}
|
||||
|
||||
Meta response = respond(env.build()).getMeta();
|
||||
if (response.getBoolean("success", true)) {
|
||||
Map<String, Value> res = new HashMap<>();
|
||||
response.getMetaList("state").forEach((stateMeta) -> {
|
||||
res.put(stateMeta.getString("name"), stateMeta.getValue("value"));
|
||||
});
|
||||
return res;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a single state and return resulting envelope meta
|
||||
*
|
||||
* @param name
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public Meta setState(String name, Object value) {
|
||||
EnvelopeBuilder env = requestActionBase("numass.state", "set");
|
||||
env.putMetaNode(new MetaBuilder("state")
|
||||
.setValue("name", name)
|
||||
.setValue("value", value)
|
||||
.build());
|
||||
|
||||
return respond(env.build()).getMeta();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set states and return resulting meta
|
||||
*
|
||||
* @param stateMap
|
||||
* @return
|
||||
*/
|
||||
public Meta setState(Map<String, Value> stateMap) {
|
||||
EnvelopeBuilder env = requestActionBase("numass.state", "set");
|
||||
stateMap.entrySet().forEach((state) -> {
|
||||
env.putMetaNode(new MetaBuilder("state")
|
||||
.setValue("name", state.getKey())
|
||||
.setValue("value", state.getValue())
|
||||
.build());
|
||||
});
|
||||
return respond(env.build()).getMeta();
|
||||
}
|
||||
|
||||
public Meta addNote(String text, Instant time) {
|
||||
EnvelopeBuilder env = requestActionBase("numass.notes", "push");
|
||||
env.setMetaValue("note.text", text);
|
||||
if (time != null) {
|
||||
env.setMetaValue("note.time", time);
|
||||
}
|
||||
return respond(env.build()).getMeta();
|
||||
}
|
||||
|
||||
public Meta getNotes(int limit) {
|
||||
EnvelopeBuilder env = requestActionBase("numass.notes", "pull");
|
||||
if (limit > 0) {
|
||||
env.setMetaValue("limit", limit);
|
||||
}
|
||||
return respond(env.build()).getMeta();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create remote storage with given meta
|
||||
*
|
||||
* @param path full path relative to root storage
|
||||
* @param meta
|
||||
* @return
|
||||
*/
|
||||
public Envelope createStorage(String path, Meta meta) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create remote loader
|
||||
*
|
||||
* @param shelf full path to the shelf
|
||||
* @param name the name of the loader
|
||||
* @param meta loader meta
|
||||
* @return
|
||||
*/
|
||||
public Envelope createLoader(String shelf, String name, Meta meta) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send points to existing point loader
|
||||
*
|
||||
* @param shelf
|
||||
* @param loaderName
|
||||
* @param points
|
||||
* @return
|
||||
*/
|
||||
public Envelope sendDataPoints(String shelf, String loaderName, Collection<Values> points) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
@ -16,10 +16,13 @@ allprojects {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':numass-client')
|
||||
compile "hep.dataforge:plots-jfc" // project(':dataforge-plots:plots-jfc')
|
||||
compile "hep.dataforge:dataforge-control" //project(':dataforge-control')
|
||||
compile "hep.dataforge:dataforge-gui"
|
||||
|
||||
// https://mvnrepository.com/artifact/commons-cli/commons-cli
|
||||
compile group: 'commons-cli', name: 'commons-cli', version: '1.4'
|
||||
|
||||
}
|
||||
|
||||
task installAll(type: Copy) {
|
||||
|
@ -23,7 +23,7 @@ configurations {
|
||||
dependencies {
|
||||
//DataForge dependencies
|
||||
compile project(':numass-control')
|
||||
compile project(':numass-server')
|
||||
//compile project(':numass-server')
|
||||
|
||||
// optional device classpath
|
||||
devices project(':numass-control:cryotemp')
|
||||
|
@ -18,4 +18,5 @@ version = "0.1.0"
|
||||
|
||||
dependencies {
|
||||
compile project(':numass-control')
|
||||
compile project(':numass-core')
|
||||
}
|
@ -86,7 +86,7 @@ class MspDisplay() : DeviceDisplayFX<MspDevice>(), NamedValueListener {
|
||||
.setValue("xAxis.type", "time")
|
||||
|
||||
|
||||
JFreeChartFrame(basePlotConfig).apply {
|
||||
JFreeChartFrame().apply { configure(basePlotConfig) }.apply {
|
||||
PlotUtils.setXAxis(this, "timestamp", "", "time")
|
||||
configure(plotFrameMeta)
|
||||
}
|
||||
|
@ -12,13 +12,13 @@ import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.nullable
|
||||
import hep.dataforge.storage.commons.StorageConnection
|
||||
import hep.dataforge.storage.commons.StorageManager
|
||||
import inr.numass.client.ClientUtils
|
||||
import javafx.application.Application
|
||||
import javafx.stage.Stage
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
|
||||
|
||||
/**
|
||||
* Created by darksnake on 08-May-17.
|
||||
*/
|
||||
@ -26,9 +26,19 @@ const val DEFAULT_CONFIG_LOCATION = "./numass-control.xml"
|
||||
//val STORING_STATE = "storing"
|
||||
//val dfIcon: Image = Image(Global::class.java.getResourceAsStream("/img/df.png"))
|
||||
|
||||
fun getRunName(config: Meta): String {
|
||||
return if (config.hasValue("numass.run")) {
|
||||
config.getString("numass.run")
|
||||
} else if (config.hasMeta("numass.server")) {
|
||||
TODO("Not implemented")
|
||||
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a single or multiple storage connections for a device
|
||||
|
||||
* @param device
|
||||
* *
|
||||
* @param config
|
||||
@ -36,7 +46,7 @@ const val DEFAULT_CONFIG_LOCATION = "./numass-control.xml"
|
||||
fun connectStorage(device: Device, config: Meta) {
|
||||
//TODO add on reset listener
|
||||
if (config.hasMeta("storage") && device.acceptsRole(Roles.STORAGE_ROLE)) {
|
||||
val numassRun = ClientUtils.getRunName(config)
|
||||
val numassRun = getRunName(config)
|
||||
config.getMetaList("storage").forEach { node ->
|
||||
device.context.logger.info("Creating storage for device with getMeta: {}", node)
|
||||
//building storage in a separate thread
|
||||
|
@ -8,6 +8,7 @@ import hep.dataforge.plots.jfreechart.JFreeChartPlugin
|
||||
import inr.numass.NumassPlugin
|
||||
import inr.numass.actions.TimeAnalyzerAction
|
||||
import inr.numass.data.NumassDataUtils
|
||||
import inr.numass.data.analyzers.TimeAnalyzer
|
||||
import inr.numass.data.api.NumassPoint
|
||||
import inr.numass.data.api.NumassSet
|
||||
import inr.numass.data.api.SimpleNumassPoint
|
||||
@ -18,8 +19,8 @@ fun main(args: Array<String>) {
|
||||
|
||||
val context = buildContext("NUMASS", NumassPlugin::class.java, JFreeChartPlugin::class.java) {
|
||||
output = FXOutputManager()
|
||||
rootDir = "D:\\Work\\Numass\\sterile2017_11"
|
||||
dataDir = "D:\\Work\\Numass\\data\\2017_11"
|
||||
rootDir = "D:\\Work\\Numass\\sterile2017_05"
|
||||
dataDir = "D:\\Work\\Numass\\data\\2017_05"
|
||||
}
|
||||
|
||||
val storage = NumassDirectory.read(context, "Fill_2")!!
|
||||
@ -27,19 +28,19 @@ fun main(args: Array<String>) {
|
||||
val meta = buildMeta {
|
||||
"t0" to 3000
|
||||
"binNum" to 200
|
||||
"t0Step" to 600
|
||||
//"chunkSize" to 3000
|
||||
//"mean" to TimeAnalyzer.AveragingMethod.ARITHMETIC
|
||||
"t0Step" to 100
|
||||
"chunkSize" to 3000
|
||||
"mean" to TimeAnalyzer.AveragingMethod.ARITHMETIC
|
||||
//"separateParallelBlocks" to true
|
||||
"window" to {
|
||||
"lo" to 400
|
||||
"lo" to 0
|
||||
"up" to 4000
|
||||
}
|
||||
//"plot.showErrors" to false
|
||||
}
|
||||
|
||||
//def sets = ((2..14) + (22..31)).collect { "set_$it" }
|
||||
val sets = (22..22).map { "set_$it" }
|
||||
val sets = (2..12).map { "set_$it" }
|
||||
//def sets = (16..31).collect { "set_$it" }
|
||||
//def sets = (20..28).collect { "set_$it" }
|
||||
|
||||
@ -49,7 +50,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
val all = NumassDataUtils.join("sum", loaders)
|
||||
|
||||
val hvs = listOf(14000.0, 15000.0)//, 15000d, 15200d, 15400d, 15600d, 15800d]
|
||||
val hvs = listOf(14500.0)//, 15000d, 15200d, 15400d, 15600d, 15800d]
|
||||
//listOf(18500.0, 18600.0, 18995.0, 19000.0)
|
||||
|
||||
val data = DataSet.edit(NumassPoint::class).apply {
|
||||
|
@ -1,32 +0,0 @@
|
||||
apply plugin: 'groovy'
|
||||
|
||||
description = "Test module for numass client and server"
|
||||
|
||||
|
||||
task runServer(type: JavaExec) {
|
||||
description 'Start numass server locally'
|
||||
|
||||
// Set main property to name of Groovy script class.
|
||||
main = 'inr.numass.scripts.TestServer'
|
||||
|
||||
// Set classpath for running the Groovy script.
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
standardInput = System.in
|
||||
}
|
||||
|
||||
task runClient(type: JavaExec) {
|
||||
description 'Start numass client locally'
|
||||
|
||||
// Set main property to name of Groovy script class.
|
||||
main = 'inr.numass.scripts.TestClient'
|
||||
|
||||
// Set classpath for running the Groovy script.
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
standardInput = System.in
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':numass-client')
|
||||
compile project(':numass-server')
|
||||
compile "hep.dataforge:grind" //project(':dataforge-grind')
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
import static groovy.io.FileType.FILES
|
||||
|
||||
def fixStampEndings(File directory){
|
||||
directory.eachFileRecurse(FILES){
|
||||
byte[] bytes = it.bytes
|
||||
bytes[26] = '!'
|
||||
bytes[27] = '#'
|
||||
it.bytes = bytes
|
||||
}
|
||||
}
|
||||
|
||||
fixStampEndings(new File("C:\\Users\\darksnake\\Dropbox\\PlayGround\\data-test\\"))
|
@ -1,12 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package inr.numass.scripts
|
||||
|
||||
import inr.numass.client.NumassClient
|
||||
|
||||
NumassClient client = new NumassClient("192.168.111.1", 8335);
|
||||
print client.startRun("2016_04")
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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.scripts
|
||||
|
||||
import hep.dataforge.storage.commons.StorageManager
|
||||
|
||||
new StorageManager().startGlobal();
|
||||
|
||||
|
||||
println "Starting Numass test client..."
|
||||
|
||||
String line = "";
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in))
|
||||
while(line == null || !line.startsWith("exit")){
|
||||
// print ">"
|
||||
line = br.readLine();
|
||||
if(line!= null && !line.startsWith("exit")){
|
||||
Cli.runComand("127.0.0.1", 8335, line.split(" "));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package inr.numass.scripts
|
||||
|
||||
import hep.dataforge.io.JSONMetaWriter
|
||||
import hep.dataforge.io.MetaStreamWriter
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.storage.commons.StorageManager
|
||||
import inr.numass.client.NumassClient
|
||||
|
||||
new StorageManager().startGlobal();
|
||||
|
||||
new NumassClient("127.0.0.1",8335).withCloseable{
|
||||
|
||||
MetaStreamWriter writer = JSONMetaWriter.INSTANCE
|
||||
|
||||
Meta startRun = it.startRun("test")
|
||||
|
||||
println writer.writeString(startRun);
|
||||
|
||||
Meta run = it.getCurrentRun();
|
||||
println writer.writeString(run);
|
||||
|
||||
Meta response = it.sendNumassData("C:\\Users\\darksnake\\Dropbox\\PlayGround\\data-test\\zip\\20150703143643_1.nm.zip");
|
||||
|
||||
println writer.writeString(response);
|
||||
|
||||
response = it.sendNumassData("C:\\Users\\darksnake\\Dropbox\\PlayGround\\data-test\\20150703144707_2");
|
||||
|
||||
println writer.writeString(response);
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package inr.numass.scripts
|
||||
|
||||
import hep.dataforge.storage.commons.StorageManager
|
||||
import inr.numass.client.NumassClient
|
||||
|
||||
new StorageManager().startGlobal();
|
||||
|
||||
NumassClient.runComand("127.0.0.1", 8336, "addNote", "This is my note with <strong>html</strong>");
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* 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.scripts
|
||||
|
||||
import hep.dataforge.storage.commons.StorageManager
|
||||
import inr.numass.client.NumassClient
|
||||
|
||||
new StorageManager().startGlobal();
|
||||
|
||||
|
||||
println "Starting Numass test client..."
|
||||
|
||||
String line = "";
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in))
|
||||
while(line == null || !line.startsWith("exit")){
|
||||
// print ">"
|
||||
line = br.readLine();
|
||||
if(!line.startsWith("exit")){
|
||||
NumassClient.runComand("192.168.111.1", 8335, line.split(" "));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* 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.scripts
|
||||
|
||||
import hep.dataforge.meta.Meta
|
||||
import inr.numass.data.storage.NumassStorage
|
||||
import inr.numass.server.NumassServer
|
||||
|
||||
String path = "D:\\Work\\Numass\\data\\2016_10\\"
|
||||
|
||||
//FileObject file = VFSUtils.getLocalFile(new File(path))
|
||||
|
||||
NumassStorage storage = NumassStorage.buildLocalNumassRoot(new File(path), true, true);
|
||||
|
||||
println "Starting test numass listener in " + path
|
||||
|
||||
NumassServer listener = new NumassServer(storage, Meta.empty());
|
||||
|
||||
listener.open()
|
||||
|
||||
String stopLine = "";
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in))
|
||||
while (stopLine == null || !stopLine.startsWith("exit")) {
|
||||
// print ">"
|
||||
stopLine = br.readLine();
|
||||
}
|
||||
|
||||
listener.close()
|
||||
|
||||
println "Stopping test numass listener"
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package inr.numass.scripts
|
||||
|
||||
import hep.dataforge.io.JSONMetaWriter
|
||||
import hep.dataforge.io.MetaStreamWriter
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.storage.commons.StorageManager
|
||||
import inr.numass.client.NumassClient
|
||||
|
||||
new StorageManager().startGlobal();
|
||||
|
||||
new NumassClient("127.0.0.1",8335).withCloseable{
|
||||
|
||||
MetaStreamWriter writer = JSONMetaWriter.INSTANCE
|
||||
|
||||
Meta startRun = it.startRun("test")
|
||||
|
||||
println writer.writeString(startRun);
|
||||
|
||||
Meta set1 = it.setState("myState", 112);
|
||||
|
||||
println writer.writeString(set1);
|
||||
|
||||
Meta set2 = it.setState("otherState.property", ["a", "b", "c"])
|
||||
|
||||
println it.getStates()
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package inr.numass.scripts
|
||||
|
||||
import hep.dataforge.io.JSONMetaWriter
|
||||
import hep.dataforge.io.MetaStreamWriter
|
||||
import hep.dataforge.io.envelopes.Envelope
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.meta.MetaBuilder
|
||||
import hep.dataforge.storage.commons.LoaderFactory
|
||||
import hep.dataforge.storage.commons.StorageManager
|
||||
import hep.dataforge.values.ValueMap
|
||||
import inr.numass.client.NumassClient
|
||||
|
||||
new StorageManager().startGlobal();
|
||||
|
||||
new NumassClient("127.0.0.1",8335).withCloseable{
|
||||
|
||||
MetaStreamWriter writer = JSONMetaWriter.INSTANCE
|
||||
|
||||
Meta startRun = it.startRun("test")
|
||||
|
||||
println writer.writeString(startRun);
|
||||
|
||||
|
||||
MetaBuilder target = new MetaBuilder("target")
|
||||
.setValue("type","loader")
|
||||
.setValue("name", "testPointLoader")
|
||||
.putNode(LoaderFactory.buildTableLoaderMeta("testPointLoader","a", DataFormat.forNames("a", "b", "c")).rename("meta"))
|
||||
|
||||
MetaBuilder data = new MetaBuilder("data");
|
||||
|
||||
String[] names = ["a","b","c"]
|
||||
|
||||
|
||||
for(int i = 0; i<5; i++){
|
||||
data.putNode(DataPoint.write(new ValueMap(names,i, 2*i,3*i)));
|
||||
}
|
||||
|
||||
|
||||
Envelope bin = it.requestBase("numass.storage")
|
||||
.putMetaValue("action","push")
|
||||
.putMetaNode(target)
|
||||
.putMetaNode(data)
|
||||
.build();
|
||||
|
||||
|
||||
def response = it.respond(bin);
|
||||
|
||||
println writer.writeString(response.getMeta());
|
||||
|
||||
}
|
@ -5,17 +5,13 @@ include ":numass-control:cryotemp"
|
||||
include ":numass-control:magnet"
|
||||
include ":numass-control:msp"
|
||||
include ":numass-control:vac"
|
||||
include ":numass-control:control-room"
|
||||
//include ":numass-control:control-room"
|
||||
include ":numass-control:dante"
|
||||
//
|
||||
include ":numass-main"
|
||||
//
|
||||
include ":numass-core"
|
||||
include ":numass-client"
|
||||
include ":numass-server"
|
||||
include ":numass-server"
|
||||
//include ":numass-web"
|
||||
include ":numass-test"
|
||||
//include ":numass-server"
|
||||
//
|
||||
include ":numass-viewer"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user