Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,22 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

include(FetchContent)
include("./cmake/cpp.cmake")
include("./cmake/qml.cmake")
include(target_compile_warn_all)
include(target_copy_dll)

qt_standard_project_setup(REQUIRES 6.10)
find_package(yaml-cpp)

add_subdirectory("${UTIL_SRC_DIR}/Filesystem")
add_subdirectory("${PLOTTING_SRC_DIR}")

# Widgets Recreation
qt_add_executable(widgets_recreation WIN32 MACOSX_BUNDLE
"${WINDOWING_SRC_DIR}/WidgetsRecreation.cpp"
${OTHER_APP_SOURCES} ${WIDGET_SOURCES})

target_include_directories(widgets_recreation PRIVATE ${STD_APP_INCLUDES})
target_compile_warn_all(widgets_recreation)

target_link_libraries(widgets_recreation PRIVATE ${STD_APP_QT6_DEPS})
target_link_libraries(widgets_recreation PRIVATE VSCL::Plot::QChart)
qt_add_executable(testrig_gui WIN32
${APP_SOURCES} ${WIDGET_SOURCES})
target_include_directories(testrig_gui PRIVATE ${STD_APP_INCLUDES})
target_compile_warn_all(testrig_gui)
target_link_libraries(testrig_gui PRIVATE ${STD_APP_QT6_DEPS})
target_link_libraries(testrig_gui PRIVATE VSCL::Plot::QChart)
target_link_libraries(testrig_gui PRIVATE VSCL::FS)
add_executable(VSCL::TestrigGUI ALIAS testrig_gui)

add_subdirectory("${CMAKE_SOURCE_DIR}/test")
43 changes: 2 additions & 41 deletions cmake/cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,14 @@ set(PLOTTING_SRC_DIR "${CMAKE_SOURCE_DIR}/src/Plotting")
set(UTIL_SRC_DIR "${CMAKE_SOURCE_DIR}/src/Util")

set(APP_SOURCES
"${CMAKE_SOURCE_DIR}/src/App/Main.cpp")

# sorry
set(OTHER_APP_SOURCES
"${CMAKE_SOURCE_DIR}/src/App/testMultiplot.cpp")

set(WINDOWING_SOURCES
"${WINDOWING_SRC_DIR}/DevWindow.cpp"
"${WINDOWING_SRC_DIR}/NumericTestWidget.cpp")
"${CMAKE_SOURCE_DIR}/src/Main.cpp"
"${WINDOWING_SRC_DIR}/MainWindow.cpp")

set(DIAL_SOURCES
"${WIDGETS_SRC_DIR}/Dial/Attitude.cpp"
"${WIDGETS_SRC_DIR}/Dial/Composite.cpp")

set(DISPLAYER_SOURCES
"${WIDGETS_SRC_DIR}/Displays/QuantitiesRatesDisplay.cpp"
"${WIDGETS_SRC_DIR}/Displays/QuantitiesRatesRow.cpp"
"${WIDGETS_SRC_DIR}/Displays/RateLabel.cpp"
"${WIDGETS_SRC_DIR}/Displays/MultiPlotContainer.cpp"
"${WIDGETS_SRC_DIR}/Displays/StatusCollector.cpp")
Expand All @@ -54,33 +45,3 @@ set(STD_APP_QT6_DEPS
Qt6::Quick
Qt6::Widgets
Qt6::QuickWidgets)

function(target_compile_warn_all IN_TARGET_NAME)
if (MSVC)
target_compile_options(${IN_TARGET_NAME} PRIVATE "/W4")
else()
target_compile_options(${IN_TARGET_NAME} PRIVATE "-Wall")
endif()
endfunction(target_compile_warn_all)

function(add_subdirectory_silence_warnings IN_DIRECTORY)
get_directory_property(oldCompileOpts COMPILE_OPTIONS)

if (MSVC)
add_compile_options("/W0")
else()
add_compile_options("-w")
endif()
add_subdirectory("${IN_DIRECTORY}" EXCLUDE_FROM_ALL)

set_directory_properties(PROPERTIES COMPILE_OPTIONS "${oldCompileOpts}")
endfunction(add_subdirectory_silence_warnings IN_DIRECTORY)

function(target_copy_dll IN_TARGET)
if (WIN32)
add_custom_command(TARGET ${IN_TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_RUNTIME_DLLS:${IN_TARGET}> $<TARGET_FILE_DIR:${IN_TARGET}>
COMMAND_EXPAND_LISTS)
endif()
endfunction(target_copy_dll IN_TARGET)
Empty file removed cmake/qml.cmake
Empty file.
7 changes: 7 additions & 0 deletions cmake/target_compile_warn_all.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function(target_compile_warn_all IN_TARGET_NAME)
if (MSVC)
target_compile_options(${IN_TARGET_NAME} PRIVATE "/W4")
else()
target_compile_options(${IN_TARGET_NAME} PRIVATE "-Wall")
endif()
endfunction(target_compile_warn_all)
8 changes: 8 additions & 0 deletions cmake/target_copy_dll.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function(target_copy_dll IN_TARGET)
if (WIN32)
add_custom_command(TARGET ${IN_TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_RUNTIME_DLLS:${IN_TARGET}> $<TARGET_FILE_DIR:${IN_TARGET}>
COMMAND_EXPAND_LISTS)
endif()
endfunction(target_copy_dll IN_TARGET)
15 changes: 0 additions & 15 deletions src/App/Main.cpp

This file was deleted.

13 changes: 0 additions & 13 deletions src/App/Recreation.cpp

This file was deleted.

14 changes: 0 additions & 14 deletions src/App/testMultiplot.cpp

This file was deleted.

46 changes: 46 additions & 0 deletions src/Main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <QApplication>
#include <QWindow>
#include <QWidget>
#include <fstream>

#include "Windowing/MainWindow.hpp"
#include "Util/Filesystem/Config.hpp"
#include "Util/Filesystem/State.hpp"

namespace fs = std::filesystem;

static VSCL::Settings settings{};
static VSCL::State state{};

int main(int argc, char** argv) {
QApplication app(argc, argv);

fs::path cfg = VSCL::FS::GetConfigFile();
if (!fs::is_regular_file(cfg)) {
std::ofstream streem(cfg.string());
streem << VSCL::FS::SerializeConfigToYAML(settings);
}
else {
settings = VSCL::FS::ReadConfig(cfg);
}

fs::path stat = VSCL::FS::GetStateFile();
if (!fs::is_regular_file(stat)) {
std::ofstream streem(stat.string());
streem << VSCL::FS::SerializeStateToYAML(state);
}

VSCL::MainWindow window;

QString message = window.tr("Test Rig Operations");
window.statusBar()->showMessage(message);

window.setWindowTitle(window.tr("VSCL Gyroscopic Test Rig"));
window.setMinimumSize(
VSCL::Util::MINIMUM_WIDTH, VSCL::Util::MINIMUM_HEIGHT);

window.resize(VSCL::Util::MINIMUM_WIDTH, VSCL::Util::MINIMUM_HEIGHT);

window.show();
return app.exec();
}
23 changes: 22 additions & 1 deletion src/Util/Filesystem/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace stdfs = std::filesystem;

namespace VSCL::FS {

stdfs::path GetConfigFile() {
constexpr std::string_view cfgwhere = GetStandardPath("config");
return GetUserAppData() / cfgwhere / "config.yaml";
Expand All @@ -32,6 +31,24 @@ YAML::Node SerializeConfigToYAML(const VSCL::Settings& settings) {
return top_lvl;
}

VSCL::Settings DeserializeConfigFromYAML(const YAML::Node& serialized) {
if (!serialized["Data"] && !serialized["Connection"]) return VSCL::Settings{};

const YAML::Node& data = serialized["Data"];
const YAML::Node& conn = serialized["Connection"];

return VSCL::Settings {
.Data {
.OutputDirectory = stdfs::path(data["OutputDirectory"].as<std::string>()),
.LogPrefix = data["LogPrefix"].as<std::string>(),
},
.Connect {
.DefaultInterface = conn["DefaultInterface"].as<std::string>(),
.DefaultGatewayPort = conn["DefaultGatewayPort"].as<std::string>(),
},
};
}

void WriteConfig(const VSCL::Settings& settings) {
YAML::Node yamlized = SerializeConfigToYAML(settings);

Expand All @@ -40,4 +57,8 @@ void WriteConfig(const VSCL::Settings& settings) {
cfg << yamlized;
}

VSCL::Settings ReadConfig(const std::filesystem::path& path) {
YAML::Node yamlized = YAML::LoadFile(path.string());
return DeserializeConfigFromYAML(yamlized);
}
} // namespace VSCL::FS
3 changes: 3 additions & 0 deletions src/Util/Filesystem/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ namespace VSCL::FS {

std::filesystem::path GetConfigFile();
YAML::Node SerializeConfigToYAML(const VSCL::Settings& settings);
VSCL::Settings DeserializeConfigFromYAML(const YAML::Node& serialized);

void WriteConfig(const VSCL::Settings& settings);
VSCL::Settings ReadConfig(const std::filesystem::path& path);

} // namespace VSCL::FS
2 changes: 1 addition & 1 deletion src/Util/Filesystem/Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace VSCL {
struct DataSettings {
// Where to output recorded data
std::filesystem::path OutputDirectory =
FS::GetUserAppData() / FS::GetStandardPath("config");
FS::GetUserAppData() / FS::GetStandardPath("data");

// Data csv log prefix
std::string LogPrefix = "run";
Expand Down
4 changes: 4 additions & 0 deletions src/Util/Filesystem/State.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include <fstream>
#include <chrono>
#include <format>

#include "UserPaths.hpp"
#include "State.hpp"

Expand All @@ -17,6 +20,7 @@ stdfs::path GetStateFile() {
YAML::Node SerializeStateToYAML(const VSCL::State& state) {
YAML::Node top_lvl;
top_lvl["LatestSocket"] = state.LatestSocket.string();
top_lvl["LatestRecord"] = std::format("{}", std::chrono::utc_clock::now());

return top_lvl;
}
Expand Down
16 changes: 0 additions & 16 deletions src/Widgets/Displays/QuantitiesRatesDisplay.cpp

This file was deleted.

28 changes: 0 additions & 28 deletions src/Widgets/Displays/QuantitiesRatesDisplay.hpp

This file was deleted.

61 changes: 0 additions & 61 deletions src/Widgets/Displays/QuantitiesRatesRow.cpp

This file was deleted.

Loading
Loading