public static void updateLogs(File directory, LogProperties properties) { try { // if(properties.getModelLoaderClass() == null) // { // LogModels model = ModelAttacher.chooseModel(directory); // ModelAttacher.addModel(directory, properties, model); // } if (properties.getCompressed() && !properties.isTimestampedIndex()) { LogTimeStampedIndexGenerator.convert(directory, properties); } } catch (IOException e) { throw new RuntimeException("Cannot convert log file", e); } } }
public VideoDataLoggerInterface(File logPath, LogProperties logProperties, String description) { logProperties.addVideoFile(description); logProperties.setInterlaced(description, false); String videoFilename = description + videoPostfix; logProperties.setVideoFile(description, videoFilename); String timestampDataFilename = description + timestampDataPostfix; logProperties.setTimestampFile(description, timestampDataFilename); timestampData = logPath.getAbsolutePath() + File.separator + timestampDataFilename; videoFile = logPath.getAbsolutePath() + File.separator + videoFilename; }
if (logProperties.getModelPath() != null) model = new File(logDirectory, logProperties.getModelPath()); if (logProperties.getModelResourceBundlePath() != null) resourceBundle = new File(logDirectory, logProperties.getModelResourceBundlePath()); if(logProperties.getSummaryFile() != null) summary = new File(logDirectory, logProperties.getSummaryFile()); handshake = new File(logDirectory, logProperties.getHandshakeFile()); if (!handshake.exists()) throw new RuntimeException("Cannot find " + logProperties.getHandshakeFile());
public static void compress(File directory, LogProperties properties) throws IOException if (!properties.getCompressed()) YoVariableHandshakeParser handshake = ConverterUtil.getHandshake(new File(directory, properties.getHandshakeFile())); int bufferSize = handshake.getBufferSize(); File logdata = new File(directory, properties.getVariableDataFile()); if (!logdata.exists()) throw new RuntimeException("Cannot find " + properties.getVariableDataFile()); properties.setCompressed(true); properties.setVariableDataFile("robotData.bsz"); properties.setVariablesIndexFile("robotData.dat"); properties.setTimestampedIndex(true); File compressedData = new File(directory, properties.getVariableDataFile()); File indexData = new File(directory, properties.getVariablesIndexFile()); properties.store(writer, "Converted by LogCompressor"); writer.close(); logdata.delete();
public static void convert(File logDirectory, LogProperties logProperties) throws IOException File handshake = new File(logDirectory, logProperties.getHandshakeFile()); if (!handshake.exists()) throw new RuntimeException("Cannot find " + logProperties.getHandshakeFile()); int logLineLength = YoVariableHandshakeParser.getNumberOfVariables(handshakeData); File logdata = new File(logDirectory, logProperties.getVariableDataFile()); if (!logdata.exists()) throw new RuntimeException("Cannot find " + logProperties.getVariableDataFile()); File index = new File(logDirectory, logProperties.getVariablesIndexFile()); if (!index.exists()) throw new RuntimeException("Cannot find " + logProperties.getVariablesIndexFile()); FileChannel indexChannel = indexStream.getChannel(); CustomProgressMonitor monitor = new CustomProgressMonitor("Generating timestamps for " + logProperties.getLogName(), "Adding timestamps to log index for future functionality improvements.", 0, dataOffsets.length); logProperties.setTimestampedIndex(true); logProperties.setVariablesIndexFile(newIndexFile); logProperties.store(writer, "Timestamps added to index by LogTimestampedIndexGenerator"); writer.close();
private void checkChecksums(CompressionProperties properties) throws IOException { out.println("Validating checksums."); File logdata = new File(targetFile, logProperties.getVariableDataFile()); if (!properties.getDataChecksum().equals(Files.hash(logdata, Hashing.sha1()).toString())) { throw new IOException("Variable data does not match with pre-compression data. Expect an unloadable data file."); } File index = new File(targetFile, logProperties.getVariablesIndexFile()); if (!properties.getTimestampChecksum().equals(Files.hash(index, Hashing.sha1()).toString())) { throw new IOException("Timestamp data does not match with pre-compression data. A bug has been found in the LogFileDecompressor and fixing it will make this data file readable again."); } out.println("Checksums validated."); }
public static void addModel(File modelDirectory, LogProperties properties, LogModels model) throws IOException { if (properties.getModelLoaderClass() == null) { if (model == null || !model.isValid()) { throw new RuntimeException("Cannot load model files"); } System.out.println("Adding model to " + modelDirectory); properties.setModelLoaderClass(model.getLoader()); properties.setModelName(model.getModelName()); properties.setModelResourceDirectories(model.getResourceDirectories()); properties.setModelPath(modelFilename); properties.setModelResourceBundlePath(modelResourceBundle); File modelFile = new File(modelDirectory, modelFilename); Files.copy(model.getModel().toPath(), modelFile.toPath(), StandardCopyOption.REPLACE_EXISTING); File resourceFile = new File(modelDirectory, modelResourceBundle); Files.copy(model.getResources().toPath(), resourceFile.toPath(), StandardCopyOption.REPLACE_EXISTING); File log = new File(modelDirectory, YoVariableLoggerListener.propertyFile); FileWriter writer = new FileWriter(log); properties.store(writer, "Model added by ModelAttacher"); writer.close(); System.out.println("Attached model to " + modelDirectory); } else { System.out.println(modelDirectory + " already contains a robot model"); } }
public VideoDataPlayer(String name, File dataDirectory, LogProperties logProperties) throws IOException { this.name = name; this.interlaced = logProperties.getInterlaced(name); this.hasTimebase = logProperties.hasTimebase(); if (!hasTimebase) { System.err.println("Video data is using timestamps instead of frame numbers. Falling back to seeking based on timestamp."); } videoFile = new File(dataDirectory, logProperties.getVideoFile(name)); if (!videoFile.exists()) { throw new IOException("Cannot find video: " + videoFile); } File timestampFile = new File(dataDirectory, logProperties.getTimestampFile(name)); parseTimestampData(timestampFile); demuxer = new MP4VideoDemuxer(videoFile); viewer = new HideableMediaFrame(name, demuxer.getWidth(), demuxer.getHeight()); }
dataPanel.add(new JLabel("Main class name: " + properties.getLogName())); dataPanel.add(new JLabel("Record time: " + properties.getTimestamp())); dataPanel.add(new JLabel("Directory: " + directory)); add(dataPanel);
public YoVariableLogVisualizerGUI(File directory, LogProperties properties, MultiVideoDataPlayer player, YoVariableHandshakeParser parser, YoVariableLogPlaybackRobot robot, SimulationConstructionSet scs) { super(); this.multiPlayer = player; this.robot = robot; this.scs = scs; this.directory = directory; if(properties.getCompressed()) { yoVariableLogCropper = new YoVariableLogCropper(player, directory, properties); exporter = new YoVariableExporter(scs, directory, properties, parser.getYoVariablesList()); } else { yoVariableLogCropper = null; exporter = null; } setLayout(new GridLayout(1, 2)); addGUIElements(directory, properties); setVisible(true); }
private void setChecksums(CompressionProperties properties) throws IOException { out.println("Saving checksums to file"); File logdata = new File(logDirectory, logProperties.getVariableDataFile()); properties.setDataChecksum(Files.hash(logdata, Hashing.sha1()).toString()); File index = new File(logDirectory, logProperties.getVariablesIndexFile()); properties.setTimestampChecksum(Files.hash(index, Hashing.sha1()).toString()); out.println("Saved checksums"); }
logLineLength = YoVariableHandshakeParser.getNumberOfVariables(handshakeData); File logdata = new File(logDirectory, logProperties.getVariableDataFile()); if (!logdata.exists()) throw new RuntimeException("Cannot find " + logProperties.getVariableDataFile()); File index = new File(logDirectory, logProperties.getVariablesIndexFile()); if (!index.exists()) throw new RuntimeException("Cannot find " + logProperties.getVariablesIndexFile());
protected void copyMetaData(File destination) throws IOException { File propertiesDestination = new File(destination, YoVariableLoggerListener.propertyFile); Files.copy(properties, propertiesDestination); File handShakeDestination = new File(destination, logProperties.getHandshakeFile()); Files.copy(handshake, handShakeDestination); if (model != null) { File modelDesitination = new File(destination, logProperties.getModelPath()); Files.copy(model, modelDesitination); } if (resourceBundle != null) { File resourceDestination = new File(destination, logProperties.getModelResourceBundlePath()); Files.copy(resourceBundle, resourceDestination); } if(summary != null) { File summaryDestination = new File(destination, logProperties.getSummaryFile()); Files.copy(summary, summaryDestination); } }
out.println("Reading " + bufferedElements + " data points at a time"); FileOutputStream outputStream = new FileOutputStream(new File(targetFile, logProperties.getVariableDataFile())); outputChannel = outputStream.getChannel(); FileOutputStream indexStream = new FileOutputStream(new File(targetFile, logProperties.getVariablesIndexFile())); indexChannel = indexStream.getChannel();
monitor.setProgress(10); File outputFile = new File(destination, logProperties.getVariableDataFile()); FileOutputStream fileOutputStream = new FileOutputStream(outputFile); FileChannel outputChannel = fileOutputStream.getChannel(); File indexFile = new File(destination, logProperties.getVariablesIndexFile()); FileOutputStream indexStream = new FileOutputStream(indexFile); FileChannel indexChannel = indexStream.getChannel();