New envelope format, FileStorage overhaul

This commit is contained in:
Alexander Nozik 2017-03-01 18:11:55 +03:00
parent 134e5c771d
commit 69d1a3a848
5 changed files with 25 additions and 19 deletions

View File

@ -160,7 +160,7 @@ public class PrepareDataAction extends OneToOneAction<NumassData, Table> {
} else {
head = dataFile.getName();
}
head = head + "\n" + new XMLMetaWriter().writeString(meta, null) + "\n";
head = head + "\n" + new XMLMetaWriter().writeString(meta) + "\n";
ListTable data = new ListTable(format, dataList);

View File

@ -45,9 +45,9 @@ public class ReadLegacyDataAction extends OneToOneAction<Binary, NMFile> {
protected NMFile execute(Context context, String name, Binary source, Laminate meta) throws ContentException {
// log.logString("File '%s' started", source.getName());
RawNMFile raw = getNumassData(source, meta);
if (meta.getBoolean("paw", false)) {
raw.generatePAW(buildActionOutput(context, name + ".paw"));
}
// if (meta.getBoolean("paw", false)) {
// raw.generatePAW(buildActionOutput(context, name + ".paw"));
// }
if (meta.getNodeNames(false).contains("debunch")) {
DebunchAction debunch = new DebunchAction();

View File

@ -26,7 +26,6 @@ import hep.dataforge.storage.api.Storage;
import hep.dataforge.storage.filestorage.FileEnvelope;
import hep.dataforge.storage.loaders.AbstractLoader;
import hep.dataforge.tables.Table;
import hep.dataforge.values.Value;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.VFS;
import org.slf4j.LoggerFactory;
@ -189,7 +188,7 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
double timeCoef = envelope.meta().getDouble("time_coeff", 50);
try (ReadableByteChannel inChannel = envelope.getData().getChannel()) {
ByteBuffer buffer = ByteBuffer.allocate(7*1000); // one event is 7b
ByteBuffer buffer = ByteBuffer.allocate(7 * 1000); // one event is 7b
buffer.order(ByteOrder.LITTLE_ENDIAN);
while (inChannel.read(buffer) > 0) {
buffer.flip();
@ -329,17 +328,20 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
@Override
public Instant startTime() {
if (meta.hasValue("start_time")) {
return meta().getValue("start_time").timeValue();
} else return null;
//Temporary substitution for meta tag
Envelope hvEnvelope = getHVEnvelope();
if (hvEnvelope != null) {
try {
return Value.of(new Scanner(hvEnvelope.getData().getStream()).next()).timeValue();
} catch (IOException ex) {
return null;
}
} else {
return null;
}
// Envelope hvEnvelope = getHVEnvelope();
// if (hvEnvelope != null) {
// try {
// return Value.of(new Scanner(hvEnvelope.getData().getStream()).next()).timeValue();
// } catch (IOException ex) {
// return null;
// }
// } else {
// return null;
// }
}
@Override

View File

@ -281,7 +281,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
private void setupInfo(NumassData loader) {
Meta info = loader.meta();
infoTextBox.setText(new JSONMetaWriter().writeString(info, null).
infoTextBox.setText(new JSONMetaWriter().writeString(info).
replace("\\r", "\r\t").replace("\\n", "\n\t"));
}

View File

@ -15,23 +15,27 @@
*/
package inr.numass.viewer;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import hep.dataforge.exceptions.StorageException;
import hep.dataforge.storage.commons.StorageManager;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.slf4j.LoggerFactory;
import java.io.IOException;
/**
*
* @author Alexander Nozik
*/
public class Viewer extends Application {
@Override
public void start(Stage primaryStage) throws StorageException, IOException {
((Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(Level.INFO);
new StorageManager().startGlobal();
FXMLLoader fxml = new FXMLLoader(getClass().getResource("/fxml/MainView.fxml"));