Skip to content

Commit

Permalink
Mon CLI: Implemented TUI Version of eCAL Mon (eclipse-ecal#730)
Browse files Browse the repository at this point in the history
Co-authored-by: Aleksandar Brakmic <[email protected]>
  • Loading branch information
1 parent 28a3ad9 commit e83135e
Show file tree
Hide file tree
Showing 77 changed files with 6,480 additions and 639 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
-DHAS_QT5=ON \
-DHAS_CURL=ON \
-DHAS_CAPNPROTO=ON \
-DHAS_FTXUI=ON \
-DBUILD_DOCS=ON \
-DBUILD_APPS=ON \
-DBUILD_SAMPLES=ON \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-ubuntu-18.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
-DHAS_QT5=ON \
-DHAS_CURL=ON \
-DHAS_CAPNPROTO=ON \
-DHAS_FTXUI=ON \
-DBUILD_DOCS=ON \
-DBUILD_APPS=ON \
-DBUILD_SAMPLES=ON \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-ubuntu-20.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
-DHAS_QT5=ON \
-DHAS_CURL=ON \
-DHAS_CAPNPROTO=ON \
-DHAS_FTXUI=ON \
-DBUILD_DOCS=ON \
-DBUILD_APPS=ON \
-DBUILD_SAMPLES=ON \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-ubuntu-22.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
-DHAS_QT5=ON \
-DHAS_CURL=ON \
-DHAS_CAPNPROTO=ON \
-DHAS_FTXUI=ON \
-DBUILD_DOCS=ON \
-DBUILD_APPS=ON \
-DBUILD_SAMPLES=ON \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-ubuntu-iceoryx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
-DHAS_QT5=ON \
-DHAS_CURL=ON \
-DHAS_CAPNPROTO=ON \
-DHAS_FTXUI=ON \
-DBUILD_DOCS=ON \
-DBUILD_APPS=ON \
-DBUILD_SAMPLES=ON \
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ jobs:
-DHAS_QT5=ON ^
-DHAS_CURL=OFF ^
-DHAS_CAPNPROTO=OFF ^
-DHAS_FTXUI=ON ^
-DBUILD_DOCS=OFF ^
-DBUILD_APPS=OFF ^
-DBUILD_SAMPLES=OFF ^
Expand Down Expand Up @@ -125,6 +126,7 @@ jobs:
-DHAS_QT5=ON ^
-DHAS_CURL=ON ^
-DHAS_CAPNPROTO=OFF ^
-DHAS_FTXUI=ON ^
-DBUILD_DOCS=ON ^
-DBUILD_APPS=ON ^
-DBUILD_SAMPLES=ON ^
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/clang-tidy-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
-DHAS_QT5=ON \
-DHAS_CURL=ON \
-DHAS_CAPNPROTO=OFF \
-DHAS_FTXUI=ON \
-DBUILD_DOCS=OFF \
-DBUILD_APPS=ON \
-DBUILD_SAMPLES=ONS \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
-DHAS_QT5=OFF \
-DHAS_CURL=OFF \
-DHAS_CAPNPROTO=OFF \
-DHAS_FTXUI=ON \
-DBUILD_DOCS=ON \
-DBUILD_APPS=OFF \
-DBUILD_SAMPLES=OFF \
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@
[submodule "thirdparty/yaml-cpp"]
path = thirdparty/yaml-cpp
url = https://github.com/jbeder/yaml-cpp.git
[submodule "thirdparty/ftxui"]
path = thirdparty/ftxui
url = https://github.com/ArthurSonzogni/FTXUI.git
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ option(HAS_HDF5 "Platform supports HDF5 library"
option(HAS_QT5 "Platform supports Qt 5 library" ON)
option(HAS_CURL "Build with CURL (i.e. upload support in the recorder app)" ON)
option(HAS_CAPNPROTO "Platform supports Cap'n Proto library" OFF)
option(HAS_FTXUI "Platform supports FTXUI library. Requires C++17 and up." ON)

option(BUILD_DOCS "Build the eCAL documentation" OFF)
option(BUILD_APPS "Build the eCAL applications" ON)
Expand All @@ -105,6 +106,7 @@ option(ECAL_THIRDPARTY_BUILD_FINEFTP "Build fineFTP with eCAL"
option(ECAL_THIRDPARTY_BUILD_TERMCOLOR "Build termcolor with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_TCP_PUBSUB "Build tcp_pubsub library with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_RECYCLE "Build steinwurf::recylce with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_FTXUI "Build ftxui with eCAL" ON)
# option(ECAL_THIRDPARTY_BUILD_ZLIB "Build zlib with eCAL" ON)
# option(ECAL_THIRDPARTY_BUILD_LIBSSH2 "Build libssh2 with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_GTEST "Build gtest with eCAL" OFF)
Expand Down Expand Up @@ -196,6 +198,7 @@ set(possible_subprojects
CMakeFunctions
qwt
yaml-cpp
ftxui
)

# We should rename the option, but don't know how to do in in a
Expand Down Expand Up @@ -394,7 +397,9 @@ endif()
# --------------------------------------------------------
add_subdirectory(app/apps)
if(BUILD_APPS)
add_subdirectory(app/mon/mon_cli)
if (HAS_FTXUI)
add_subdirectory(app/mon/mon_cli)
endif()
add_subdirectory(app/util/config)
add_subdirectory(app/util/stop)
add_subdirectory(app/sys/sys_core)
Expand Down Expand Up @@ -549,6 +554,7 @@ message(STATUS "HAS_HDF5 : ${HAS_HDF5}")
message(STATUS "HAS_QT5 : ${HAS_QT5}")
message(STATUS "HAS_CURL : ${HAS_CURL}")
message(STATUS "HAS_CAPNPROTO : ${HAS_CAPNPROTO}")
message(STATUS "HAS_FTXUI : ${HAS_FTXUI}")
message(STATUS "BUILD_DOCS : ${BUILD_DOCS}")
message(STATUS "BUILD_APPS : ${BUILD_APPS}")
message(STATUS "BUILD_SAMPLES : ${BUILD_SAMPLES}")
Expand Down
21 changes: 18 additions & 3 deletions app/mon/mon_cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ project(mon)

find_package(Protobuf REQUIRED)
find_package(tclap REQUIRED)
find_package(ftxui REQUIRED)

set(ecalmon_src
src/ecal_mon.cpp
src/main.cpp
)

if(WIN32)
Expand All @@ -39,14 +40,28 @@ target_include_directories(${PROJECT_NAME}
target_compile_definitions(${PROJECT_NAME}
PRIVATE $<$<BOOL:${MSVC}>:PCRE_STATIC;_UNICODE>)

# Upgrade Visual studio toolset version if necessary. Minimum working version is v142
# TODO: Remove this code block as soon as possible
if (MSVC AND (MSVC_TOOLSET_VERSION LESS 142))
set_target_properties(${PROJECT_NAME}
PROPERTIES
VS_PLATFORM_TOOLSET v142
)

list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS "C:/Windows/system32/vcruntime140_1.dll")
include(InstallRequiredSystemLibraries)
endif()

create_targets_protobuf()

target_link_libraries(${PROJECT_NAME}
protobuf::libprotobuf
tclap::tclap
eCAL::core
eCAL::core_pb)
eCAL::core_pb
ftxui::screen
ftxui::dom
ftxui::component)

ecal_install_app(${PROJECT_NAME})

set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER app/mon)
74 changes: 74 additions & 0 deletions app/mon/mon_cli/src/args.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================= eCAL LICENSE =================================
*/
#pragma once

#include <unordered_set>

#include <tclap/CmdLine.h>
#include <tclap/Constraint.h>

#include "ecal_mon_defs.h"

struct Args
{
enum class Color
{
YES, NO, AUTO
};
Color color = Color::AUTO;
};

class ColorArgConstraint : public TCLAP::Constraint<std::string>
{
std::unordered_set<std::string> possible_values = {"auto", "yes", "always", "no", "never"};
std::string description() const override { return ""; }
std::string shortID() const override { return ""; }
bool check(const std::string &value) const override
{
return possible_values.find(value) != possible_values.end();
}
};

Args::Color ColorArgsFromString(const std::string &val)
{
if(val == "yes" || val == "always")
return Args::Color::YES;
if(val == "no" || val == "never")
return Args::Color::NO;
return Args::Color::AUTO;
}

Args ParseArgs(int argc, char** argv)
{
TCLAP::CmdLine cmd(ECAL_MON_NAME, ' ', ECAL_MON_VERSION);
ColorArgConstraint color_arg_constraint{};

auto color = TCLAP::ValueArg<std::string>("", "color",
"Specifies whether monitor should render colors, possible values are (default is auto): \n"
" yes/always - render colors\n"
" no/never - don't render colors\n"
" auto - automatically decide whether to render colors.",
false, "auto", &color_arg_constraint, cmd);

cmd.parse(argc, argv);

return Args {
ColorArgsFromString(color.getValue())
};
}
Loading

0 comments on commit e83135e

Please sign in to comment.