Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev 4.0.0 #69

Draft
wants to merge 163 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
163 commits
Select commit Hold shift + click to select a range
07a8c3d
new aircraft container
Jarthianur May 26, 2019
ce06fe8
major interface changes, use stack-strings and fine-grained lockig fo…
Jarthianur May 27, 2019
e7bbf86
begin new class structure, constants instead of macros
Jarthianur May 28, 2019
294396b
begin removing useless accessors
Jarthianur May 28, 2019
512a85b
new code structureing
Jarthianur May 28, 2019
16bafbc
apply new code structure and format
Jarthianur May 29, 2019
9097cc5
apply new code structure and format
Jarthianur May 29, 2019
f7fa828
replace sctf submod by release header
Jarthianur Jun 1, 2019
3ad839d
restructure parsers, data and processors
Jarthianur Jun 3, 2019
397bd6f
check limits for incoming data
Jarthianur Jun 4, 2019
b163baf
saturate non mandatory fields in processor and fix nmea_size
Jarthianur Jun 4, 2019
d9dcbd3
begin adjusting tests
Jarthianur Jun 4, 2019
2f3d014
-m proxy snprintf for cstring
Jarthianur Jun 10, 2019
464fb96
no section comments
Jarthianur Jul 7, 2019
2eb5384
fix constant definitions
Jarthianur Aug 3, 2019
ed4a077
movable iterator
Jarthianur Aug 3, 2019
563e7bd
some adjustments
Jarthianur Aug 5, 2019
c6a2fd8
refactor names
Jarthianur Aug 5, 2019
50a3d97
adding a workerthread for aircraft feeds to reduce delay in read
Jarthianur Aug 10, 2019
e436928
templateing workerthread
Jarthianur Aug 10, 2019
b3002e0
update sctf
Jarthianur Aug 15, 2019
a9584e4
bump version
Jarthianur Aug 21, 2019
b8afbc0
Merge pull request #51 from Jarthianur/better-locking-strategy
Jarthianur Aug 21, 2019
bdccf92
build with cpp17
Jarthianur Aug 21, 2019
9772239
upgrade clang-format, begin cpp17 changes
Jarthianur Aug 21, 2019
d5e9b6f
apply more cpp17 changes
Jarthianur Aug 21, 2019
99f84df
refactor cpp17 and logger
Jarthianur Aug 22, 2019
a42b7fc
more cpp17 refactores
Jarthianur Aug 22, 2019
586399f
more cpp17 refactoring and ctor provided accessor for data
Jarthianur Aug 23, 2019
fc7b944
more cpp17 refactoring
Jarthianur Aug 23, 2019
98deeb8
cstring using string_view
Jarthianur Aug 24, 2019
c48fa15
cpp17 refactors, fix member order feed
Jarthianur Aug 27, 2019
6f78856
client logprefix dispatch
Jarthianur Aug 27, 2019
aa7e609
Merge pull request #52 from Jarthianur/dev_upgrade-cpp17
Jarthianur Aug 27, 2019
becb3ed
impl guarded thread, split into concurrency package, vfrb namespace
Jarthianur Aug 27, 2019
2fc0f6f
refactor, custom exceptions
Jarthianur Aug 28, 2019
d3906dc
more custom exceptions
Jarthianur Aug 29, 2019
c71450c
custom exception handling
Jarthianur Aug 30, 2019
fa035fd
Merge pull request #53 from Jarthianur/dev_3.1.0_custom-exceptions
Jarthianur Aug 30, 2019
182ad1a
client as FSM to fix timeout handler bug
Jarthianur Aug 31, 2019
7b76e42
use move semantics for processing incoming data
Jarthianur Aug 31, 2019
90c5421
debug and gcov for test build
Jarthianur Sep 1, 2019
d33c17b
Merge pull request #54 from Jarthianur/dev_3.1.0_refactor-clients
Jarthianur Sep 1, 2019
155e973
use string_view and charconv for checksum
Jarthianur Sep 1, 2019
4a84078
add profiling, fix KA loop
Jarthianur Sep 9, 2019
59a10e3
profiling builds
Jarthianur Sep 20, 2019
c400d39
adjust profilers
Jarthianur Sep 22, 2019
15be6b1
rework timestamp
Jarthianur Sep 22, 2019
84e9ae6
use string views and fast conversion
Jarthianur Sep 22, 2019
4a595b3
bump version
Jarthianur Sep 22, 2019
c348525
update aprs parser
Jarthianur Oct 15, 2019
4c934bc
more generic parse function
Jarthianur Oct 18, 2019
6319450
optimize aprs parsing
Jarthianur Oct 18, 2019
f039be5
Merge pull request #58 from Jarthianur/dev_4.0.0_optimize-parsing
Jarthianur Oct 18, 2019
10df4cf
split nmea strings and objects to reduce copies
Jarthianur Nov 3, 2019
ae1e47f
fix wrong include
Jarthianur Nov 3, 2019
324a170
sort feed subscriptions for client by priority
Jarthianur Nov 3, 2019
6f998cd
Merge pull request #60 from Jarthianur/dev_4.0.0_optimize-data
Jarthianur Nov 4, 2019
63abded
impl a backoff timeout
Jarthianur Nov 4, 2019
27eca42
Merge pull request #62 from Jarthianur/dev_4.0.0_connect-backoff
Jarthianur Nov 4, 2019
a7ce6e1
change server and config to allow dynamic count of connections
Jarthianur Nov 4, 2019
1324cb5
remove params, improve configuration
Jarthianur Nov 4, 2019
f5d3bdb
Merge pull request #63 from Jarthianur/dev_4.0.0_dyn-max-connection-s…
Jarthianur Nov 4, 2019
8472334
merge master
Jarthianur Nov 4, 2019
d0aa462
format
Jarthianur Nov 4, 2019
a861a00
add and impl mutex wrapper for clang analysis, parsers not static any…
Jarthianur Nov 5, 2019
c7f57ac
apply annotations for clangs thread safety analysis (altough its pret…
Jarthianur Nov 7, 2019
5971971
use alias lock types
Jarthianur Nov 7, 2019
6430f5a
Merge pull request #64 from Jarthianur/dev_4.0.0_threadsafety-analysis
Jarthianur Nov 7, 2019
b64638a
fix include
Jarthianur Nov 7, 2019
6aa2041
Merge branch 'master' into dev_4.0.0_code-guidelines
Jarthianur Nov 7, 2019
239d646
change to new code style
Jarthianur Nov 8, 2019
d0ee828
adjust new code style
Jarthianur Nov 8, 2019
91b964c
apply new code style
Jarthianur Nov 8, 2019
acc335f
apply new codestyle to headers
Jarthianur Nov 9, 2019
474fa76
start applying codestyle to sources, refactor files, documenting
Jarthianur Nov 9, 2019
d1a03b0
more docs, logger prefix as constexpr
Jarthianur Nov 10, 2019
f00b777
apply new code style
Jarthianur Nov 10, 2019
c263457
code doc
Jarthianur Nov 10, 2019
728de5a
apply code style
Jarthianur Nov 10, 2019
b661866
apply code style
Jarthianur Nov 11, 2019
0c82636
fix code
Jarthianur Nov 11, 2019
ed2bfe3
move inner clase declaration
Jarthianur Nov 12, 2019
a9da9e4
change warnings
Jarthianur Nov 16, 2019
266d2dd
Merge pull request #65 from Jarthianur/dev_4.0.0_code-guidelines
Jarthianur Jan 18, 2020
c774565
change sctf
Jarthianur Jan 18, 2020
0c780aa
add tests
Jarthianur Jan 18, 2020
382dbfb
fix wind and atmos interface
Jarthianur Jan 19, 2020
f3e0622
more tests
Jarthianur Jan 19, 2020
9da096e
gpspos tests
Jarthianur Jan 20, 2020
cf2eb0f
change aircraft update logic and add tests
Jarthianur Jan 20, 2020
7cb5b79
adjust tests
Jarthianur Jan 21, 2020
269bb35
config tests
Jarthianur Jan 21, 2020
c8c127e
use makestr function
Jarthianur Jan 21, 2020
c99a057
impl server tests
Jarthianur Jan 22, 2020
868318f
use makestr
Jarthianur Jan 23, 2020
ceaefc7
apply naming schema and tidy fixes
Jarthianur Apr 3, 2020
b21cc9f
refactor and apply tidy fixes
Jarthianur Apr 3, 2020
f0b80ce
refactoring headers and apply tidy fixes
Jarthianur Apr 4, 2020
9964c36
refactoring and tidy fixes
Jarthianur Apr 4, 2020
b74d599
refactor and apply tidy fixes
Jarthianur Apr 4, 2020
2a45d7f
update copyright
Jarthianur Apr 16, 2020
caf118f
fix build and refactor class utils
Jarthianur Apr 26, 2020
c497c55
Merge pull request #66 from Jarthianur/dev_4.0.0_refactoring
Jarthianur Apr 26, 2020
166d00d
add test and rename some files
Jarthianur Apr 30, 2020
13d5ea1
adjust tests, and update sctf
Jarthianur May 2, 2020
1ac9833
adjust tests
Jarthianur May 3, 2020
39595ba
thread wait instead of throwing error
Jarthianur May 3, 2020
d8331ea
adjust tests
Jarthianur May 3, 2020
f901808
update sctf
Jarthianur Jun 4, 2020
4935d68
apply tidy fixes
Jarthianur Jun 11, 2020
bd66a03
apply tidy fixes
Jarthianur Jun 11, 2020
423cae5
apply tidy fixes
Jarthianur Jun 12, 2020
7ee2870
fix string utils and tests
Jarthianur Jun 12, 2020
5f1e14e
fix server test and mocks
Jarthianur Jun 15, 2020
5ca9098
fix static string implementation and tests
Jarthianur Jun 15, 2020
7723ed9
adjust object tests
Jarthianur Jun 17, 2020
6a945bc
adjust some tests
Jarthianur Jun 17, 2020
1ee741f
format code, no default target in aircraft ctor
Jarthianur Aug 29, 2020
2e24953
impl test, minor code adjustments
Jarthianur Sep 18, 2020
b3da5e6
create targets for each test component
Jarthianur Sep 19, 2020
a8060e5
refactor impl
Jarthianur Sep 19, 2020
be408dd
fix some tests
Jarthianur Sep 19, 2020
456565d
use threadsafe spirit
Jarthianur Dec 30, 2020
dbd02b6
using for limits
Jarthianur Dec 30, 2020
652b3ba
update sctf to tpp
Jarthianur Dec 30, 2020
2fbc2ef
using for limits
Jarthianur Dec 30, 2020
e97a4c1
fix profiler compile
Jarthianur Feb 1, 2021
22ce087
update tpp ro 3.0-rc1
Jarthianur Feb 1, 2021
39cf11a
fixed config tests
Jarthianur Feb 15, 2021
cc9e692
fixed data tests
Jarthianur Feb 15, 2021
77c4810
Merge pull request #70 from Jarthianur/dev_4.0.0_testing
Jarthianur Feb 15, 2021
29cd035
beginning cleanup
Jarthianur Feb 16, 2021
5e5f617
use libfmt from git
Jarthianur Feb 16, 2021
b4fe159
move tpp into submodule and integrate via cmake
Jarthianur Feb 16, 2021
563ec46
Merge pull request #71 from Jarthianur/dev_4.0.0_use-libfmt
Jarthianur Feb 16, 2021
bba9dcb
Merge branch 'dev_4.0.0' into dev_4.0.0_cleanup-build
Jarthianur Feb 16, 2021
834dbf6
drop all systems but debian, change alpine docker to debian, some cle…
Jarthianur Feb 17, 2021
14a3d2b
aplit wget install
Jarthianur Feb 17, 2021
16dfc52
change order for repo
Jarthianur Feb 17, 2021
91eb1c7
install gnupg
Jarthianur Feb 17, 2021
108838c
fix docker build and format
Jarthianur Feb 17, 2021
6462e32
no xtrace
Jarthianur Feb 17, 2021
63f0eea
move ini to conf naming
Jarthianur Feb 18, 2021
bed50e0
fix boost exception, increase min connections
Jarthianur Feb 21, 2021
9fdc1af
change nmea string colletion method. Run clients causes segfault, Pos…
Jarthianur Feb 21, 2021
619dfa9
fix client segfault
Jarthianur Feb 24, 2021
8b5cebc
rename s to i types, generalize result type, moves in client read
Jarthianur Feb 24, 2021
0905889
fix server segfault
Jarthianur Feb 24, 2021
a76664b
fix compile
Jarthianur Feb 24, 2021
ac5a378
dismis regression tests, as they are not properly working nayway
Jarthianur Feb 24, 2021
7d03580
fix lcov missing
Jarthianur Feb 24, 2021
06788ca
remove regression make
Jarthianur Feb 25, 2021
a4ea7f2
Merge pull request #72 from Jarthianur/dev_4.0.0_cleanup-build
Jarthianur Feb 25, 2021
a2c5cc4
rename to asio
Jarthianur Feb 25, 2021
00887db
clean submods
Jarthianur Feb 25, 2021
9571e75
bundle whole boost
Jarthianur Feb 25, 2021
2bdebc8
impl program options
Jarthianur Feb 26, 2021
c36319a
Merge pull request #73 from Jarthianur/dev_4.0.0_bundle-dependencies
Jarthianur Feb 26, 2021
d1a84f9
add progopts tests
Jarthianur Feb 27, 2021
8a8735e
refactor types, temporarily remove comments
Jarthianur Feb 27, 2021
197ea6e
refactor locks
Jarthianur Mar 21, 2021
0ade0d3
refactor locks
Jarthianur Mar 21, 2021
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
!/include/
!/profiling/
!/docs/
!/vendor/
!/vendor/**
!.github/**
!/docs/_includes/**
!/docs/assets/**
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "vendor/fmt"]
path = vendor/fmt
url = https://github.com/fmtlib/fmt.git
[submodule "vendor/TestPlusPlus"]
path = vendor/TestPlusPlus
url = https://github.com/Jarthianur/TestPlusPlus.git
50 changes: 35 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS OFF)

file(GLOB_RECURSE vfrb_sources src/*.cpp)
file(GLOB vfrb_test_sources test/*.cpp)
Expand All @@ -39,7 +39,6 @@ list(REMOVE_ITEM vfrb_sources_for_test ${PROJECT_SOURCE_DIR}/src/object/impl/CDa
list(REMOVE_ITEM vfrb_sources_for_test ${PROJECT_SOURCE_DIR}/src/server/net/impl/CAcceptorBoost.cpp)
list(REMOVE_ITEM vfrb_sources_for_test ${PROJECT_SOURCE_DIR}/src/server/net/impl/CSocketBoost.cpp)


set(CMAKE_BUILD_TYPE staged)
set(CMAKE_CXX_FLAGS_STAGED "-Wall -Wextra -Wpedantic -Wnon-virtual-dtor -Werror -Wno-error=attributes -Wno-error=unused-result -DBOOST_SPIRIT_THREADSAFE")

Expand All @@ -52,11 +51,15 @@ if(DEFINED BOOST_STATIC)
set(Boost_USE_STATIC_LIBS ON)
endif()

set(VFRB_LINK_LIBS Boost::system Boost::program_options Threads::Threads)
set(VFRB_LINK_LIBS Boost::system Boost::program_options Threads::Threads fmt::fmt-header-only)
set(VFRB_TEST_LINK_LIBS gcov gomp tpp)

#
# dependencies
#
add_subdirectory(vendor/fmt EXCLUDE_FROM_ALL)
add_subdirectory(vendor/TestPlusPlus EXCLUDE_FROM_ALL)

find_package(Boost REQUIRED COMPONENTS system program_options)
find_package(Threads REQUIRED)

Expand Down Expand Up @@ -85,65 +88,65 @@ add_executable(unittest ${vfrb_test_sources} ${vfrb_sources_for_test})
target_compile_options(unittest PUBLIC -O0 -g --coverage -fopenmp -DLOG_ENABLE_DEBUG)
set_target_properties(unittest PROPERTIES OUTPUT_NAME ${vfrb_test_bin})
target_include_directories(unittest PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include)
target_link_libraries(unittest PUBLIC ${VFRB_LINK_LIBS} gcov gomp)
target_link_libraries(unittest PUBLIC ${VFRB_LINK_LIBS} ${VFRB_TEST_LINK_LIBS})

#
# targets for single tests
#
add_executable(util.test ${PROJECT_SOURCE_DIR}/test/UnitTests.cpp ${PROJECT_SOURCE_DIR}/test/TestUtil.cpp ${vfrb_sources_for_test})
target_compile_options(util.test PUBLIC -O0 -g -fopenmp -DLOG_ENABLE_DEBUG)
target_include_directories(util.test PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include)
target_link_libraries(util.test PUBLIC ${VFRB_LINK_LIBS} gcov gomp)
target_link_libraries(util.test PUBLIC ${VFRB_LINK_LIBS} ${VFRB_TEST_LINK_LIBS})

add_executable(string.test ${PROJECT_SOURCE_DIR}/test/UnitTests.cpp ${PROJECT_SOURCE_DIR}/test/TestString.cpp ${vfrb_sources_for_test})
target_compile_options(string.test PUBLIC -O0 -g -fopenmp -DLOG_ENABLE_DEBUG)
target_include_directories(string.test PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include)
target_link_libraries(string.test PUBLIC ${VFRB_LINK_LIBS} gcov gomp)
target_link_libraries(string.test PUBLIC ${VFRB_LINK_LIBS} ${VFRB_TEST_LINK_LIBS})

add_executable(server.test ${PROJECT_SOURCE_DIR}/test/UnitTests.cpp ${PROJECT_SOURCE_DIR}/test/TestServer.cpp ${vfrb_sources_for_test})
target_compile_options(server.test PUBLIC -O0 -g -fopenmp -DLOG_ENABLE_DEBUG)
target_include_directories(server.test PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include)
target_link_libraries(server.test PUBLIC ${VFRB_LINK_LIBS} gcov gomp)
target_link_libraries(server.test PUBLIC ${VFRB_LINK_LIBS} ${VFRB_TEST_LINK_LIBS})

add_executable(object.test ${PROJECT_SOURCE_DIR}/test/UnitTests.cpp ${PROJECT_SOURCE_DIR}/test/TestObject.cpp ${vfrb_sources_for_test})
target_compile_options(object.test PUBLIC -O0 -g -fopenmp -DLOG_ENABLE_DEBUG)
target_include_directories(object.test PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include)
target_link_libraries(object.test PUBLIC ${VFRB_LINK_LIBS} gcov gomp)
target_link_libraries(object.test PUBLIC ${VFRB_LINK_LIBS} ${VFRB_TEST_LINK_LIBS})

add_executable(math.test ${PROJECT_SOURCE_DIR}/test/UnitTests.cpp ${PROJECT_SOURCE_DIR}/test/TestMath.cpp ${vfrb_sources_for_test})
target_compile_options(math.test PUBLIC -O0 -g -fopenmp -DLOG_ENABLE_DEBUG)
target_include_directories(math.test PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include)
target_link_libraries(math.test PUBLIC ${VFRB_LINK_LIBS} gcov gomp)
target_link_libraries(math.test PUBLIC ${VFRB_LINK_LIBS} ${VFRB_TEST_LINK_LIBS})

add_executable(parser.test ${PROJECT_SOURCE_DIR}/test/UnitTests.cpp ${PROJECT_SOURCE_DIR}/test/TestFeedParser.cpp ${vfrb_sources_for_test})
target_compile_options(parser.test PUBLIC -O0 -g -fopenmp -DLOG_ENABLE_DEBUG)
target_include_directories(parser.test PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include)
target_link_libraries(parser.test PUBLIC ${VFRB_LINK_LIBS} gcov gomp)
target_link_libraries(parser.test PUBLIC ${VFRB_LINK_LIBS} ${VFRB_TEST_LINK_LIBS})

add_executable(feed.test ${PROJECT_SOURCE_DIR}/test/UnitTests.cpp ${PROJECT_SOURCE_DIR}/test/TestFeed.cpp ${vfrb_sources_for_test})
target_compile_options(feed.test PUBLIC -O0 -g -fopenmp -DLOG_ENABLE_DEBUG)
target_include_directories(feed.test PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include)
target_link_libraries(feed.test PUBLIC ${VFRB_LINK_LIBS} gcov gomp)
target_link_libraries(feed.test PUBLIC ${VFRB_LINK_LIBS} ${VFRB_TEST_LINK_LIBS})

add_executable(processor.test ${PROJECT_SOURCE_DIR}/test/UnitTests.cpp ${PROJECT_SOURCE_DIR}/test/TestDataProcessor.cpp ${vfrb_sources_for_test})
target_compile_options(processor.test PUBLIC -O0 -g -fopenmp -DLOG_ENABLE_DEBUG)
target_include_directories(processor.test PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include)
target_link_libraries(processor.test PUBLIC ${VFRB_LINK_LIBS} gcov gomp)
target_link_libraries(processor.test PUBLIC ${VFRB_LINK_LIBS} ${VFRB_TEST_LINK_LIBS})

add_executable(data.test ${PROJECT_SOURCE_DIR}/test/UnitTests.cpp ${PROJECT_SOURCE_DIR}/test/TestData.cpp ${vfrb_sources_for_test})
target_compile_options(data.test PUBLIC -O0 -g -fopenmp -DLOG_ENABLE_DEBUG)
target_include_directories(data.test PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include)
target_link_libraries(data.test PUBLIC ${VFRB_LINK_LIBS} gcov gomp)
target_link_libraries(data.test PUBLIC ${VFRB_LINK_LIBS} ${VFRB_TEST_LINK_LIBS})

add_executable(config.test ${PROJECT_SOURCE_DIR}/test/UnitTests.cpp ${PROJECT_SOURCE_DIR}/test/TestConfig.cpp ${vfrb_sources_for_test})
target_compile_options(config.test PUBLIC -O0 -g -fopenmp -DLOG_ENABLE_DEBUG)
target_include_directories(config.test PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include)
target_link_libraries(config.test PUBLIC ${VFRB_LINK_LIBS} gcov gomp)
target_link_libraries(config.test PUBLIC ${VFRB_LINK_LIBS} ${VFRB_TEST_LINK_LIBS})

add_executable(client.test ${PROJECT_SOURCE_DIR}/test/UnitTests.cpp ${PROJECT_SOURCE_DIR}/test/TestClient.cpp ${vfrb_sources_for_test})
target_compile_options(client.test PUBLIC -O0 -g -fopenmp -DLOG_ENABLE_DEBUG)
target_include_directories(client.test PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include)
target_link_libraries(client.test PUBLIC ${VFRB_LINK_LIBS} gcov gomp)
target_link_libraries(client.test PUBLIC ${VFRB_LINK_LIBS} ${VFRB_TEST_LINK_LIBS})

#
# target: profiling
Expand All @@ -162,3 +165,20 @@ install(CODE "file(READ ${PROJECT_SOURCE_DIR}/vfrb.service.in service_file_data)
string(REPLACE \"%VFRB_EXEC_PATH%\" \"${PROJECT_BINARY_DIR}/${vfrb_release_bin}\" service_file_data \"\${service_file_data}\")\n
string(REPLACE \"%VFRB_INI_PATH%\" \"${PROJECT_BINARY_DIR}/$ENV{VFRB_INI}\" service_file_data \"\${service_file_data}\")\n
file(WRITE /etc/systemd/system/vfrb.service \"\${service_file_data}\")")

#
# compiledb dummy target
#
add_executable(compiledb_dummy EXCLUDE_FROM_ALL ${vfrb_test_sources} ${vfrb_sources_for_test})
target_compile_options(compiledb_dummy PUBLIC -O0 -g -fopenmp -DLOG_ENABLE_DEBUG)
target_include_directories(compiledb_dummy PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/test/include)
target_link_libraries(compiledb_dummy PUBLIC ${VFRB_LINK_LIBS} gomp tpp)

if("${GENERATE_COMPILEDB}")
if(NOT "${COMPILEDB_TARGET}")
set(COMPILEDB_TARGET compiledb_dummy)
endif()
message(STATUS "compiledb --command-style -n make -C ${CMAKE_BINARY_DIR} ${COMPILEDB_TARGET}")
execute_process(COMMAND pwd)
execute_process(COMMAND compiledb --command-style -n make -C ${CMAKE_BINARY_DIR} ${COMPILEDB_TARGET})
endif()
17 changes: 10 additions & 7 deletions include/CStaticString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include <algorithm>
#include <array>
#include <cstdio>
#include <fmt/chrono.h>
#include <fmt/core.h>
#include <fmt/format.h>
#include <utility>

#include "error/IError.hpp"
Expand Down Expand Up @@ -167,20 +170,20 @@ class CStaticString final
*/
template<typename... Args>
auto
Format(usize pos_, str fmt_, Args... args_) -> s32 {
Format(usize pos_, str fmt_, Args&&... args_) -> usize {
if (pos_ >= N) {
throw error::COverflowError();
}
usize max = N - pos_;
s32 b = 0;
if ((b = std::snprintf(m_data.data() + pos_, max, fmt_, std::forward<Args>(args_)...)) >= 0 &&
static_cast<usize>(b) < max) {
m_view = StringView{m_data.data(), pos_ + b}; // like append
usize max = N - pos_;
auto start = m_data.data() + pos_;
if (auto [end, s] = fmt::format_to_n(start, max, fmt_, std::forward<Args>(args_)...);
start != end && s < max) {
m_view = StringView{m_data.data(), pos_ + s}; // like append
return s;
} else {
Clear();
throw error::COverflowError();
}
return b;
}

/// Get the length of seen characters.
Expand Down
23 changes: 12 additions & 11 deletions src/data/processor/CAircraftProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,20 @@ CAircraftProcessor::calculateRelPosition(CAircraft const& aircraft_) const {
auto
CAircraftProcessor::appendPflau(CAircraft const& aircraft_, CStaticString<NMEA_SIZE>* nmea_, usize idx_) const
-> usize {
int next = nmea_->Format(idx_, "$PFLAU,,,,1,0,%d,0,%d,%d,%s*", math::DoubleToInt(m_relBearing),
m_relVertical, m_distance, (*aircraft_.Id()).data());
next += nmea_->Format(idx_ + next, "%02x\r\n", Checksum(**nmea_, idx_));
return idx_ + static_cast<usize>(next);
usize next = nmea_->Format(idx_, "$PFLAU,,,,1,0,{:d},0,{:d},{:d},{:s}*", math::DoubleToInt(m_relBearing),
m_relVertical, m_distance, *aircraft_.Id());
next += nmea_->Format(idx_ + next, "{:02X}\r\n", Checksum(**nmea_, idx_));
return idx_ + next;
}

auto
CAircraftProcessor::appendPflaa(CAircraft const& aircraft_, CStaticString<NMEA_SIZE>* nmea_, usize idx_) const
-> usize {
int next = 0;
usize next = 0;
if (aircraft_.HasFullInfo()) {
next = nmea_->Format(
idx_, "$PFLAA,0,%d,%d,%d,%hhu,%s,%.3d,,%d,%3.1lf,%.1hhX*", m_relNorth, m_relEast, m_relVertical,
util::AsUnderlyingType(aircraft_.IdType()), (*aircraft_.Id()).data(),
idx_, "$PFLAA,0,{:d},{:d},{:d},{:d},{:s},{:03d},,{:d},{:3.1f},{:1X}*", m_relNorth, m_relEast,
m_relVertical, util::AsUnderlyingType(aircraft_.IdType()), *aircraft_.Id(),
math::DoubleToInt(math::Saturate(aircraft_.Movement().Heading, CAircraft::SMovement::MIN_HEADING,
CAircraft::SMovement::MAX_HEADING)),
math::DoubleToInt(math::Saturate(aircraft_.Movement().GndSpeed * math::MS_2_KMH,
Expand All @@ -110,10 +110,11 @@ CAircraftProcessor::appendPflaa(CAircraft const& aircraft_, CStaticString<NMEA_S
CAircraft::SMovement::MAX_CLIMB_RATE),
util::AsUnderlyingType(aircraft_.AircraftType()));
} else {
next = nmea_->Format(idx_, "$PFLAA,0,%d,%d,%d,1,%s,,,,,%1hhX*", m_relNorth, m_relEast, m_relVertical,
(*aircraft_.Id()).data(), util::AsUnderlyingType(aircraft_.AircraftType()));
next =
nmea_->Format(idx_, "$PFLAA,0,{:d},{:d},{:d},1,{:s},,,,,{:1X}*", m_relNorth, m_relEast,
m_relVertical, *aircraft_.Id(), util::AsUnderlyingType(aircraft_.AircraftType()));
}
next += nmea_->Format(idx_ + next, "%02x\r\n", Checksum(**nmea_, idx_));
return idx_ + static_cast<usize>(next);
next += nmea_->Format(idx_ + next, "{:02X}\r\n", Checksum(**nmea_, idx_));
return idx_ + next;
}
} // namespace vfrb::data::processor
28 changes: 12 additions & 16 deletions src/data/processor/CGpsProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,23 @@ CGpsProcessor::Process(object::CGpsPosition const& pos_, CStaticString<NMEA_SIZE
auto
CGpsProcessor::appendGpgga(CGpsPosition const& pos_, CStaticString<NMEA_SIZE>* nmea_, std::tm const* utc_,
usize idx_) const -> usize {
// As we use XCSoar as frontend, we need to set the fix quality to 1. It doesn't
// support others.
// "$GPGGA,%02d%02d%02d,%02.0lf%07.4lf,%c,%03.0lf%07.4lf,%c,%1d,%02d,1,%d,M,%.1lf,M,,*"
int next = nmea_->Format(
idx_, "$GPGGA,%.2d%.2d%.2d,%02.0lf%07.4lf,%c,%03.0lf%07.4lf,%c,1,%.2hhu,1,%d,M,%.1lf,M,,*",
utc_->tm_hour, utc_->tm_min, utc_->tm_sec, m_degLatitude, m_minLatitude, m_directionSN,
m_degLongitude, m_minLongitude, m_directionEW, /*pos.fixQa,*/ pos_.NrOfSatellites(),
pos_.Location().Altitude,
// XCSoar requires a fix quality of 1
usize next = nmea_->Format(
idx_, "$GPGGA,{:%H%M%S},{:02.0f}{:07.4f},{:c},{:03.0f}{:07.4f},{:c},1,{:2d},1,{:d},M,{:.1f},M,,*",
*utc_, m_degLatitude, m_minLatitude, m_directionSN, m_degLongitude, m_minLongitude, m_directionEW,
pos_.NrOfSatellites(), pos_.Location().Altitude,
math::Saturate(pos_.Geoid(), CGpsPosition::MIN_GEOID, CGpsPosition::MAX_GEOID));
next += nmea_->Format(idx_ + next, "%02x\r\n", Checksum(**nmea_, idx_));
return idx_ + static_cast<usize>(next);
next += nmea_->Format(idx_ + next, "{:02X}\r\n", Checksum(**nmea_, idx_));
return idx_ + next;
}

auto
CGpsProcessor::appendGprmc(CStaticString<NMEA_SIZE>* nmea_, std::tm const* utc_, usize idx_) const -> usize {
int next = nmea_->Format(
idx_, "$GPRMC,%.2d%.2d%.2d,A,%02.0lf%06.3lf,%c,%03.0lf%06.3lf,%c,0,0,%.2d%.2d%.2d,001.0,W*",
utc_->tm_hour, utc_->tm_min, utc_->tm_sec, m_degLatitude, m_minLatitude, m_directionSN,
m_degLongitude, m_minLongitude, m_directionEW, utc_->tm_mday, utc_->tm_mon + 1, utc_->tm_year - 100);
next += nmea_->Format(idx_ + next, "%02x\r\n", Checksum(**nmea_, idx_));
return idx_ + static_cast<usize>(next);
usize next = nmea_->Format(
idx_, "$GPRMC,{0:%H%M%S},A,{1:02.0f}{2:06.3f},{3:c},{4:03.0f}{5:06.3f},{6:c},0,0,{0:%d%m%y},001.0,W*",
*utc_, m_degLatitude, m_minLatitude, m_directionSN, m_degLongitude, m_minLongitude, m_directionEW);
next += nmea_->Format(idx_ + next, "{:02X}\r\n", Checksum(**nmea_, idx_));
return idx_ + next;
}

void
Expand Down
1 change: 1 addition & 0 deletions test/TestDataProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ DESCRIBE("test_CGpsProcessor") {
IT("should process GPS data correctly") {
CGpsPosition pos(0, {0., 0., 0}, 48.);
uut.Process(pos, &cstr);
SYSO(*cstr);
ASSERT((*cstr).data(), LIKE, helper::GpsRE);
};
};
Expand Down
10 changes: 5 additions & 5 deletions test/TestString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ DESCRIBE_PAR("test_CStatisString") {
}
IT("should correctly format string") {
CStaticString<8> a;
ASSERT_NOTHROW(a.Format(0, "%s", "a"));
ASSERT_NOTHROW(a.Format(0, "{}", "a"));
ASSERT_EQ(*a, StringView{"a"});
ASSERT_EQ(a.Length(), 1U);
ASSERT_NOTHROW(a.Format(0, "%d", 1234));
ASSERT_NOTHROW(a.Format(0, "{}", 1234));
ASSERT_EQ(*a, StringView{"1234"});
ASSERT_EQ(a.Length(), 4U);
}
IT("should throw if format overflows") {
CStaticString<4> a;
ASSERT_THROWS(a.Format(0, "%s", "abcdefg"), error::COverflowError);
ASSERT_THROWS(a.Format(0, "%s", "abcd"), error::COverflowError);
ASSERT_THROWS(a.Format(2, "%s", "aaa"), error::COverflowError);
ASSERT_THROWS(a.Format(0, "{}", "abcdefg"), error::COverflowError);
ASSERT_THROWS(a.Format(0, "{}", "abcd"), error::COverflowError);
ASSERT_THROWS(a.Format(2, "{}", "aaa"), error::COverflowError);
};
};
3 changes: 1 addition & 2 deletions test/include/Helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
#include <cstdint>
#include <iostream>
#include <string>
#include <tpp.hpp>

#include <boost/date_time/posix_time/posix_time.hpp>

#include "object/CAircraft.hpp"
#include "util/Utility.hpp"

#include "tpp.hpp"

#define SYSO(M) std::cout << M << std::flush

using tpp::operator""_re;
Expand Down
Loading