mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[datalog] Move all DataLog functionality to new datalog library (#7641)
Currently the major DataLog backend API (reading and writing) is split between wpiutil and glass. In the interest of allowing code that wants to use these APIs to not need to link to glass and declutter wpiutil, all of those APIs are moved to a new library named "datalog". Signed-off-by: Jade Turner <spacey-sooty@proton.me> Co-authored-by: Jade Turner <spacey-sooty@proton.me> Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
This commit is contained in:
@@ -291,6 +291,8 @@ set(WPIUNITS_DEP_REPLACE_IMPL "find_dependency(wpiunits)")
|
||||
set(WPIUTIL_DEP_REPLACE "find_dependency(wpiutil)")
|
||||
add_subdirectory(wpiutil)
|
||||
|
||||
add_subdirectory(datalog)
|
||||
|
||||
if(WITH_NTCORE)
|
||||
set(NTCORE_DEP_REPLACE "find_dependency(ntcore)")
|
||||
set(WPINET_DEP_REPLACE "find_dependency(wpinet)")
|
||||
|
||||
29
datalog/.styleguide
Normal file
29
datalog/.styleguide
Normal file
@@ -0,0 +1,29 @@
|
||||
cppHeaderFileInclude {
|
||||
\.h$
|
||||
}
|
||||
|
||||
cppSrcFileInclude {
|
||||
\.cpp$
|
||||
}
|
||||
|
||||
licenseUpdateExclude {
|
||||
examples/printlog
|
||||
}
|
||||
|
||||
modifiableFileExclude {
|
||||
examples/printlog/datalog\.py$
|
||||
}
|
||||
|
||||
repoRootNameOverride {
|
||||
datalog
|
||||
}
|
||||
|
||||
includeOtherLibs {
|
||||
^fmt/
|
||||
^gtest/
|
||||
^wpi/(?!datalog)
|
||||
}
|
||||
|
||||
includeProject {
|
||||
^wpi/datalog/
|
||||
}
|
||||
106
datalog/BUILD.bazel
Normal file
106
datalog/BUILD.bazel
Normal file
@@ -0,0 +1,106 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||
load("@rules_java//java:defs.bzl", "java_binary")
|
||||
load("@rules_python//python:defs.bzl", "py_binary")
|
||||
load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test")
|
||||
load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library")
|
||||
|
||||
cc_library(
|
||||
name = "datalog.static",
|
||||
srcs = glob(
|
||||
["src/main/native/cpp/**"],
|
||||
exclude = ["src/main/native/cpp/jni/**"],
|
||||
),
|
||||
hdrs = glob(["src/main/native/include/**"]),
|
||||
includes = [
|
||||
"src/main/native/cpp",
|
||||
"src/main/native/include",
|
||||
],
|
||||
strip_include_prefix = "src/main/native/include",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//wpiutil:wpiutil.static",
|
||||
],
|
||||
)
|
||||
|
||||
wpilib_jni_cc_library(
|
||||
name = "datalogjni",
|
||||
srcs = glob(["src/main/native/cpp/jni/**"]),
|
||||
java_dep = ":datalog-java",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":datalog.static",
|
||||
],
|
||||
)
|
||||
|
||||
wpilib_jni_java_library(
|
||||
name = "datalog-java",
|
||||
srcs = glob(["src/main/java/**/*.java"]),
|
||||
native_libs = [":datalogjni"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//wpiutil:wpiutil-java",
|
||||
"@maven//:us_hebi_quickbuf_quickbuf_runtime",
|
||||
],
|
||||
)
|
||||
|
||||
py_binary(
|
||||
name = "datalog",
|
||||
srcs = ["examples/printlog/datalog.py"],
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "printlog",
|
||||
srcs = ["examples/printlog/printlog.cpp"],
|
||||
deps = [
|
||||
":datalog.static",
|
||||
"//wpiutil:wpiutil.static",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "writelog",
|
||||
srcs = ["examples/writelog/writelog.cpp"],
|
||||
deps = [
|
||||
":datalog.static",
|
||||
"//wpiutil:wpiutil.static",
|
||||
],
|
||||
)
|
||||
|
||||
java_binary(
|
||||
name = "printlog-java",
|
||||
srcs = ["src/printlog/java/printlog/PrintLog.java"],
|
||||
main_class = "printlog.PrintLog",
|
||||
deps = [
|
||||
":datalog-java",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "datalog-cpp-test",
|
||||
size = "small",
|
||||
srcs = glob([
|
||||
"src/test/native/**/*.cpp",
|
||||
"src/test/native/**/*.h",
|
||||
]),
|
||||
tags = [
|
||||
"exclusive",
|
||||
"no-asan",
|
||||
"no-tsan",
|
||||
],
|
||||
deps = [
|
||||
":datalog.static",
|
||||
"//thirdparty/googletest:googletest.static",
|
||||
"//wpiutil:wpiutil-testlib",
|
||||
],
|
||||
)
|
||||
|
||||
wpilib_java_junit5_test(
|
||||
name = "datalog-java-test",
|
||||
srcs = glob(["src/test/java/**/*.java"]),
|
||||
tags = ["exclusive"],
|
||||
deps = [
|
||||
":datalog-java",
|
||||
"//wpiutil:wpiutil-java",
|
||||
],
|
||||
)
|
||||
108
datalog/CMakeLists.txt
Normal file
108
datalog/CMakeLists.txt
Normal file
@@ -0,0 +1,108 @@
|
||||
project(datalog)
|
||||
|
||||
include(CompileWarnings)
|
||||
|
||||
file(GLOB datalog_native_src src/main/native/cpp/*.cpp)
|
||||
|
||||
file(GLOB datalog_jni_src src/main/native/cpp/jni/DataLogJNI.cpp)
|
||||
list(REMOVE_ITEM datalog_native_src ${datalog_jni_src})
|
||||
|
||||
add_library(datalog ${datalog_native_src})
|
||||
set_target_properties(datalog PROPERTIES DEBUG_POSTFIX "d")
|
||||
|
||||
target_compile_features(datalog PUBLIC cxx_std_20)
|
||||
if(MSVC)
|
||||
target_compile_options(
|
||||
datalog
|
||||
PUBLIC /permissive- /Zc:preprocessor /Zc:__cplusplus /Zc:throwingNew /MP /bigobj /utf-8
|
||||
)
|
||||
target_compile_definitions(datalog PRIVATE -D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
wpilib_target_warnings(datalog)
|
||||
|
||||
target_include_directories(
|
||||
datalog
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
||||
)
|
||||
|
||||
target_link_libraries(datalog PRIVATE wpiutil)
|
||||
|
||||
subdir_list(datalog_examples "${CMAKE_CURRENT_SOURCE_DIR}/examples")
|
||||
foreach(example ${datalog_examples})
|
||||
file(GLOB datalog_example_src examples/${example}/*.cpp)
|
||||
if(datalog_example_src)
|
||||
add_executable(datalog_${example} ${datalog_example_src})
|
||||
wpilib_target_warnings(datalog_${example})
|
||||
target_link_libraries(datalog_${example} datalog wpiutil)
|
||||
set_property(TARGET datalog_${example} PROPERTY FOLDER "examples")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Java bindings
|
||||
if(WITH_JAVA)
|
||||
include(UseJava)
|
||||
|
||||
set(CMAKE_JNI_TARGET true)
|
||||
|
||||
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
|
||||
file(GLOB QUICKBUF_JAR ${WPILIB_BINARY_DIR}/wpiutil/thirdparty/quickbuf/*.jar)
|
||||
|
||||
add_jar(
|
||||
datalog_jar
|
||||
${JAVA_SOURCES}
|
||||
# INCLUDE_JARS ${JACKSON_JARS} ${QUICKBUF_JAR}
|
||||
INCLUDE_JARS wpiutil_jar ${QUICKBUF_JAR}
|
||||
OUTPUT_NAME datalog
|
||||
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
|
||||
GENERATE_NATIVE_HEADERS datalog_jni_headers
|
||||
)
|
||||
set_property(TARGET datalog_jar PROPERTY FOLDER "java")
|
||||
|
||||
install_jar(datalog_jar DESTINATION ${java_lib_dest})
|
||||
install_jar_exports(TARGETS datalog_jar FILE datalog_jar.cmake DESTINATION share/datalog)
|
||||
|
||||
add_library(datalogjni ${datalog_jni_src})
|
||||
wpilib_target_warnings(datalogjni)
|
||||
target_link_libraries(datalogjni PUBLIC datalog wpiutil)
|
||||
|
||||
set_property(TARGET datalogjni PROPERTY FOLDER "libraries")
|
||||
|
||||
target_link_libraries(datalogjni PRIVATE datalog_jni_headers)
|
||||
add_dependencies(datalogjni datalog_jar)
|
||||
|
||||
install(TARGETS datalogjni EXPORT datalogjni)
|
||||
export(TARGETS datalogjni FILE datalogjni.cmake NAMESPACE datalogjni::)
|
||||
endif()
|
||||
|
||||
if(WITH_JAVA_SOURCE)
|
||||
include(UseJava)
|
||||
include(CreateSourceJar)
|
||||
add_source_jar(
|
||||
datalog_src_jar
|
||||
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
|
||||
OUTPUT_NAME datalog-sources
|
||||
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
|
||||
)
|
||||
set_property(TARGET datalog_src_jar PROPERTY FOLDER "java")
|
||||
|
||||
install_jar(datalog_src_jar DESTINATION ${java_lib_dest})
|
||||
endif()
|
||||
|
||||
install(TARGETS datalog EXPORT datalog)
|
||||
export(TARGETS datalog FILE datalog.cmake NAMESPACE datalog::)
|
||||
|
||||
configure_file(datalog-config.cmake.in ${WPILIB_BINARY_DIR}/datalog-config.cmake)
|
||||
install(FILES ${WPILIB_BINARY_DIR}/datalog-config.cmake DESTINATION share/datalog)
|
||||
install(EXPORT datalog DESTINATION share/datalog)
|
||||
|
||||
if(WITH_TESTS)
|
||||
file(GLOB_RECURSE datalog_testlib_src src/test/native/include/*.h)
|
||||
add_library(datalog_testlib INTERFACE ${datalog_test_src})
|
||||
target_include_directories(datalog_testlib INTERFACE src/test/native/include)
|
||||
|
||||
wpilib_add_test(datalog src/test/native/cpp)
|
||||
target_link_libraries(datalog_test datalog googletest datalog_testlib wpiutil)
|
||||
if(MSVC)
|
||||
target_compile_options(datalog_test PRIVATE /utf-8)
|
||||
endif()
|
||||
endif()
|
||||
32
datalog/build.gradle
Normal file
32
datalog/build.gradle
Normal file
@@ -0,0 +1,32 @@
|
||||
ext {
|
||||
useJava = true
|
||||
useCpp = true
|
||||
baseId = 'datalog'
|
||||
groupId = 'edu.wpi.first.datalog'
|
||||
|
||||
nativeName = 'datalog'
|
||||
devMain = 'edu.wpi.first.datalog.DevMain'
|
||||
}
|
||||
|
||||
apply from: "${rootDir}/shared/jni/setupBuild.gradle"
|
||||
|
||||
nativeUtils.exportsConfigs {
|
||||
datalog {
|
||||
}
|
||||
}
|
||||
|
||||
model {
|
||||
components {
|
||||
all {
|
||||
it.sources.each {
|
||||
it.exportedHeaders {
|
||||
srcDirs 'src/main/native/include'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api project(":wpiutil")
|
||||
}
|
||||
5
datalog/datalog-config.cmake.in
Normal file
5
datalog/datalog-config.cmake.in
Normal file
@@ -0,0 +1,5 @@
|
||||
@FILENAME_DEP_REPLACE@
|
||||
include(${SELF_DIR}/wpiutil.cmake)
|
||||
if(@WITH_JAVA@)
|
||||
include(${SELF_DIR}/wpiutil_jar.cmake)
|
||||
endif()
|
||||
@@ -9,11 +9,11 @@
|
||||
#include <fmt/chrono.h>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
#include <wpi/DenseMap.h>
|
||||
#include <wpi/MemoryBuffer.h>
|
||||
#include <wpi/print.h>
|
||||
|
||||
#include "wpi/DataLogReader.h"
|
||||
#include "wpi/DenseMap.h"
|
||||
#include "wpi/MemoryBuffer.h"
|
||||
#include "wpi/print.h"
|
||||
#include "wpi/datalog/DataLogReader.h"
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
if (argc != 2) {
|
||||
@@ -8,8 +8,9 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "wpi/DataLogBackgroundWriter.h"
|
||||
#include "wpi/print.h"
|
||||
#include <wpi/print.h>
|
||||
|
||||
#include "wpi/datalog/DataLogBackgroundWriter.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
using std::chrono::duration_cast;
|
||||
12
datalog/src/dev/java/edu/wpi/first/datalog/DevMain.java
Normal file
12
datalog/src/dev/java/edu/wpi/first/datalog/DevMain.java
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
public final class DevMain {
|
||||
/** Main entry point. */
|
||||
public static void main(String[] args) {}
|
||||
|
||||
private DevMain() {}
|
||||
}
|
||||
5
datalog/src/dev/native/cpp/main.cpp
Normal file
5
datalog/src/dev/native/cpp/main.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
int main() {}
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
/** Log boolean values. */
|
||||
public class BooleanLogEntry extends DataLogEntry {
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import edu.wpi.first.util.WPIUtilJNI;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
/**
|
||||
* A data log background writer that periodically flushes the data log on a background thread. The
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
/** Log entry base class. */
|
||||
public class DataLogEntry {
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
@@ -2,18 +2,72 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import edu.wpi.first.util.WPIUtilJNI;
|
||||
import edu.wpi.first.util.RuntimeLoader;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* DataLog wpiutil JNI Functions.
|
||||
* DataLog JNI Functions.
|
||||
*
|
||||
* @see "wpiutil/DataLog.h"
|
||||
* @see "datalog/DataLog.h"
|
||||
*/
|
||||
public class DataLogJNI extends WPIUtilJNI {
|
||||
public class DataLogJNI {
|
||||
static boolean libraryLoaded = false;
|
||||
|
||||
/** Sets whether JNI should be loaded in the static block. */
|
||||
public static class Helper {
|
||||
private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
|
||||
|
||||
/**
|
||||
* Returns true if the JNI should be loaded in the static block.
|
||||
*
|
||||
* @return True if the JNI should be loaded in the static block.
|
||||
*/
|
||||
public static boolean getExtractOnStaticLoad() {
|
||||
return extractOnStaticLoad.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the JNI should be loaded in the static block.
|
||||
*
|
||||
* @param load Whether the JNI should be loaded in the static block.
|
||||
*/
|
||||
public static void setExtractOnStaticLoad(boolean load) {
|
||||
extractOnStaticLoad.set(load);
|
||||
}
|
||||
|
||||
/** Utility class. */
|
||||
private Helper() {}
|
||||
}
|
||||
|
||||
static {
|
||||
if (Helper.getExtractOnStaticLoad()) {
|
||||
try {
|
||||
RuntimeLoader.loadLibrary("datalogjni");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
libraryLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force load the library.
|
||||
*
|
||||
* @throws IOException if the library failed to load
|
||||
*/
|
||||
public static synchronized void forceLoad() throws IOException {
|
||||
if (libraryLoaded) {
|
||||
return;
|
||||
}
|
||||
RuntimeLoader.loadLibrary("datalogjni");
|
||||
libraryLoaded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Data Log background writer. The log will be initially created with a temporary
|
||||
* filename.
|
||||
@@ -298,6 +352,24 @@ public class DataLogJNI extends WPIUtilJNI {
|
||||
*/
|
||||
static native void appendStringArray(long impl, int entry, String[] value, long timestamp);
|
||||
|
||||
/**
|
||||
* Create a native FileLogger. When the specified file is modified, appended data will be appended
|
||||
* to the specified data log.
|
||||
*
|
||||
* @param file path to the file
|
||||
* @param log data log implementation handle
|
||||
* @param key log key to append data to
|
||||
* @return The FileLogger handle.
|
||||
*/
|
||||
public static native long createFileLogger(String file, long log, String key);
|
||||
|
||||
/**
|
||||
* Free a native FileLogger. This causes the FileLogger to stop appending data to the log.
|
||||
*
|
||||
* @param fileTail The FileLogger handle.
|
||||
*/
|
||||
public static native void freeFileLogger(long fileTail);
|
||||
|
||||
/** Utility class. */
|
||||
private DataLogJNI() {}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
/** Log double values. */
|
||||
public class DoubleLogEntry extends DataLogEntry {
|
||||
@@ -2,9 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util;
|
||||
|
||||
import edu.wpi.first.util.datalog.DataLog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
/**
|
||||
* A class version of `tail -f`, otherwise known as `tail -f` at home. Watches a file and puts the
|
||||
@@ -22,11 +20,11 @@ public class FileLogger implements AutoCloseable {
|
||||
* @param key The log key to append data to.
|
||||
*/
|
||||
public FileLogger(String file, DataLog log, String key) {
|
||||
m_impl = WPIUtilJNI.createFileLogger(file, log.getImpl(), key);
|
||||
m_impl = DataLogJNI.createFileLogger(file, log.getImpl(), key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
WPIUtilJNI.freeFileLogger(m_impl);
|
||||
DataLogJNI.freeFileLogger(m_impl);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
/** Log float values. */
|
||||
public class FloatLogEntry extends DataLogEntry {
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
/** Log integer values. */
|
||||
public class IntegerLogEntry extends DataLogEntry {
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import edu.wpi.first.util.protobuf.ProtobufBuffer;
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
/** Log string values. */
|
||||
public class StringLogEntry extends DataLogEntry {
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import edu.wpi.first.util.struct.StructBuffer;
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import edu.wpi.first.util.struct.StructBuffer;
|
||||
@@ -2,8 +2,6 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "wpi/DataLog.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
#include <cstdio>
|
||||
@@ -13,11 +11,13 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "wpi/Endian.h"
|
||||
#include "wpi/Logger.h"
|
||||
#include "wpi/SmallString.h"
|
||||
#include "wpi/print.h"
|
||||
#include "wpi/timestamp.h"
|
||||
#include <wpi/Endian.h>
|
||||
#include <wpi/Logger.h>
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/print.h>
|
||||
#include <wpi/timestamp.h>
|
||||
|
||||
#include "wpi/datalog/DataLog.h"
|
||||
|
||||
using namespace wpi::log;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "wpi/DataLogBackgroundWriter.h"
|
||||
#include "wpi/datalog/DataLogBackgroundWriter.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
@@ -2,13 +2,13 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "wpi/DataLogReader.h"
|
||||
|
||||
#include <bit>
|
||||
#include <utility>
|
||||
|
||||
#include "wpi/DataLog.h"
|
||||
#include "wpi/Endian.h"
|
||||
#include <wpi/Endian.h>
|
||||
|
||||
#include "wpi/datalog/DataLog.h"
|
||||
#include "wpi/datalog/DataLogReader.h"
|
||||
|
||||
using namespace wpi::log;
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "glass/support/DataLogReaderThread.h"
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <wpi/StringExtras.h>
|
||||
#include <wpi/print.h>
|
||||
|
||||
using namespace glass;
|
||||
#include "wpi/datalog/DataLogReaderThread.h"
|
||||
|
||||
using namespace wpi::log;
|
||||
|
||||
DataLogReaderThread::~DataLogReaderThread() {
|
||||
if (m_thread.joinable()) {
|
||||
@@ -2,13 +2,13 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "wpi/DataLogWriter.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "wpi/raw_ostream.h"
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "wpi/datalog/DataLogWriter.h"
|
||||
|
||||
using namespace wpi::log;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "wpi/FileLogger.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#include <fcntl.h>
|
||||
#include <sys/inotify.h>
|
||||
@@ -18,10 +16,11 @@
|
||||
#include <utility>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
|
||||
#include "wpi/StringExtras.h"
|
||||
#include "wpi/datalog/FileLogger.h"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::log {
|
||||
FileLogger::FileLogger(std::string_view file,
|
||||
std::function<void(std::string_view)> callback)
|
||||
#ifdef __linux__
|
||||
@@ -101,4 +100,4 @@ std::function<void(std::string_view)> FileLogger::Buffer(
|
||||
buf.append(leftover.begin(), leftover.end());
|
||||
};
|
||||
}
|
||||
} // namespace wpi
|
||||
} // namespace wpi::log
|
||||
@@ -2,6 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "DataLogJNI.h"
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -9,17 +11,47 @@
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "WPIUtilJNI.h"
|
||||
#include "edu_wpi_first_util_datalog_DataLogJNI.h"
|
||||
#include "wpi/DataLog.h"
|
||||
#include "wpi/DataLogBackgroundWriter.h"
|
||||
#include "wpi/DataLogWriter.h"
|
||||
#include "wpi/jni_util.h"
|
||||
#include "edu_wpi_first_datalog_DataLogJNI.h"
|
||||
#include "wpi/datalog/DataLog.h"
|
||||
#include "wpi/datalog/DataLogBackgroundWriter.h"
|
||||
#include "wpi/datalog/DataLogWriter.h"
|
||||
#include "wpi/datalog/FileLogger.h"
|
||||
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::log;
|
||||
|
||||
static bool mockTimeEnabled = false;
|
||||
static uint64_t mockNow = 0;
|
||||
|
||||
static JException illegalArgEx;
|
||||
static JException indexOobEx;
|
||||
static JException ioEx;
|
||||
static JException nullPointerEx;
|
||||
|
||||
static const JExceptionInit exceptions[] = {
|
||||
{"java/lang/IllegalArgumentException", &illegalArgEx},
|
||||
{"java/lang/IndexOutOfBoundsException", &indexOobEx},
|
||||
{"java/io/IOException", &ioEx},
|
||||
{"java/lang/NullPointerException", &nullPointerEx}};
|
||||
|
||||
void wpi::ThrowIllegalArgumentException(JNIEnv* env, std::string_view msg) {
|
||||
illegalArgEx.Throw(env, msg);
|
||||
}
|
||||
|
||||
void wpi::ThrowIndexOobException(JNIEnv* env, std::string_view msg) {
|
||||
indexOobEx.Throw(env, msg);
|
||||
}
|
||||
|
||||
void wpi::ThrowIOException(JNIEnv* env, std::string_view msg) {
|
||||
ioEx.Throw(env, msg);
|
||||
}
|
||||
|
||||
void wpi::ThrowNullPointerException(JNIEnv* env, std::string_view msg) {
|
||||
nullPointerEx.Throw(env, msg);
|
||||
}
|
||||
|
||||
namespace {
|
||||
class buf_ostream : public wpi::raw_uvector_ostream {
|
||||
private:
|
||||
@@ -34,13 +66,40 @@ class buf_ostream : public wpi::raw_uvector_ostream {
|
||||
|
||||
extern "C" {
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
for (auto& c : exceptions) {
|
||||
*c.cls = JException(env, c.name);
|
||||
if (!*c.cls) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved) {
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& c : exceptions) {
|
||||
c.cls->free(env);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: bgCreate
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/String;DLjava/lang/String;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_bgCreate
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_bgCreate
|
||||
(JNIEnv* env, jclass, jstring dir, jstring filename, jdouble period,
|
||||
jstring extraHeader)
|
||||
{
|
||||
@@ -62,12 +121,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_bgCreate
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: bgSetFilename
|
||||
* Signature: (JLjava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_bgSetFilename
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_bgSetFilename
|
||||
(JNIEnv* env, jclass, jlong impl, jstring filename)
|
||||
{
|
||||
if (impl == 0) {
|
||||
@@ -83,12 +142,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_bgSetFilename
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: fgCreate
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_fgCreate
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_fgCreate
|
||||
(JNIEnv* env, jclass, jstring filename, jstring extraHeader)
|
||||
{
|
||||
if (!filename) {
|
||||
@@ -111,12 +170,28 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_fgCreate
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_util_WPIUtilJNI
|
||||
* Method: now
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_edu_wpi_first_util_WPIUtilJNI_now
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
if (mockTimeEnabled) {
|
||||
return mockNow;
|
||||
} else {
|
||||
return wpi::Now();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: fgCreateMemory
|
||||
* Signature: (Ljava/lang/String;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_fgCreateMemory
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_fgCreateMemory
|
||||
(JNIEnv* env, jclass, jstring extraHeader)
|
||||
{
|
||||
if (!extraHeader) {
|
||||
@@ -129,12 +204,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_fgCreateMemory
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: flush
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_flush
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_flush
|
||||
(JNIEnv* env, jclass, jlong impl)
|
||||
{
|
||||
if (impl == 0) {
|
||||
@@ -145,12 +220,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_flush
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: copyWriteBuffer
|
||||
* Signature: (J[BI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_copyWriteBuffer
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_copyWriteBuffer
|
||||
(JNIEnv* env, jclass, jlong impl, jbyteArray buf, jint start)
|
||||
{
|
||||
if (impl == 0) {
|
||||
@@ -172,12 +247,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_copyWriteBuffer
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: pause
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_pause
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_pause
|
||||
(JNIEnv* env, jclass, jlong impl)
|
||||
{
|
||||
if (impl == 0) {
|
||||
@@ -188,12 +263,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_pause
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: resume
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_resume
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_resume
|
||||
(JNIEnv* env, jclass, jlong impl)
|
||||
{
|
||||
if (impl == 0) {
|
||||
@@ -204,12 +279,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_resume
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: stop
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_stop
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_stop
|
||||
(JNIEnv* env, jclass, jlong impl)
|
||||
{
|
||||
if (impl == 0) {
|
||||
@@ -220,12 +295,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_stop
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: addSchema
|
||||
* Signature: (JLjava/lang/String;Ljava/lang/String;[BJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_addSchema
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_addSchema
|
||||
(JNIEnv* env, jclass, jlong impl, jstring name, jstring type,
|
||||
jbyteArray schema, jlong timestamp)
|
||||
{
|
||||
@@ -239,12 +314,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_addSchema
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: addSchemaString
|
||||
* Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_addSchemaString
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_addSchemaString
|
||||
(JNIEnv* env, jclass, jlong impl, jstring name, jstring type, jstring schema,
|
||||
jlong timestamp)
|
||||
{
|
||||
@@ -261,12 +336,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_addSchemaString
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: start
|
||||
* Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;J)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_start
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_start
|
||||
(JNIEnv* env, jclass, jlong impl, jstring name, jstring type,
|
||||
jstring metadata, jlong timestamp)
|
||||
{
|
||||
@@ -280,12 +355,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_start
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: finish
|
||||
* Signature: (JIJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_finish
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_finish
|
||||
(JNIEnv* env, jclass, jlong impl, jint entry, jlong timestamp)
|
||||
{
|
||||
if (impl == 0) {
|
||||
@@ -296,12 +371,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_finish
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: setMetadata
|
||||
* Signature: (JILjava/lang/String;J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_setMetadata
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_setMetadata
|
||||
(JNIEnv* env, jclass, jlong impl, jint entry, jstring metadata,
|
||||
jlong timestamp)
|
||||
{
|
||||
@@ -314,24 +389,24 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_setMetadata
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: close
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_close
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_close
|
||||
(JNIEnv*, jclass, jlong impl)
|
||||
{
|
||||
delete reinterpret_cast<DataLog*>(impl);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: appendRaw
|
||||
* Signature: (JI[BIIJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_appendRaw
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_appendRaw
|
||||
(JNIEnv* env, jclass, jlong impl, jint entry, jbyteArray value, jint start,
|
||||
jint length, jlong timestamp)
|
||||
{
|
||||
@@ -362,12 +437,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_appendRaw
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: appendRawBuffer
|
||||
* Signature: (JILjava/lang/Object;IIJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_appendRawBuffer
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_appendRawBuffer
|
||||
(JNIEnv* env, jclass, jlong impl, jint entry, jobject value, jint start,
|
||||
jint length, jlong timestamp)
|
||||
{
|
||||
@@ -398,12 +473,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_appendRawBuffer
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: appendBoolean
|
||||
* Signature: (JIZJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_appendBoolean
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_appendBoolean
|
||||
(JNIEnv* env, jclass, jlong impl, jint entry, jboolean value, jlong timestamp)
|
||||
{
|
||||
if (impl == 0) {
|
||||
@@ -414,12 +489,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_appendBoolean
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: appendInteger
|
||||
* Signature: (JIJJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_appendInteger
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_appendInteger
|
||||
(JNIEnv* env, jclass, jlong impl, jint entry, jlong value, jlong timestamp)
|
||||
{
|
||||
if (impl == 0) {
|
||||
@@ -430,12 +505,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_appendInteger
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: appendFloat
|
||||
* Signature: (JIFJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_appendFloat
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_appendFloat
|
||||
(JNIEnv* env, jclass, jlong impl, jint entry, jfloat value, jlong timestamp)
|
||||
{
|
||||
if (impl == 0) {
|
||||
@@ -446,12 +521,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_appendFloat
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: appendDouble
|
||||
* Signature: (JIDJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_appendDouble
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_appendDouble
|
||||
(JNIEnv* env, jclass, jlong impl, jint entry, jdouble value, jlong timestamp)
|
||||
{
|
||||
if (impl == 0) {
|
||||
@@ -462,12 +537,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_appendDouble
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: appendString
|
||||
* Signature: (JILjava/lang/String;J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_appendString
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_appendString
|
||||
(JNIEnv* env, jclass, jlong impl, jint entry, jstring value, jlong timestamp)
|
||||
{
|
||||
if (impl == 0) {
|
||||
@@ -479,12 +554,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_appendString
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: appendBooleanArray
|
||||
* Signature: (JI[ZJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_appendBooleanArray
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_appendBooleanArray
|
||||
(JNIEnv* env, jclass, jlong impl, jint entry, jbooleanArray value,
|
||||
jlong timestamp)
|
||||
{
|
||||
@@ -501,12 +576,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_appendBooleanArray
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: appendIntegerArray
|
||||
* Signature: (JI[JJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_appendIntegerArray
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_appendIntegerArray
|
||||
(JNIEnv* env, jclass, jlong impl, jint entry, jlongArray value,
|
||||
jlong timestamp)
|
||||
{
|
||||
@@ -534,12 +609,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_appendIntegerArray
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: appendFloatArray
|
||||
* Signature: (JI[FJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_appendFloatArray
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_appendFloatArray
|
||||
(JNIEnv* env, jclass, jlong impl, jint entry, jfloatArray value,
|
||||
jlong timestamp)
|
||||
{
|
||||
@@ -556,12 +631,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_appendFloatArray
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: appendDoubleArray
|
||||
* Signature: (JI[DJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_appendDoubleArray
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_appendDoubleArray
|
||||
(JNIEnv* env, jclass, jlong impl, jint entry, jdoubleArray value,
|
||||
jlong timestamp)
|
||||
{
|
||||
@@ -578,12 +653,12 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_appendDoubleArray
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_datalog_DataLogJNI
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: appendStringArray
|
||||
* Signature: (JI[Ljava/lang/Object;J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_datalog_DataLogJNI_appendStringArray
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_appendStringArray
|
||||
(JNIEnv* env, jclass, jlong impl, jint entry, jobjectArray value,
|
||||
jlong timestamp)
|
||||
{
|
||||
@@ -610,5 +685,41 @@ Java_edu_wpi_first_util_datalog_DataLogJNI_appendStringArray
|
||||
}
|
||||
reinterpret_cast<DataLog*>(impl)->AppendStringArray(entry, arr, timestamp);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: createFileLogger
|
||||
* Signature: (Ljava/lang/String;JLjava/lang/String;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_createFileLogger
|
||||
(JNIEnv* env, jclass, jstring file, jlong log, jstring key)
|
||||
{
|
||||
if (!file) {
|
||||
wpi::ThrowNullPointerException(env, "file is null");
|
||||
return 0;
|
||||
}
|
||||
auto* f = reinterpret_cast<wpi::log::DataLog*>(log);
|
||||
if (!f) {
|
||||
wpi::ThrowNullPointerException(env, "log is null");
|
||||
return 0;
|
||||
}
|
||||
if (!key) {
|
||||
wpi::ThrowNullPointerException(env, "key is null");
|
||||
return 0;
|
||||
}
|
||||
return reinterpret_cast<jlong>(new wpi::log::FileLogger{
|
||||
JStringRef{env, file}, *f, JStringRef{env, key}});
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_datalog_DataLogJNI
|
||||
* Method: freeFileLogger
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_datalog_DataLogJNI_freeFileLogger
|
||||
(JNIEnv* env, jclass, jlong fileTail)
|
||||
{
|
||||
delete reinterpret_cast<wpi::log::FileLogger*>(fileTail);
|
||||
}
|
||||
} // extern "C"
|
||||
18
datalog/src/main/native/cpp/jni/DataLogJNI.h
Normal file
18
datalog/src/main/native/cpp/jni/DataLogJNI.h
Normal file
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace wpi {
|
||||
|
||||
void ThrowIllegalArgumentException(JNIEnv* env, std::string_view msg);
|
||||
void ThrowIndexOobException(JNIEnv* env, std::string_view msg);
|
||||
void ThrowIOException(JNIEnv* env, std::string_view msg);
|
||||
void ThrowNullPointerException(JNIEnv* env, std::string_view msg);
|
||||
|
||||
} // namespace wpi
|
||||
@@ -19,15 +19,16 @@
|
||||
#include <vector>
|
||||
#include <version>
|
||||
|
||||
#include "wpi/DataLog_c.h"
|
||||
#include "wpi/DenseMap.h"
|
||||
#include "wpi/SmallVector.h"
|
||||
#include "wpi/StringMap.h"
|
||||
#include "wpi/mutex.h"
|
||||
#include "wpi/protobuf/Protobuf.h"
|
||||
#include "wpi/string.h"
|
||||
#include "wpi/struct/Struct.h"
|
||||
#include "wpi/timestamp.h"
|
||||
#include <wpi/DenseMap.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/mutex.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
#include <wpi/string.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
#include <wpi/timestamp.h>
|
||||
|
||||
#include "wpi/datalog/DataLog_c.h"
|
||||
|
||||
namespace wpi {
|
||||
class Logger;
|
||||
@@ -12,9 +12,10 @@
|
||||
#include <string_view>
|
||||
#include <thread>
|
||||
|
||||
#include "wpi/DataLog.h"
|
||||
#include "wpi/condition_variable.h"
|
||||
#include "wpi/mutex.h"
|
||||
#include <wpi/condition_variable.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "wpi/datalog/DataLog.h"
|
||||
|
||||
namespace wpi {
|
||||
class Logger;
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "wpi/MemoryBuffer.h"
|
||||
#include <wpi/MemoryBuffer.h>
|
||||
|
||||
namespace wpi::log {
|
||||
|
||||
@@ -13,17 +13,18 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/DataLogReader.h>
|
||||
#include <wpi/DenseMap.h>
|
||||
#include <wpi/Signal.h>
|
||||
#include <wpi/mutex.h>
|
||||
#include <wpi/struct/DynamicStruct.h>
|
||||
|
||||
#include "wpi/datalog/DataLogReader.h"
|
||||
|
||||
#ifndef NO_PROTOBUF
|
||||
#include <wpi/protobuf/ProtobufMessageDatabase.h>
|
||||
#endif
|
||||
|
||||
namespace glass {
|
||||
namespace wpi::log {
|
||||
|
||||
class DataLogReaderRange {
|
||||
public:
|
||||
@@ -105,4 +106,4 @@ class DataLogReaderThread {
|
||||
std::thread m_thread;
|
||||
};
|
||||
|
||||
} // namespace glass
|
||||
} // namespace wpi::log
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <string_view>
|
||||
#include <system_error>
|
||||
|
||||
#include "wpi/DataLog.h"
|
||||
#include "wpi/datalog/DataLog.h"
|
||||
|
||||
namespace wpi {
|
||||
class raw_ostream;
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <stddef.h> // NOLINT
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <wpi/string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -8,9 +8,9 @@
|
||||
#include <string_view>
|
||||
#include <thread>
|
||||
|
||||
#include "wpi/DataLog.h"
|
||||
#include "wpi/datalog/DataLog.h"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::log {
|
||||
/**
|
||||
* A class version of `tail -f`, otherwise known as `tail -f` at home. Watches
|
||||
* a file and puts the data somewhere else. Only works on Linux-based platforms.
|
||||
@@ -58,4 +58,4 @@ class FileLogger {
|
||||
std::thread m_thread;
|
||||
#endif
|
||||
};
|
||||
} // namespace wpi
|
||||
} // namespace wpi::log
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
package printlog;
|
||||
|
||||
import edu.wpi.first.util.datalog.DataLogReader;
|
||||
import edu.wpi.first.util.datalog.DataLogRecord;
|
||||
import edu.wpi.first.datalog.DataLogReader;
|
||||
import edu.wpi.first.datalog.DataLogRecord;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.util.datalog;
|
||||
package edu.wpi.first.datalog;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
@@ -8,10 +8,10 @@
|
||||
#include <vector>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <wpi/Logger.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "wpi/DataLogWriter.h"
|
||||
#include "wpi/Logger.h"
|
||||
#include "wpi/raw_ostream.h"
|
||||
#include "wpi/datalog/DataLogWriter.h"
|
||||
|
||||
namespace {
|
||||
struct ThingA {
|
||||
@@ -8,11 +8,11 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "wpi/FileLogger.h"
|
||||
#include "wpi/datalog/FileLogger.h"
|
||||
|
||||
TEST(FileLoggerTest, BufferSingleLine) {
|
||||
std::vector<std::string> buf;
|
||||
auto func = wpi::FileLogger::Buffer(
|
||||
auto func = wpi::log::FileLogger::Buffer(
|
||||
[&buf](std::string_view line) { buf.emplace_back(line); });
|
||||
func("qwertyuiop\n");
|
||||
EXPECT_EQ("qwertyuiop", buf[0]);
|
||||
@@ -20,7 +20,7 @@ TEST(FileLoggerTest, BufferSingleLine) {
|
||||
|
||||
TEST(FileLoggerTest, BufferMultiLine) {
|
||||
std::vector<std::string> buf;
|
||||
auto func = wpi::FileLogger::Buffer(
|
||||
auto func = wpi::log::FileLogger::Buffer(
|
||||
[&buf](std::string_view line) { buf.emplace_back(line); });
|
||||
func("line 1\nline 2\nline 3\n");
|
||||
EXPECT_EQ("line 1\nline 2\nline 3", buf[0]);
|
||||
@@ -28,7 +28,7 @@ TEST(FileLoggerTest, BufferMultiLine) {
|
||||
|
||||
TEST(FileLoggerTest, BufferPartials) {
|
||||
std::vector<std::string> buf;
|
||||
auto func = wpi::FileLogger::Buffer(
|
||||
auto func = wpi::log::FileLogger::Buffer(
|
||||
[&buf](std::string_view line) { buf.emplace_back(line); });
|
||||
func("part 1");
|
||||
func("part 2\npart 3");
|
||||
@@ -39,7 +39,7 @@ TEST(FileLoggerTest, BufferPartials) {
|
||||
|
||||
TEST(FileLoggerTest, BufferMultiplePartials) {
|
||||
std::vector<std::string> buf;
|
||||
auto func = wpi::FileLogger::Buffer(
|
||||
auto func = wpi::log::FileLogger::Buffer(
|
||||
[&buf](std::string_view line) { buf.emplace_back(line); });
|
||||
func("part 1");
|
||||
func("part 2");
|
||||
@@ -49,7 +49,7 @@ TEST(FileLoggerTest, BufferMultiplePartials) {
|
||||
}
|
||||
TEST(FileLoggerTest, BufferMultipleMultiLinePartials) {
|
||||
std::vector<std::string> buf;
|
||||
auto func = wpi::FileLogger::Buffer(
|
||||
auto func = wpi::log::FileLogger::Buffer(
|
||||
[&buf](std::string_view line) { buf.emplace_back(line); });
|
||||
func("part 1");
|
||||
func("part 2\npart 3");
|
||||
11
datalog/src/test/native/cpp/main.cpp
Normal file
11
datalog/src/test/native/cpp/main.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
int ret = RUN_ALL_TESTS();
|
||||
return ret;
|
||||
}
|
||||
@@ -25,7 +25,7 @@ add_executable(
|
||||
${APP_ICON_MACOSX}
|
||||
)
|
||||
wpilib_link_macos_gui(datalogtool)
|
||||
target_link_libraries(datalogtool libglass ssh)
|
||||
target_link_libraries(datalogtool libglass ssh datalog wpiutil)
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(datalogtool PROPERTIES WIN32_EXECUTABLE YES)
|
||||
|
||||
@@ -99,9 +99,10 @@ model {
|
||||
}
|
||||
it.cppCompiler.define("LIBSSH_STATIC")
|
||||
lib project: ':glass', library: 'glass', linkage: 'static'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
||||
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
|
||||
lib project: ':datalog', library: 'datalog', linkage: 'static'
|
||||
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
||||
nativeUtils.useRequiredLibrary(it, 'libssh')
|
||||
if (it.targetPlatform.operatingSystem.isWindows()) {
|
||||
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
#include <glass/Storage.h>
|
||||
#include <glass/support/DataLogReaderThread.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <imgui_stdlib.h>
|
||||
@@ -30,6 +29,7 @@
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/SpanExtras.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
#include <wpi/datalog/DataLogReaderThread.h>
|
||||
#include <wpi/fmt/raw_ostream.h>
|
||||
#include <wpi/fs.h>
|
||||
#include <wpi/mutex.h>
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
namespace {
|
||||
struct InputFile {
|
||||
explicit InputFile(std::unique_ptr<glass::DataLogReaderThread> datalog);
|
||||
explicit InputFile(std::unique_ptr<wpi::log::DataLogReaderThread> datalog);
|
||||
|
||||
InputFile(std::string_view filename, std::string_view status)
|
||||
: filename{filename},
|
||||
@@ -51,7 +51,7 @@ struct InputFile {
|
||||
|
||||
std::string filename;
|
||||
std::string stem;
|
||||
std::unique_ptr<glass::DataLogReaderThread> datalog;
|
||||
std::unique_ptr<wpi::log::DataLogReaderThread> datalog;
|
||||
std::string status;
|
||||
bool highlight = false;
|
||||
};
|
||||
@@ -140,7 +140,7 @@ static void RebuildEntryTree() {
|
||||
}
|
||||
}
|
||||
|
||||
InputFile::InputFile(std::unique_ptr<glass::DataLogReaderThread> datalog_)
|
||||
InputFile::InputFile(std::unique_ptr<wpi::log::DataLogReaderThread> datalog_)
|
||||
: filename{datalog_->GetBufferIdentifier()},
|
||||
stem{fs::path{filename}.stem().string()},
|
||||
datalog{std::move(datalog_)} {
|
||||
@@ -196,7 +196,7 @@ static std::unique_ptr<InputFile> LoadDataLog(std::string_view filename) {
|
||||
}
|
||||
|
||||
return std::make_unique<InputFile>(
|
||||
std::make_unique<glass::DataLogReaderThread>(std::move(reader)));
|
||||
std::make_unique<wpi::log::DataLogReaderThread>(std::move(reader)));
|
||||
}
|
||||
|
||||
void DisplayInputFiles() {
|
||||
|
||||
@@ -6,6 +6,7 @@ java_library(
|
||||
srcs = glob(["src/main/java/**/*.java"]),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//datalog:datalog-java",
|
||||
"//ntcore:networktables-java",
|
||||
"//wpiunits",
|
||||
"//wpiutil:wpiutil-java",
|
||||
|
||||
@@ -13,4 +13,5 @@ dependencies {
|
||||
api(project(':ntcore'))
|
||||
api(project(':wpiutil'))
|
||||
api(project(':wpiunits'))
|
||||
api(project(':datalog'))
|
||||
}
|
||||
|
||||
@@ -6,21 +6,21 @@ package edu.wpi.first.epilogue.logging;
|
||||
|
||||
import static edu.wpi.first.util.ErrorMessages.requireNonNullParam;
|
||||
|
||||
import edu.wpi.first.util.datalog.BooleanArrayLogEntry;
|
||||
import edu.wpi.first.util.datalog.BooleanLogEntry;
|
||||
import edu.wpi.first.util.datalog.DataLog;
|
||||
import edu.wpi.first.util.datalog.DataLogEntry;
|
||||
import edu.wpi.first.util.datalog.DoubleArrayLogEntry;
|
||||
import edu.wpi.first.util.datalog.DoubleLogEntry;
|
||||
import edu.wpi.first.util.datalog.FloatArrayLogEntry;
|
||||
import edu.wpi.first.util.datalog.FloatLogEntry;
|
||||
import edu.wpi.first.util.datalog.IntegerArrayLogEntry;
|
||||
import edu.wpi.first.util.datalog.IntegerLogEntry;
|
||||
import edu.wpi.first.util.datalog.RawLogEntry;
|
||||
import edu.wpi.first.util.datalog.StringArrayLogEntry;
|
||||
import edu.wpi.first.util.datalog.StringLogEntry;
|
||||
import edu.wpi.first.util.datalog.StructArrayLogEntry;
|
||||
import edu.wpi.first.util.datalog.StructLogEntry;
|
||||
import edu.wpi.first.datalog.BooleanArrayLogEntry;
|
||||
import edu.wpi.first.datalog.BooleanLogEntry;
|
||||
import edu.wpi.first.datalog.DataLog;
|
||||
import edu.wpi.first.datalog.DataLogEntry;
|
||||
import edu.wpi.first.datalog.DoubleArrayLogEntry;
|
||||
import edu.wpi.first.datalog.DoubleLogEntry;
|
||||
import edu.wpi.first.datalog.FloatArrayLogEntry;
|
||||
import edu.wpi.first.datalog.FloatLogEntry;
|
||||
import edu.wpi.first.datalog.IntegerArrayLogEntry;
|
||||
import edu.wpi.first.datalog.IntegerLogEntry;
|
||||
import edu.wpi.first.datalog.RawLogEntry;
|
||||
import edu.wpi.first.datalog.StringArrayLogEntry;
|
||||
import edu.wpi.first.datalog.StringLogEntry;
|
||||
import edu.wpi.first.datalog.StructArrayLogEntry;
|
||||
import edu.wpi.first.datalog.StructLogEntry;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -93,11 +93,12 @@ model {
|
||||
it.buildable = false
|
||||
return
|
||||
}
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
||||
|
||||
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
||||
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
|
||||
lib project: ':fieldImages', library: 'fieldImages', linkage: 'shared'
|
||||
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
||||
}
|
||||
appendDebugPathToBinaries(binaries)
|
||||
}
|
||||
@@ -123,11 +124,11 @@ model {
|
||||
lib library: nativeName, linkage: 'static'
|
||||
project(':ntcore').addNtcoreDependency(it, 'shared')
|
||||
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
||||
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
||||
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
|
||||
lib project: ':fieldImages', library: 'fieldImages', linkage: 'shared'
|
||||
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
||||
}
|
||||
appendDebugPathToBinaries(binaries)
|
||||
}
|
||||
@@ -162,12 +163,12 @@ model {
|
||||
lib library: nativeName, linkage: 'static'
|
||||
project(':ntcore').addNtcoreDependency(it, 'static')
|
||||
lib project: ':wpinet', library: 'wpinet', linkage: 'static'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
||||
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
|
||||
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
|
||||
lib project: ':fieldImages', library: 'fieldImages', linkage: 'static'
|
||||
nativeUtils.useRequiredLibrary(it, 'opencv_static')
|
||||
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
||||
if (it.targetPlatform.operatingSystem.isWindows()) {
|
||||
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
|
||||
it.linker.args << '/DELAYLOAD:MF.dll' << '/DELAYLOAD:MFReadWrite.dll' << '/DELAYLOAD:MFPlat.dll' << '/delay:nobind'
|
||||
|
||||
@@ -47,6 +47,7 @@ cc_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":generated_cc_headers",
|
||||
"//datalog:datalog.static",
|
||||
"//wpinet:wpinet.static",
|
||||
"//wpiutil:wpiutil.static",
|
||||
],
|
||||
@@ -68,6 +69,7 @@ wpilib_jni_java_library(
|
||||
native_libs = [":ntcorejni"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//datalog:datalog-java",
|
||||
"//wpiutil:wpiutil-java",
|
||||
"@maven//:us_hebi_quickbuf_quickbuf_runtime",
|
||||
],
|
||||
|
||||
@@ -26,7 +26,7 @@ target_include_directories(
|
||||
)
|
||||
wpilib_target_warnings(ntcore)
|
||||
target_compile_features(ntcore PUBLIC cxx_std_20)
|
||||
target_link_libraries(ntcore PUBLIC wpinet wpiutil)
|
||||
target_link_libraries(ntcore PUBLIC wpinet wpiutil datalog)
|
||||
|
||||
set_property(TARGET ntcore PROPERTY FOLDER "libraries")
|
||||
|
||||
@@ -53,7 +53,7 @@ if(WITH_JAVA)
|
||||
add_jar(
|
||||
ntcore_jar
|
||||
${JAVA_SOURCES}
|
||||
INCLUDE_JARS wpiutil_jar ${QUICKBUF_JAR}
|
||||
INCLUDE_JARS wpiutil_jar ${QUICKBUF_JAR} datalog_jar
|
||||
OUTPUT_NAME ntcore
|
||||
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
|
||||
GENERATE_NATIVE_HEADERS ntcore_jni_headers
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
ext {
|
||||
addNtcoreDependency = { binary, shared->
|
||||
binary.lib project: ':ntcore', library: 'ntcore', linkage: shared
|
||||
binary.lib project: ':datalog', library: 'datalog', linkage: shared
|
||||
}
|
||||
|
||||
addNtcoreJniDependency = { binary->
|
||||
binary.lib project: ':ntcore', library: 'ntcoreJNIShared', linkage: 'shared'
|
||||
binary.lib project: ':datalog', library: 'datalogJNIShared', linkage: 'shared'
|
||||
}
|
||||
|
||||
nativeName = 'ntcore'
|
||||
@@ -34,9 +36,11 @@ model {
|
||||
if (it.component.name == "${nativeName}JNI") {
|
||||
lib project: ':wpinet', library: 'wpinet', linkage: 'static'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
||||
lib project: ':datalog', library: 'datalog', linkage: 'static'
|
||||
} else {
|
||||
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
||||
lib project: ':datalog', library: 'datalog', linkage: 'shared'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,3 +65,7 @@ nativeUtils.exportsConfigs {
|
||||
x64SymbolFilter = symbolFilter
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api project(":datalog")
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
package edu.wpi.first.networktables;
|
||||
|
||||
import edu.wpi.first.datalog.DataLog;
|
||||
import edu.wpi.first.util.WPIUtilJNI;
|
||||
import edu.wpi.first.util.concurrent.Event;
|
||||
import edu.wpi.first.util.datalog.DataLog;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
package edu.wpi.first.networktables;
|
||||
|
||||
import edu.wpi.first.datalog.DataLog;
|
||||
import edu.wpi.first.util.RuntimeLoader;
|
||||
import edu.wpi.first.util.datalog.DataLog;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.EnumSet;
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
package edu.wpi.first.networktables;
|
||||
|
||||
import edu.wpi.first.datalog.DataLog;
|
||||
import edu.wpi.first.util.WPIUtilJNI;
|
||||
import edu.wpi.first.util.concurrent.Event;
|
||||
import edu.wpi.first.util.datalog.DataLog;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
package edu.wpi.first.networktables;
|
||||
|
||||
import edu.wpi.first.datalog.DataLog;
|
||||
import edu.wpi.first.util.RuntimeLoader;
|
||||
import edu.wpi.first.util.datalog.DataLog;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.EnumSet;
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/DataLog.h>
|
||||
#include <wpi/UidVector.h>
|
||||
#include <wpi/datalog/DataLog.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "Handle.h"
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include "LocalDataLogger.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <wpi/DataLog.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
#include <wpi/datalog/DataLog.h>
|
||||
|
||||
using namespace nt::local;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <wpi/DataLog.h>
|
||||
#include <wpi/datalog/DataLog.h>
|
||||
|
||||
#include "ntcore_c.h"
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ranges.h>
|
||||
#include <wpi/DataLog.h>
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
#include <wpi/datalog/DataLog.h>
|
||||
|
||||
#include "IListenerStorage.h"
|
||||
#include "Log.h"
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
#include <fmt/chrono.h>
|
||||
#include <fmt/format.h>
|
||||
#include <networktables/NetworkTableInstance.h>
|
||||
#include <wpi/DataLogBackgroundWriter.h>
|
||||
#include <wpi/FileLogger.h>
|
||||
#include <wpi/SafeThread.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
#include <wpi/datalog/DataLogBackgroundWriter.h>
|
||||
#include <wpi/datalog/FileLogger.h>
|
||||
#include <wpi/fs.h>
|
||||
#include <wpi/print.h>
|
||||
|
||||
@@ -202,7 +202,7 @@ struct Thread final : public wpi::SafeThread {
|
||||
NT_DataLogger m_ntEntryLogger = 0;
|
||||
NT_ConnectionDataLogger m_ntConnLogger = 0;
|
||||
bool m_consoleLoggerEnabled = false;
|
||||
wpi::FileLogger m_consoleLogger;
|
||||
wpi::log::FileLogger m_consoleLogger;
|
||||
wpi::log::StringLogEntry m_messageLog;
|
||||
};
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ include 'epilogue-runtime'
|
||||
include 'thirdparty:googletest'
|
||||
include 'thirdparty:imgui_suite'
|
||||
include 'wpical'
|
||||
include 'datalog'
|
||||
|
||||
buildCache {
|
||||
def cred = {
|
||||
|
||||
@@ -25,7 +25,7 @@ endif()
|
||||
wpilib_link_macos_gui(sysid)
|
||||
wpilib_target_warnings(sysid)
|
||||
target_include_directories(sysid PRIVATE src/main/native/include)
|
||||
target_link_libraries(sysid wpimath libglass)
|
||||
target_link_libraries(sysid wpimath libglass datalog)
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(sysid PROPERTIES WIN32_EXECUTABLE YES)
|
||||
@@ -42,5 +42,5 @@ if(WITH_TESTS)
|
||||
target_compile_options(sysid_test PRIVATE /utf-8)
|
||||
endif()
|
||||
target_include_directories(sysid_test PRIVATE src/main/native/cpp src/main/native/include)
|
||||
target_link_libraries(sysid_test wpimath libglass googletest)
|
||||
target_link_libraries(sysid_test wpimath libglass datalog googletest)
|
||||
endif()
|
||||
|
||||
@@ -98,9 +98,10 @@ model {
|
||||
}
|
||||
lib project: ':glass', library: 'glass', linkage: 'static'
|
||||
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
||||
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
|
||||
lib project: ':datalog', library: 'datalog', linkage: 'static'
|
||||
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
||||
if (it.targetPlatform.operatingSystem.isWindows()) {
|
||||
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
|
||||
it.linker.args << '/DELAYLOAD:MF.dll' << '/DELAYLOAD:MFReadWrite.dll' << '/DELAYLOAD:MFPlat.dll' << '/delay:nobind'
|
||||
@@ -137,9 +138,10 @@ model {
|
||||
}
|
||||
lib project: ':glass', library: 'glass', linkage: 'static'
|
||||
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
||||
lib project: ':datalog', library: 'datalog', linkage: 'static'
|
||||
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
|
||||
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
||||
if (it.targetPlatform.operatingSystem.isWindows()) {
|
||||
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
|
||||
it.linker.args << '/DELAYLOAD:MF.dll' << '/DELAYLOAD:MFReadWrite.dll' << '/DELAYLOAD:MFPlat.dll' << '/delay:nobind'
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <glass/support/DataLogReaderThread.h>
|
||||
#include <imgui.h>
|
||||
#include <wpi/DataLogReader.h>
|
||||
#include <wpi/Logger.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
#include <wpi/datalog/DataLogReader.h>
|
||||
#include <wpi/datalog/DataLogReaderThread.h>
|
||||
|
||||
#include "sysid/Util.h"
|
||||
#include "sysid/analysis/AnalysisType.h"
|
||||
@@ -25,7 +25,7 @@ using namespace sysid;
|
||||
static constexpr const char* kAnalysisTypes[] = {"Elevator", "Arm", "Simple"};
|
||||
|
||||
static bool EmitEntryTarget(const char* name, bool isString,
|
||||
const glass::DataLogReaderEntry** entry) {
|
||||
const wpi::log::DataLogReaderEntry** entry) {
|
||||
if (*entry) {
|
||||
auto text =
|
||||
fmt::format("{}: {} ({})", name, (*entry)->name, (*entry)->type);
|
||||
@@ -38,8 +38,9 @@ static bool EmitEntryTarget(const char* name, bool isString,
|
||||
if (ImGui::BeginDragDropTarget()) {
|
||||
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(
|
||||
isString ? "DataLogEntryString" : "DataLogEntry")) {
|
||||
assert(payload->DataSize == sizeof(const glass::DataLogReaderEntry*));
|
||||
*entry = *static_cast<const glass::DataLogReaderEntry**>(payload->Data);
|
||||
assert(payload->DataSize == sizeof(const wpi::log::DataLogReaderEntry*));
|
||||
*entry =
|
||||
*static_cast<const wpi::log::DataLogReaderEntry**>(payload->Data);
|
||||
rv = true;
|
||||
}
|
||||
ImGui::EndDragDropTarget();
|
||||
@@ -179,7 +180,7 @@ void DataSelector::Reset() {
|
||||
}
|
||||
|
||||
DataSelector::Tests DataSelector::LoadTests(
|
||||
const glass::DataLogReaderEntry& testStateEntry) {
|
||||
const wpi::log::DataLogReaderEntry& testStateEntry) {
|
||||
Tests tests;
|
||||
for (auto&& range : testStateEntry.ranges) {
|
||||
std::string_view prevState;
|
||||
@@ -245,7 +246,7 @@ static void AddSamples(std::vector<MotorData::Run::Sample<T>>& samples,
|
||||
}
|
||||
|
||||
static std::vector<std::pair<int64_t, double>> GetData(
|
||||
const glass::DataLogReaderEntry& entry, double scale) {
|
||||
const wpi::log::DataLogReaderEntry& entry, double scale) {
|
||||
std::vector<std::pair<int64_t, double>> rv;
|
||||
bool isDouble = entry.type == "double";
|
||||
for (auto&& range : entry.ranges) {
|
||||
|
||||
@@ -12,13 +12,13 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <glass/support/DataLogReaderThread.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_stdlib.h>
|
||||
#include <portable-file-dialogs.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/SpanExtras.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
#include <wpi/datalog/DataLogReaderThread.h>
|
||||
#include <wpi/fs.h>
|
||||
|
||||
using namespace sysid;
|
||||
@@ -55,7 +55,7 @@ void LogLoader::Display() {
|
||||
}
|
||||
unload();
|
||||
m_reader =
|
||||
std::make_unique<glass::DataLogReaderThread>(std::move(reader));
|
||||
std::make_unique<wpi::log::DataLogReaderThread>(std::move(reader));
|
||||
m_entryTree.clear();
|
||||
}
|
||||
m_opener.reset();
|
||||
@@ -108,7 +108,7 @@ void LogLoader::Display() {
|
||||
void LogLoader::RebuildEntryTree() {
|
||||
m_entryTree.clear();
|
||||
wpi::SmallVector<std::string_view, 16> parts;
|
||||
m_reader->ForEachEntryName([&](const glass::DataLogReaderEntry& entry) {
|
||||
m_reader->ForEachEntryName([&](const wpi::log::DataLogReaderEntry& entry) {
|
||||
// only show double/float/string entries (TODO: support struct/protobuf)
|
||||
if (entry.type != "double" && entry.type != "float" &&
|
||||
entry.type != "string") {
|
||||
@@ -167,7 +167,7 @@ void LogLoader::RebuildEntryTree() {
|
||||
}
|
||||
|
||||
static void EmitEntry(const std::string& name,
|
||||
const glass::DataLogReaderEntry& entry) {
|
||||
const wpi::log::DataLogReaderEntry& entry) {
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Selectable(name.c_str());
|
||||
if (ImGui::BeginDragDropSource()) {
|
||||
|
||||
@@ -12,17 +12,19 @@
|
||||
#include <vector>
|
||||
|
||||
#include <glass/View.h>
|
||||
#include <glass/support/DataLogReaderThread.h>
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/datalog/DataLogReaderThread.h>
|
||||
|
||||
#include "sysid/analysis/Storage.h"
|
||||
|
||||
namespace glass {
|
||||
class DataLogReaderEntry;
|
||||
class Storage;
|
||||
} // namespace glass
|
||||
|
||||
namespace wpi {
|
||||
namespace log {
|
||||
class DataLogReaderEntry;
|
||||
} // namespace log
|
||||
class Logger;
|
||||
} // namespace wpi
|
||||
|
||||
@@ -64,10 +66,10 @@ class DataSelector : public glass::View {
|
||||
std::future<Tests> m_testsFuture;
|
||||
Tests m_tests;
|
||||
std::string m_selectedTest;
|
||||
const glass::DataLogReaderEntry* m_testStateEntry = nullptr;
|
||||
const glass::DataLogReaderEntry* m_velocityEntry = nullptr;
|
||||
const glass::DataLogReaderEntry* m_positionEntry = nullptr;
|
||||
const glass::DataLogReaderEntry* m_voltageEntry = nullptr;
|
||||
const wpi::log::DataLogReaderEntry* m_testStateEntry = nullptr;
|
||||
const wpi::log::DataLogReaderEntry* m_velocityEntry = nullptr;
|
||||
const wpi::log::DataLogReaderEntry* m_positionEntry = nullptr;
|
||||
const wpi::log::DataLogReaderEntry* m_voltageEntry = nullptr;
|
||||
double m_velocityScale = 1.0;
|
||||
double m_positionScale = 1.0;
|
||||
int m_selectedUnit = 0;
|
||||
@@ -75,7 +77,7 @@ class DataSelector : public glass::View {
|
||||
std::future<TestData> m_testdataFuture;
|
||||
std::vector<std::string> m_testdataStats;
|
||||
|
||||
static Tests LoadTests(const glass::DataLogReaderEntry& testStateEntry);
|
||||
static Tests LoadTests(const wpi::log::DataLogReaderEntry& testStateEntry);
|
||||
TestData BuildTestData();
|
||||
};
|
||||
} // namespace sysid
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#include <wpi/Signal.h>
|
||||
|
||||
namespace glass {
|
||||
class DataLogReaderEntry;
|
||||
class DataLogReaderThread;
|
||||
class Storage;
|
||||
} // namespace glass
|
||||
|
||||
@@ -23,6 +21,10 @@ class open_file;
|
||||
} // namespace pfd
|
||||
|
||||
namespace wpi {
|
||||
namespace log {
|
||||
class DataLogReaderEntry;
|
||||
class DataLogReaderThread;
|
||||
} // namespace log
|
||||
class Logger;
|
||||
} // namespace wpi
|
||||
|
||||
@@ -57,7 +59,7 @@ class LogLoader : public glass::View {
|
||||
|
||||
std::string m_filename;
|
||||
std::unique_ptr<pfd::open_file> m_opener;
|
||||
std::unique_ptr<glass::DataLogReaderThread> m_reader;
|
||||
std::unique_ptr<wpi::log::DataLogReaderThread> m_reader;
|
||||
|
||||
std::string m_error;
|
||||
|
||||
@@ -67,7 +69,7 @@ class LogLoader : public glass::View {
|
||||
explicit EntryTreeNode(std::string_view name) : name{name} {}
|
||||
std::string name; // name of just this node
|
||||
std::string path; // full path if entry is nullptr
|
||||
const glass::DataLogReaderEntry* entry = nullptr;
|
||||
const wpi::log::DataLogReaderEntry* entry = nullptr;
|
||||
std::vector<EntryTreeNode> children; // children, sorted by name
|
||||
};
|
||||
std::vector<EntryTreeNode> m_entryTree;
|
||||
|
||||
@@ -22,6 +22,7 @@ if(WITH_JAVA)
|
||||
wpiunits_jar
|
||||
wpiutil_jar
|
||||
wpilibj_jar
|
||||
datalog_jar
|
||||
OUTPUT_NAME wpilibNewCommands
|
||||
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
|
||||
)
|
||||
|
||||
@@ -21,6 +21,7 @@ dependencies {
|
||||
implementation project(':hal')
|
||||
implementation project(':wpimath')
|
||||
implementation project(':wpilibj')
|
||||
api project(':datalog')
|
||||
testImplementation 'org.mockito:mockito-core:4.1.0'
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ cc_library(
|
||||
":generated_cc_headers",
|
||||
"//cameraserver:cameraserver.static",
|
||||
"//cscore:cscore.static",
|
||||
"//datalog:datalog.static",
|
||||
"//hal:wpiHal.static",
|
||||
"//ntcore:ntcore.static",
|
||||
"//wpimath:wpimath.static",
|
||||
|
||||
@@ -35,7 +35,7 @@ else()
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(wpilibc PUBLIC hal ntcore wpimath wpiutil)
|
||||
target_link_libraries(wpilibc PUBLIC hal ntcore wpimath datalog)
|
||||
|
||||
set_property(TARGET wpilibc PROPERTY FOLDER "libraries")
|
||||
|
||||
|
||||
@@ -112,6 +112,7 @@ model {
|
||||
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
||||
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
||||
lib project: ':datalog', library: 'datalog', linkage: 'shared'
|
||||
}
|
||||
}
|
||||
"${nativeName}"(NativeLibrarySpec) {
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
#include <fmt/chrono.h>
|
||||
#include <hal/UsageReporting.h>
|
||||
#include <networktables/NetworkTableInstance.h>
|
||||
#include <wpi/DataLog.h>
|
||||
#include <wpi/DataLogBackgroundWriter.h>
|
||||
#include <wpi/FileLogger.h>
|
||||
#include <wpi/SafeThread.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
#include <wpi/datalog/DataLog.h>
|
||||
#include <wpi/datalog/DataLogBackgroundWriter.h>
|
||||
#include <wpi/datalog/FileLogger.h>
|
||||
#include <wpi/fs.h>
|
||||
#include <wpi/print.h>
|
||||
#include <wpi/timestamp.h>
|
||||
@@ -51,7 +51,7 @@ struct Thread final : public wpi::SafeThread {
|
||||
NT_DataLogger m_ntEntryLogger = 0;
|
||||
NT_ConnectionDataLogger m_ntConnLogger = 0;
|
||||
bool m_consoleLoggerEnabled = false;
|
||||
wpi::FileLogger m_consoleLogger;
|
||||
wpi::log::FileLogger m_consoleLogger;
|
||||
wpi::log::StringLogEntry m_messageLog;
|
||||
};
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
#include <networktables/NetworkTable.h>
|
||||
#include <networktables/NetworkTableInstance.h>
|
||||
#include <networktables/StringTopic.h>
|
||||
#include <wpi/DataLog.h>
|
||||
#include <wpi/EventVector.h>
|
||||
#include <wpi/condition_variable.h>
|
||||
#include <wpi/datalog/DataLog.h>
|
||||
#include <wpi/json.h>
|
||||
#include <wpi/mutex.h>
|
||||
#include <wpi/timestamp.h>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <units/length.h>
|
||||
#include <units/velocity.h>
|
||||
#include <units/voltage.h>
|
||||
#include <wpi/DataLog.h>
|
||||
#include <wpi/datalog/DataLog.h>
|
||||
|
||||
namespace frc::sysid {
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ java_library(
|
||||
deps = [
|
||||
"//cameraserver:cameraserver-java",
|
||||
"//cscore:cscore-java",
|
||||
"//datalog:datalog-java",
|
||||
"//hal:hal-java",
|
||||
"//ntcore:networktables-java",
|
||||
"//wpimath:wpimath-java",
|
||||
|
||||
@@ -41,6 +41,7 @@ if(WITH_JAVA)
|
||||
wpimath_jar
|
||||
wpiunits_jar
|
||||
wpiutil_jar
|
||||
datalog_jar
|
||||
OUTPUT_NAME wpilibj
|
||||
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
|
||||
)
|
||||
|
||||
@@ -69,6 +69,7 @@ dependencies {
|
||||
implementation project(':wpimath')
|
||||
implementation project(':ntcore')
|
||||
implementation project(':cscore')
|
||||
api project(':datalog')
|
||||
implementation project(':cameraserver')
|
||||
testImplementation 'org.mockito:mockito-core:4.1.0'
|
||||
devImplementation sourceSets.main.output
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
import edu.wpi.first.datalog.DataLog;
|
||||
import edu.wpi.first.datalog.DataLogBackgroundWriter;
|
||||
import edu.wpi.first.datalog.FileLogger;
|
||||
import edu.wpi.first.datalog.IntegerLogEntry;
|
||||
import edu.wpi.first.datalog.StringLogEntry;
|
||||
import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||
import edu.wpi.first.util.FileLogger;
|
||||
import edu.wpi.first.util.WPIUtilJNI;
|
||||
import edu.wpi.first.util.concurrent.Event;
|
||||
import edu.wpi.first.util.datalog.DataLog;
|
||||
import edu.wpi.first.util.datalog.DataLogBackgroundWriter;
|
||||
import edu.wpi.first.util.datalog.IntegerLogEntry;
|
||||
import edu.wpi.first.util.datalog.StringLogEntry;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
import edu.wpi.first.datalog.BooleanArrayLogEntry;
|
||||
import edu.wpi.first.datalog.BooleanLogEntry;
|
||||
import edu.wpi.first.datalog.DataLog;
|
||||
import edu.wpi.first.datalog.FloatArrayLogEntry;
|
||||
import edu.wpi.first.datalog.IntegerArrayLogEntry;
|
||||
import edu.wpi.first.hal.AllianceStationID;
|
||||
import edu.wpi.first.hal.ControlWord;
|
||||
import edu.wpi.first.hal.DriverStationJNI;
|
||||
@@ -16,11 +21,6 @@ import edu.wpi.first.networktables.StringPublisher;
|
||||
import edu.wpi.first.networktables.StringTopic;
|
||||
import edu.wpi.first.util.EventVector;
|
||||
import edu.wpi.first.util.WPIUtilJNI;
|
||||
import edu.wpi.first.util.datalog.BooleanArrayLogEntry;
|
||||
import edu.wpi.first.util.datalog.BooleanLogEntry;
|
||||
import edu.wpi.first.util.datalog.DataLog;
|
||||
import edu.wpi.first.util.datalog.FloatArrayLogEntry;
|
||||
import edu.wpi.first.util.datalog.IntegerArrayLogEntry;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -12,6 +12,8 @@ import static edu.wpi.first.units.Units.RotationsPerSecond;
|
||||
import static edu.wpi.first.units.Units.Second;
|
||||
import static edu.wpi.first.units.Units.Volts;
|
||||
|
||||
import edu.wpi.first.datalog.DoubleLogEntry;
|
||||
import edu.wpi.first.datalog.StringLogEntry;
|
||||
import edu.wpi.first.units.measure.Angle;
|
||||
import edu.wpi.first.units.measure.AngularAcceleration;
|
||||
import edu.wpi.first.units.measure.AngularVelocity;
|
||||
@@ -20,8 +22,6 @@ import edu.wpi.first.units.measure.Distance;
|
||||
import edu.wpi.first.units.measure.LinearAcceleration;
|
||||
import edu.wpi.first.units.measure.LinearVelocity;
|
||||
import edu.wpi.first.units.measure.Voltage;
|
||||
import edu.wpi.first.util.datalog.DoubleLogEntry;
|
||||
import edu.wpi.first.util.datalog.StringLogEntry;
|
||||
import edu.wpi.first.wpilibj.DataLogManager;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||
load("@rules_java//java:defs.bzl", "java_binary")
|
||||
load("@rules_python//python:defs.bzl", "py_binary")
|
||||
load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test")
|
||||
load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library")
|
||||
load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources")
|
||||
@@ -305,34 +304,3 @@ java_binary(
|
||||
":wpiutil-java",
|
||||
],
|
||||
)
|
||||
|
||||
py_binary(
|
||||
name = "datalog",
|
||||
srcs = ["examples/printlog/datalog.py"],
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "printlog",
|
||||
srcs = ["examples/printlog/printlog.cpp"],
|
||||
deps = [
|
||||
":wpiutil.static",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "writelog",
|
||||
srcs = ["examples/writelog/writelog.cpp"],
|
||||
deps = [
|
||||
":wpiutil.static",
|
||||
],
|
||||
)
|
||||
|
||||
java_binary(
|
||||
name = "printlog-java",
|
||||
srcs = ["src/printlog/java/printlog/PrintLog.java"],
|
||||
main_class = "printlog.PrintLog",
|
||||
deps = [
|
||||
":wpiutil-java",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -6,11 +6,7 @@ include(CompileWarnings)
|
||||
include(AddTest)
|
||||
include(DownloadAndCheck)
|
||||
|
||||
file(
|
||||
GLOB wpiutil_jni_src
|
||||
src/main/native/cpp/jni/WPIUtilJNI.cpp
|
||||
src/main/native/cpp/jni/DataLogJNI.cpp
|
||||
)
|
||||
file(GLOB wpiutil_jni_src src/main/native/cpp/jni/WPIUtilJNI.cpp)
|
||||
|
||||
# Java bindings
|
||||
if(WITH_JAVA)
|
||||
|
||||
@@ -222,24 +222,6 @@ public class WPIUtilJNI {
|
||||
public static native int[] waitForObjectsTimeout(int[] handles, double timeout)
|
||||
throws InterruptedException;
|
||||
|
||||
/**
|
||||
* Create a native FileLogger. When the specified file is modified, appended data will be appended
|
||||
* to the specified data log.
|
||||
*
|
||||
* @param file path to the file
|
||||
* @param log data log implementation handle
|
||||
* @param key log key to append data to
|
||||
* @return The FileLogger handle.
|
||||
*/
|
||||
public static native long createFileLogger(String file, long log, String key);
|
||||
|
||||
/**
|
||||
* Free a native FileLogger. This causes the FileLogger to stop appending data to the log.
|
||||
*
|
||||
* @param fileTail The FileLogger handle.
|
||||
*/
|
||||
public static native void freeFileLogger(long fileTail);
|
||||
|
||||
/** Utility class. */
|
||||
protected WPIUtilJNI() {}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include <jni.h>
|
||||
|
||||
#include "edu_wpi_first_util_WPIUtilJNI.h"
|
||||
#include "wpi/DataLog.h"
|
||||
#include "wpi/FileLogger.h"
|
||||
#include "wpi/RawFrame.h"
|
||||
#include "wpi/RuntimeCheck.h"
|
||||
#include "wpi/Synchronization.h"
|
||||
@@ -464,42 +462,4 @@ Java_edu_wpi_first_util_WPIUtilJNI_setRawFrameInfo
|
||||
f->stride = stride;
|
||||
f->pixelFormat = pixelFormat;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_WPIUtilJNI
|
||||
* Method: createFileLogger
|
||||
* Signature: (Ljava/lang/String;JLjava/lang/String;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_edu_wpi_first_util_WPIUtilJNI_createFileLogger
|
||||
(JNIEnv* env, jclass, jstring file, jlong log, jstring key)
|
||||
{
|
||||
if (!file) {
|
||||
wpi::ThrowNullPointerException(env, "file is null");
|
||||
return 0;
|
||||
}
|
||||
auto* f = reinterpret_cast<wpi::log::DataLog*>(log);
|
||||
if (!f) {
|
||||
wpi::ThrowNullPointerException(env, "log is null");
|
||||
return 0;
|
||||
}
|
||||
if (!key) {
|
||||
wpi::ThrowNullPointerException(env, "key is null");
|
||||
return 0;
|
||||
}
|
||||
return reinterpret_cast<jlong>(
|
||||
new wpi::FileLogger{JStringRef{env, file}, *f, JStringRef{env, key}});
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_util_WPIUtilJNI
|
||||
* Method: freeFileLogger
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_util_WPIUtilJNI_freeFileLogger
|
||||
(JNIEnv* env, jclass, jlong fileTail)
|
||||
{
|
||||
delete reinterpret_cast<wpi::FileLogger*>(fileTail);
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
Reference in New Issue
Block a user