Skip to content

Commit c5cd720

Browse files
Merge pull request #6 from MuonPi/release-v1.0.0
Release v1.0.0
2 parents 269f448 + c0671e4 commit c5cd720

File tree

103 files changed

+5102
-4462
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+5102
-4462
lines changed

CMakeLists.txt

Lines changed: 50 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -1,215 +1,80 @@
11
cmake_minimum_required(VERSION 3.10)
2-
project(muondetector-cluster LANGUAGES CXX C)
2+
project(detector-network-processor LANGUAGES CXX C)
33

44
string(TIMESTAMP PROJECT_DATE_STRING "%b %d, %Y")
55

6-
option(CLUSTER_BUILD_TIDY "run clang-tidy when building the project" OFF)
7-
option(CLUSTER_FORMAT "run clang-format when building the project" ON)
6+
option(PROCESSOR_DISABLE_SSL "build the code so the rest service doesn't use SSL"
7+
OFF)
8+
option(PROCESSOR_BUILD_AGGREGATION "along with the default application, also build the aggregation executable."
9+
OFF)
810

911
set(PROJECT_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
1012
set(PROJECT_HEADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
1113
set(PROJECT_CONFIG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/config")
1214

13-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../bin")
15+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output/bin")
1416
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.cmake")
1517

16-
17-
if(${CLUSTER_BUILD_TIDY})
18-
set(CMAKE_CXX_CLANG_TIDY
19-
clang-tidy;
20-
-header-filter=^global;
21-
-checks=-*,bugprone-*,performace-*,readability-*,-readability-magic-numbers,modernize-*,hicpp-*,clang-analyzer-*;
22-
-fix;
23-
)
24-
endif(${CLUSTER_BUILD_TIDY})
18+
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/files.cmake")
2519

2620
set(CMAKE_CXX_STANDARD 17)
2721
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2822

23+
add_compile_options(-Wall -Wextra -Wshadow -Wpedantic -Werror -O3)
2924

30-
add_compile_options(
31-
-Wall
32-
-Wextra
33-
-Wshadow
34-
-Wpedantic
35-
-Werror
36-
-O3
37-
)
38-
25+
if(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
26+
add_compile_options(-fsanitize=address,undefined)
27+
add_link_options(-fsanitize=address,undefined)
28+
endif()
3929

4030

4131
find_library(MOSQUITTO mosquitto REQUIRED)
42-
find_library(CRYPTOPP crypto++ REQUIRED)
43-
find_library(CURL curl REQUIRED)
4432
find_library(SASL2 sasl2 REQUIRED)
4533
find_library(LDAP ldap REQUIRED)
46-
find_library(RESTBED restbed REQUIRED)
47-
48-
find_library(STD_CPP_FS stdc++fs /usr/lib/gcc/x86_64-linux-gnu/8/)
49-
34+
find_library(DL dl REQUIRED)
5035

36+
find_package(
37+
Boost 1.71
38+
COMPONENTS system program_options
39+
REQUIRED)
5140

52-
53-
set(CLUSTER_SOURCE_FILES
54-
"${PROJECT_SRC_DIR}/coincidencefilter.cpp"
55-
"${PROJECT_SRC_DIR}/detectortracker.cpp"
56-
"${PROJECT_SRC_DIR}/detector.cpp"
57-
"${PROJECT_SRC_DIR}/triggerhandler.cpp"
58-
59-
"${PROJECT_SRC_DIR}/link/mqtt.cpp"
60-
"${PROJECT_SRC_DIR}/link/database.cpp"
61-
62-
"${PROJECT_SRC_DIR}/messages/event.cpp"
63-
"${PROJECT_SRC_DIR}/messages/detectorlog.cpp"
64-
"${PROJECT_SRC_DIR}/messages/detectorinfo.cpp"
65-
"${PROJECT_SRC_DIR}/messages/detectorsummary.cpp"
66-
"${PROJECT_SRC_DIR}/messages/clusterlog.cpp"
67-
68-
"${PROJECT_SRC_DIR}/utility/coincidence.cpp"
69-
"${PROJECT_SRC_DIR}/utility/eventconstructor.cpp"
70-
"${PROJECT_SRC_DIR}/utility/threadrunner.cpp"
71-
"${PROJECT_SRC_DIR}/utility/log.cpp"
72-
"${PROJECT_SRC_DIR}/utility/utility.cpp"
73-
"${PROJECT_SRC_DIR}/utility/geohash.cpp"
74-
"${PROJECT_SRC_DIR}/utility/parameters.cpp"
75-
"${PROJECT_SRC_DIR}/utility/configuration.cpp"
76-
"${PROJECT_SRC_DIR}/utility/resourcetracker.cpp"
77-
78-
"${PROJECT_SRC_DIR}/supervision/state.cpp"
79-
"${PROJECT_SRC_DIR}/supervision/timebase.cpp"
80-
)
81-
82-
set(CLUSTER_HEADER_FILES
83-
"${PROJECT_HEADER_DIR}/coincidencefilter.h"
84-
"${PROJECT_HEADER_DIR}/detectortracker.h"
85-
"${PROJECT_HEADER_DIR}/detector.h"
86-
"${PROJECT_HEADER_DIR}/triggerhandler.h"
87-
"${PROJECT_HEADER_DIR}/pipeline.h"
88-
89-
"${PROJECT_HEADER_DIR}/link/database.h"
90-
"${PROJECT_HEADER_DIR}/link/mqtt.h"
91-
92-
"${PROJECT_HEADER_DIR}/sink/base.h"
93-
"${PROJECT_HEADER_DIR}/sink/database.h"
94-
"${PROJECT_HEADER_DIR}/sink/mqtt.h"
95-
"${PROJECT_HEADER_DIR}/sink/ascii.h"
96-
97-
"${PROJECT_HEADER_DIR}/source/base.h"
98-
"${PROJECT_HEADER_DIR}/source/mqtt.h"
99-
100-
"${PROJECT_HEADER_DIR}/messages/event.h"
101-
"${PROJECT_HEADER_DIR}/messages/detectorlog.h"
102-
"${PROJECT_HEADER_DIR}/messages/detectorinfo.h"
103-
"${PROJECT_HEADER_DIR}/messages/detectorsummary.h"
104-
"${PROJECT_HEADER_DIR}/messages/clusterlog.h"
105-
"${PROJECT_HEADER_DIR}/messages/userinfo.h"
106-
"${PROJECT_HEADER_DIR}/messages/trigger.h"
107-
108-
"${PROJECT_HEADER_DIR}/utility/threadrunner.h"
109-
"${PROJECT_HEADER_DIR}/utility/coincidence.h"
110-
"${PROJECT_HEADER_DIR}/utility/criterion.h"
111-
"${PROJECT_HEADER_DIR}/utility/log.h"
112-
"${PROJECT_HEADER_DIR}/utility/utility.h"
113-
"${PROJECT_HEADER_DIR}/utility/geohash.h"
114-
"${PROJECT_HEADER_DIR}/utility/eventconstructor.h"
115-
"${PROJECT_HEADER_DIR}/utility/parameters.h"
116-
"${PROJECT_HEADER_DIR}/utility/configuration.h"
117-
"${PROJECT_HEADER_DIR}/utility/resourcetracker.h"
118-
119-
"${PROJECT_HEADER_DIR}/supervision/state.h"
120-
"${PROJECT_HEADER_DIR}/supervision/timebase.h"
121-
)
122-
123-
configure_file(
124-
"${PROJECT_CONFIG_DIR}/muondetector-cluster.1"
125-
"${CMAKE_CURRENT_BINARY_DIR}/muondetector-cluster.1"
126-
)
127-
128-
configure_file(
129-
"${PROJECT_CONFIG_DIR}/config.h"
130-
"${CMAKE_CURRENT_BINARY_DIR}/defaults.h"
131-
)
132-
133-
add_library(source-files OBJECT ${CLUSTER_SOURCE_FILES} ${CLUSTER_HEADER_FILES})
134-
target_include_directories(source-files PUBLIC
135-
${PROJECT_HEADER_DIR}
136-
${CMAKE_CURRENT_BINARY_DIR}
137-
)
138-
139-
add_executable(muondetector-cluster "${PROJECT_SRC_DIR}/main.cpp")
140-
141-
if (CMAKE_BUILD_TYPE STREQUAL Release)
142-
add_custom_command(TARGET muondetector-cluster POST_BUILD
143-
COMMAND ${CMAKE_STRIP} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/muondetector-cluster")
144-
endif ()
145-
target_include_directories(muondetector-cluster PUBLIC
146-
${PROJECT_HEADER_DIR}
147-
${CMAKE_CURRENT_BINARY_DIR}
148-
)
149-
150-
if (NOT STD_CPP_FS)
151-
target_link_libraries(muondetector-cluster
152-
crypto++
153-
mosquitto
154-
source-files
155-
pthread
156-
curl
157-
restbed
158-
sasl2
159-
ldap
160-
)
161-
else()
162-
target_link_libraries(muondetector-cluster
163-
crypto++
41+
set(PROJECT_INCLUDE_LIBS
16442
mosquitto
165-
source-files
16643
pthread
167-
curl
168-
restbed
16944
sasl2
17045
ldap
171-
stdc++fs
172-
)
46+
boost_system
47+
boost_program_options
48+
ssl
49+
crypto
50+
dl)
51+
52+
# +++ necessary for compatability with older compilers
53+
find_library(STD_CPP_FS stdc++fs /usr/lib/gcc/x86_64-linux-gnu/8/)
54+
55+
if(STD_CPP_FS)
56+
set(PROJECT_INCLUDE_LIBS ${PROJECT_INCLUDE_LIBS} stdc++fs)
57+
endif()
58+
# --- necessary for compatability with older compilers
59+
60+
configure_file("${PROJECT_CONFIG_DIR}/detector-network-processor.1"
61+
"${CMAKE_CURRENT_BINARY_DIR}/detector-network-processor.1")
62+
63+
configure_file("${PROJECT_CONFIG_DIR}/config.h"
64+
"${CMAKE_CURRENT_BINARY_DIR}/defaults.h")
65+
66+
if (PROCESSOR_BUILD_AGGREGATION)
67+
add_executable(aggregation "${PROJECT_SRC_DIR}/aggregation.cpp")
17368
endif()
17469

70+
add_executable(
71+
detector-network-processor ${PROJECT_SOURCE_FILES} ${PROJECT_HEADER_FILES})
72+
73+
target_include_directories(
74+
detector-network-processor PUBLIC ${PROJECT_HEADER_DIR} ${CMAKE_CURRENT_BINARY_DIR})
75+
76+
target_link_libraries(detector-network-processor ${PROJECT_INCLUDE_LIBS})
77+
78+
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/packaging.cmake")
17579

176-
include(GNUInstallDirs)
177-
178-
add_custom_target(changelog-cluster ALL COMMAND gzip -cn9 "${PROJECT_CONFIG_DIR}/changelog" > "${CMAKE_CURRENT_BINARY_DIR}/changelog.gz")
179-
add_custom_target(manpage-cluster ALL COMMAND gzip -cn9 "${CMAKE_CURRENT_BINARY_DIR}/muondetector-cluster.1" > "${CMAKE_CURRENT_BINARY_DIR}/muondetector-cluster.1.gz")
180-
181-
if(${CLUSTER_FORMAT})
182-
add_custom_target(clangformat ALL COMMAND clang-format -style=WebKit -i ${CLUSTER_SOURCE_FILES} ${CLUSTER_HEADER_FILES} "${PROJECT_SRC_DIR}/main.cpp")
183-
endif(${CLUSTER_FORMAT})
184-
185-
install(TARGETS muondetector-cluster DESTINATION bin COMPONENT cluster)
186-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/changelog.gz" DESTINATION "${CMAKE_INSTALL_DOCDIR}" COMPONENT cluster)
187-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/muondetector-cluster.1.gz" DESTINATION "share/man/man1/" COMPONENT cluster)
188-
install(FILES "${PROJECT_CONFIG_DIR}/copyright" DESTINATION "${CMAKE_INSTALL_DOCDIR}" COMPONENT cluster)
189-
install(FILES "${PROJECT_CONFIG_DIR}/muondetector-cluster.service" DESTINATION "/lib/systemd/system" COMPONENT cluster)
190-
install(FILES "${PROJECT_CONFIG_DIR}/muondetector-cluster.cfg" DESTINATION "/etc/muondetector/" COMPONENT cluster)
191-
install(FILES "${PROJECT_CONFIG_DIR}/muondetector-cluster-credentials" DESTINATION "share/muondetector/" COMPONENT cluster)
192-
193-
194-
195-
set(CPACK_GENERATOR "DEB")
196-
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
197-
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_CONFIG_DIR}/license")
198-
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_CONFIG_DIR}/postinst;${PROJECT_CONFIG_DIR}/conffiles")
199-
set(CPACK_PACKAGE_VENDOR "MuonPi.org")
200-
set(CPACK_DEBIAN_PACKAGE_SECTION "net")
201-
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/MuonPi/muondetector-cluster")
202-
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
203-
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
204-
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
205-
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
206-
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION " Daemon which calculates coincidences for incoming events
207-
It subscribes to a mqtt topic to collect the incoming event messages and keep
208-
trace of individual event sources.
209-
With these messages it calculates coincidences and depending on the context
210-
publishes them to another mqtt topic or writes them to a database.
211-
It is licensed under the GNU Lesser General Public License version 3 (LGPL v3).")
212-
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "MuonPi <developer@muonpi.org>")
213-
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../packages/")
214-
215-
include(CPack)
80+
add_custom_target(clangformat COMMAND clang-format -style=WebKit -i ${PROJECT_SOURCE_FILES} ${PROJECT_HEADER_FILES} "${PROJECT_SRC_DIR}/aggregation.cpp")

README.md

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,76 @@
22

33
Application to process data coming in from detector stations.
44

5+
The main goal is to calculate coincidences on the fly. The calculation itself is not complicated though it requires supporting infrastructure.
6+
This infrastructure includes the classification of detector stations as reliable or unreliable to maintain a good level for the quality of the incoming data.
7+
58
It uses an event-driven pipeline design and can theoretically use a wide variety of input sources and ouput sinks.
69
Currently implemented is only a MQTT input source and MQTT, InfluxDB and an ascii output sinks.
710

8-
Compile by downloading this repository, creating a build directory next to the repository and running
11+
## dependencies
12+
Dependencies are
13+
```
14+
boost system
15+
boost program_options
16+
boost beast
17+
18+
libmosquitto
19+
libsasl2
20+
libldap
21+
```
22+
Consult your distributions package manager to discover how to install those dependencies.
923

10-
`cmake ../detector-network-processor && make`
24+
Build dependencies are
25+
```
26+
cmake
27+
```
1128

12-
If you want to use this on a debian system it is recommended to automatically create a package by running
29+
## compiling
30+
For compiling, it is recommended to use an out-of-source build directory. Here it is assumed the build directory is on the same directory level as the cloned repository.
31+
Execute the following commands in order to compile the processor.
32+
```
33+
mkdir build
34+
cd build
35+
cmake ../detector-network-processor -DCMAKE_BUILD_TYPE=Release
36+
make
37+
```
38+
This will result in the executable being written to `output/bin` in the build directory.
1339

14-
`make package`
40+
## installation
41+
Simply execute
42+
```
43+
make install
44+
```
45+
in the build directory.
46+
### debian based distributions
47+
In the case of debian based distributions you can optionally also build a package for easy installation.
48+
In order to do so, run
49+
```
50+
cpack
51+
```
52+
in the build directory. The debian package will be created in `output/packages` in the build directory.
53+
Install it via
54+
```
55+
apt install ./<package_name>.deb
56+
```
1557

16-
The output files will be written to the directory `output` in the build directory.
58+
## Configuration
59+
In order to see all configuration options, see the file `config/detector-network-processor.cfg`. Upon installation, this file will be written to `/etc/muondetector/detector-network-processor.cfg`.
60+
Edit this file to your needs.
61+
Commandline options are
62+
```
63+
-h [ --help ] produce help message
64+
-o [ --offline ] Do not send processed data to the
65+
servers.
66+
-d [ --debug ] Use the ascii sinks for debugging.
67+
-l [ --local ] Run the cluser as a local instance
68+
-v [ --verbose ] arg (=0) Verbosity level
69+
-c [ --config ] arg (=/etc/muondetector/detector-network-processor.cfg)
70+
Specify a configuration file to use
71+
```
72+
## Executing
73+
It is recommended to use the service file provided with the software, it should have been placed in the appropriate directory upon installation. Enable and start it with
74+
```
75+
systemctl enable --now detector-network-processor
76+
```
77+
However, you can also run the software without using the service file.

0 commit comments

Comments
 (0)