@@ -0,0 +1,35 | |||
|
1 | #ifndef SCIQLOP_AMDASERVER_H | |
|
2 | #define SCIQLOP_AMDASERVER_H | |
|
3 | ||
|
4 | #include <QLoggingCategory> | |
|
5 | ||
|
6 | #include <memory> | |
|
7 | ||
|
8 | Q_DECLARE_LOGGING_CATEGORY(LOG_AmdaServer) | |
|
9 | ||
|
10 | // Directive used to determine the active AMDA server | |
|
11 | #ifndef SCIQLOP_AMDA_SERVER | |
|
12 | #define SCIQLOP_AMDA_SERVER "default" | |
|
13 | #endif | |
|
14 | ||
|
15 | /** | |
|
16 | * @brief The AmdaServer class represents the server used to retrieve AMDA data (singleton). | |
|
17 | * | |
|
18 | * The server instance is initialized at compile time, as defined by the AMDA_SERVER value. | |
|
19 | */ | |
|
20 | class AmdaServer { | |
|
21 | public: | |
|
22 | /// @return the unique instance of the AMDA server | |
|
23 | static AmdaServer &instance(); | |
|
24 | ||
|
25 | virtual ~AmdaServer() noexcept = default; | |
|
26 | ||
|
27 | /// @return the name of the server | |
|
28 | virtual QString name() const = 0; | |
|
29 | ||
|
30 | /// @param properties used to generate url | |
|
31 | /// @return the url of the server (used to retrieve data) | |
|
32 | virtual QString url(const QVariantHash &properties = {}) const = 0; | |
|
33 | }; | |
|
34 | ||
|
35 | #endif // SCIQLOP_AMDASERVER_H |
@@ -0,0 +1,99 | |||
|
1 | #include "AmdaServer.h" | |
|
2 | ||
|
3 | #include "AmdaDefs.h" | |
|
4 | ||
|
5 | Q_LOGGING_CATEGORY(LOG_AmdaServer, "AmdaServer") | |
|
6 | ||
|
7 | namespace { | |
|
8 | ||
|
9 | /// URL of the default AMDA server | |
|
10 | const auto AMDA_DEFAULT_SERVER_URL = QStringLiteral("amda.irap.omp.eu"); | |
|
11 | ||
|
12 | /// URL of the AMDA test server | |
|
13 | const auto AMDA_TEST_SERVER_URL = QStringLiteral("amdatest.irap.omp.eu"); | |
|
14 | ||
|
15 | /// Port used for local server | |
|
16 | const auto AMDA_LOCAL_SERVER_PORT = 6543; | |
|
17 | ||
|
18 | /// URL of the local server | |
|
19 | const auto AMDA_LOCAL_SERVER_URL | |
|
20 | = QString{"localhost:%1"}.arg(QString::number(AMDA_LOCAL_SERVER_PORT)); | |
|
21 | ||
|
22 | /// Default AMDA server | |
|
23 | struct AmdaDefaultServer : public AmdaServer { | |
|
24 | public: | |
|
25 | QString name() const override { return QStringLiteral("AMDA (default)"); } | |
|
26 | QString url(const QVariantHash &properties) const override | |
|
27 | { | |
|
28 | Q_UNUSED(properties); | |
|
29 | return AMDA_DEFAULT_SERVER_URL; | |
|
30 | } | |
|
31 | }; | |
|
32 | ||
|
33 | /// Alternative AMDA server (tests) | |
|
34 | struct AmdaTestServer : public AmdaServer { | |
|
35 | public: | |
|
36 | QString name() const override { return QStringLiteral("AMDA (test)"); } | |
|
37 | QString url(const QVariantHash &properties) const override | |
|
38 | { | |
|
39 | Q_UNUSED(properties); | |
|
40 | return AMDA_TEST_SERVER_URL; | |
|
41 | } | |
|
42 | }; | |
|
43 | ||
|
44 | /// Hybrid AMDA server: use both of default and test server. | |
|
45 | /// The server used is relative to each product for which to retrieve url, according to its "server" | |
|
46 | /// property | |
|
47 | struct AmdaHybridServer : public AmdaServer { | |
|
48 | public: | |
|
49 | QString name() const override { return QStringLiteral("AMDA (hybrid)"); } | |
|
50 | QString url(const QVariantHash &properties) const override | |
|
51 | { | |
|
52 | // Reads "server" property to determine which server url to use | |
|
53 | auto server = properties.value(AMDA_SERVER_KEY).toString(); | |
|
54 | return server == QString{"amdatest"} ? AMDA_TEST_SERVER_URL : AMDA_DEFAULT_SERVER_URL; | |
|
55 | } | |
|
56 | }; | |
|
57 | ||
|
58 | /// Local AMDA server: use local python server to simulate AMDA requests | |
|
59 | struct AmdaLocalServer : public AmdaServer { | |
|
60 | public: | |
|
61 | QString name() const override { return AMDA_LOCAL_SERVER_URL; } | |
|
62 | QString url(const QVariantHash &properties) const override | |
|
63 | { | |
|
64 | Q_UNUSED(properties); | |
|
65 | return AMDA_LOCAL_SERVER_URL; | |
|
66 | } | |
|
67 | }; | |
|
68 | ||
|
69 | /// @return an AMDA server instance created from the name of the server passed in parameter. If the | |
|
70 | /// name does not match any known server, a default server instance is created | |
|
71 | std::unique_ptr<AmdaServer> createInstance(const QString &server) | |
|
72 | { | |
|
73 | if (server == QString{"amdatest"}) { | |
|
74 | return std::make_unique<AmdaTestServer>(); | |
|
75 | } | |
|
76 | else if (server == QString{"hybrid"}) { | |
|
77 | return std::make_unique<AmdaHybridServer>(); | |
|
78 | } | |
|
79 | else if (server == QString{"localhost"}) { | |
|
80 | return std::make_unique<AmdaLocalServer>(); | |
|
81 | } | |
|
82 | else { | |
|
83 | if (server != QString{"default"}) { | |
|
84 | qCWarning(LOG_AmdaServer()) | |
|
85 | << QObject::tr("Unknown server '%1': default AMDA server will be used").arg(server); | |
|
86 | } | |
|
87 | ||
|
88 | return std::make_unique<AmdaDefaultServer>(); | |
|
89 | } | |
|
90 | } | |
|
91 | ||
|
92 | } // namespace | |
|
93 | ||
|
94 | AmdaServer &AmdaServer::instance() | |
|
95 | { | |
|
96 | // Creates instance depending on the SCIQLOP_AMDA_SERVER value at compile time | |
|
97 | static auto instance = createInstance(SCIQLOP_AMDA_SERVER); | |
|
98 | return *instance; | |
|
99 | } |
@@ -0,0 +1,5 | |||
|
1 | AmdaResultParser\.h:\d+:.*IPSIS_S01.* | |
|
2 | AmdaResultParserHelper\.h:\d+:.*IPSIS_S01.* | |
|
3 | ||
|
4 | AmdaProvider\.cpp:\d+:.*IPSIS_S04_VARIABLE.*found: QStringLiteral | |
|
5 | AmdaResultParserHelper\.cpp:\d+:.*IPSIS_S04_VARIABLE.*found: QT_VERSION_CHECK No newline at end of file |
@@ -1,65 +1,74 | |||
|
1 | 1 | |
|
2 | 2 | if(BUILD_TESTS) |
|
3 | 3 | INCLUDE ("cmake/sciqlop_code_coverage.cmake") |
|
4 | 4 | APPEND_COVERAGE_COMPILER_FLAGS() |
|
5 | 5 | endif(BUILD_TESTS) |
|
6 | 6 | |
|
7 | 7 | # |
|
8 | 8 | # Compile the diffents modules |
|
9 | 9 | # |
|
10 | 10 | set(sciqlop-plugin_DIR "${CMAKE_SOURCE_DIR}/plugin/cmake") |
|
11 | 11 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-plugin_DIR}") |
|
12 | 12 | ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/plugin") |
|
13 | 13 | |
|
14 | 14 | set(sciqlop-core_DIR "${CMAKE_SOURCE_DIR}/core/cmake") |
|
15 | 15 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-core_DIR}") |
|
16 | 16 | ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/core") |
|
17 | 17 | |
|
18 | 18 | set(sciqlop-gui_DIR "${CMAKE_SOURCE_DIR}/gui/cmake") |
|
19 | 19 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-gui_DIR}") |
|
20 | 20 | ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/gui") |
|
21 | 21 | |
|
22 | 22 | ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/app") |
|
23 | 23 | |
|
24 | 24 | OPTION (BUILD_PLUGINS "Build the plugins" OFF) |
|
25 | 25 | IF(BUILD_PLUGINS) |
|
26 | 26 | set(sciqlop-mockplugin_DIR "${CMAKE_SOURCE_DIR}/plugins/mockplugin/cmake") |
|
27 | 27 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-mockplugin_DIR}") |
|
28 | 28 | ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/plugins/mockplugin") |
|
29 | 29 | |
|
30 | # Sets AMDA server that will be used during execution. | |
|
31 | # Available values are: | |
|
32 | # - "default": default AMDA server | |
|
33 | # - "amdatest": AMDA test server | |
|
34 | # - "hybrid": use both the default server and the test server (the server used is relative to each product, according to its "server" property in the JSON file) | |
|
35 | # - "localhost": use local AMDA server | |
|
36 | # Any other value will lead to the use of the default server | |
|
37 | ADD_DEFINITIONS(-DSCIQLOP_AMDA_SERVER="hybrid") | |
|
38 | ||
|
30 | 39 | set(sciqlop-amda_DIR "${CMAKE_SOURCE_DIR}/plugins/amda/cmake") |
|
31 | 40 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-amda_DIR}") |
|
32 | 41 | ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/plugins/amda") |
|
33 | 42 | |
|
34 | 43 | # Temporary target to copy to plugins dir |
|
35 | 44 | find_package(sciqlop-mockplugin) |
|
36 | 45 | find_package(sciqlop-amda) |
|
37 | 46 | ADD_CUSTOM_TARGET(plugins |
|
38 | 47 | COMMAND ${CMAKE_COMMAND} -E copy ${SCIQLOP-MOCKPLUGIN_LIBRARIES} "${LIBRARY_OUTPUT_PATH}/plugins/${SCIQLOP-MOCKPLUGIN_LIBRARIES_NAME}" |
|
39 | 48 | COMMAND ${CMAKE_COMMAND} -E copy ${SCIQLOP-AMDA_LIBRARIES} "${LIBRARY_OUTPUT_PATH}/plugins/${SCIQLOP-AMDA_LIBRARIES_NAME}" |
|
40 | 49 | ) |
|
41 | 50 | ENDIF(BUILD_PLUGINS) |
|
42 | 51 | |
|
43 | 52 | # LOGGER |
|
44 | 53 | set(QTLOGGING_INI_FILE "${CMAKE_SOURCE_DIR}/config/QtProject/qtlogging.ini") |
|
45 | 54 | FILE(COPY ${QTLOGGING_INI_FILE} DESTINATION ${CONFIG_OUTPUT_PATH}) |
|
46 | 55 | |
|
47 | 56 | |
|
48 | 57 | # |
|
49 | 58 | # Code formatting |
|
50 | 59 | # |
|
51 | 60 | # Vera++ exclusion files |
|
52 | 61 | LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/formatting/vera-exclusions/exclusions.txt) |
|
53 | 62 | #SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) |
|
54 | 63 | INCLUDE ("cmake/sciqlop_formatting.cmake") |
|
55 | 64 | |
|
56 | 65 | # |
|
57 | 66 | # Documentation generation |
|
58 | 67 | # |
|
59 | 68 | INCLUDE ("cmake/sciqlop_doxygen.cmake") |
|
60 | 69 | |
|
61 | 70 | # |
|
62 | 71 | # Source code analysis |
|
63 | 72 | # |
|
64 | 73 | INCLUDE ("cmake/sciqlop_code_analysis.cmake") |
|
65 | 74 | INCLUDE ("cmake/sciqlop_code_cppcheck.cmake") |
@@ -1,37 +1,46 | |||
|
1 | 1 | project('SciQLOP', 'cpp',default_options : ['cpp_std=c++14']) |
|
2 | 2 | |
|
3 | 3 | qt5 = import('qt5') |
|
4 | 4 | qt5core = dependency('qt5', modules : 'Core') |
|
5 | 5 | qt5widgets = dependency('qt5', modules : 'Widgets') |
|
6 | 6 | qt5gui = dependency('qt5', modules : 'Gui') |
|
7 | 7 | qt5svg = dependency('qt5', modules : 'Svg') |
|
8 | 8 | qt5xml = dependency('qt5', modules : 'Xml') |
|
9 | 9 | qt5network = dependency('qt5', modules : 'Network') |
|
10 | 10 | qt5printsupport = dependency('qt5', modules : 'PrintSupport') |
|
11 | 11 | qt5test = dependency('qt5', modules : 'Test') |
|
12 | 12 | |
|
13 | 13 | moc = find_program('moc-qt5','moc') |
|
14 | 14 | rcc = find_program('rcc-qt5','rcc') |
|
15 | 15 | |
|
16 | 16 | if build_machine.system()=='darwin' |
|
17 | 17 | add_global_link_arguments('-headerpad_max_install_names', language : 'cpp') |
|
18 | 18 | install_data('build_cfg/mac/sciqlopLOGO.icns', install_dir : 'Contents/Resources') |
|
19 | 19 | install_data('build_cfg/mac/Info.plist', install_dir : 'Contents') |
|
20 | 20 | meson.add_install_script('build_cfg/mac/install_script.sh') |
|
21 | 21 | elif host_machine.system()=='windows' |
|
22 | 22 | meson.add_install_script('build_cfg/windows/install_script.sh') |
|
23 | 23 | endif |
|
24 | 24 | |
|
25 | # Sets AMDA server that will be used during execution. | |
|
26 | # Available values are: | |
|
27 | # - "default": default AMDA server | |
|
28 | # - "amdatest": AMDA test server | |
|
29 | # - "hybrid": use both the default server and the test server (the server used is relative to each product, according to its "server" property in the JSON file) | |
|
30 | # - "localhost": use local AMDA server | |
|
31 | # Any other value will lead to the use of the default server | |
|
32 | add_project_arguments('-DSCIQLOP_AMDA_SERVER="hybrid"', language : 'cpp') | |
|
33 | ||
|
25 | 34 | subdir('core') |
|
26 | 35 | subdir('gui') |
|
27 | 36 | subdir('app') |
|
28 | 37 | subdir('plugins') |
|
29 | 38 | |
|
30 | 39 | cppcheck = find_program('cppcheck', required : false) |
|
31 | 40 | |
|
32 | 41 | if cppcheck.found() |
|
33 | 42 | run_target('cppcheck', |
|
34 | 43 | command : [cppcheck, '--enable=all', |
|
35 | 44 | '--project=' + join_paths(meson.build_root(), 'compile_commands.json')] |
|
36 | 45 | ) |
|
37 | 46 | endif |
@@ -1,167 +1,167 | |||
|
1 | 1 | ## amda - CMakeLists.txt |
|
2 | 2 | STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX) |
|
3 | 3 | SET(SQPAMDA_LIBRARY_NAME "${LIBRARY_PREFFIX}_amda${DEBUG_SUFFIX}") |
|
4 | 4 | SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") |
|
5 | 5 | SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include") |
|
6 | 6 | SET(RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources") |
|
7 | 7 | SET(TESTS_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests-resources") |
|
8 | 8 | |
|
9 | 9 | # Include amda directory |
|
10 | 10 | INCLUDE_DIRECTORIES(${INCLUDES_DIR}) |
|
11 | 11 | INCLUDE_DIRECTORIES(${RESOURCES_DIR}) |
|
12 | 12 | |
|
13 | 13 | # |
|
14 | 14 | # Find Qt modules |
|
15 | 15 | # |
|
16 | 16 | SCIQLOP_FIND_QT(Core Widgets Network) |
|
17 | 17 | |
|
18 | 18 | # |
|
19 | 19 | # Find dependent libraries |
|
20 | 20 | # ======================== |
|
21 | 21 | |
|
22 | 22 | # sciqlop plugin |
|
23 | 23 | find_package(sciqlop-plugin) |
|
24 | 24 | INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR}) |
|
25 | 25 | |
|
26 | 26 | # sciqlop core |
|
27 | 27 | find_package(sciqlop-core) |
|
28 | 28 | INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR}) |
|
29 | 29 | list(APPEND LIBRARIES ${SCIQLOP-CORE_LIBRARIES}) |
|
30 | 30 | |
|
31 | 31 | # sciqlop gui |
|
32 | 32 | find_package(sciqlop-gui) |
|
33 | 33 | INCLUDE_DIRECTORIES(${SCIQLOP-GUI_INCLUDE_DIR}) |
|
34 | 34 | list(APPEND LIBRARIES ${SCIQLOP-GUI_LIBRARIES}) |
|
35 | 35 | |
|
36 | 36 | # Description file |
|
37 | 37 | FILE (GLOB_RECURSE PLUGIN_FILE ${RESOURCES_DIR}/amda.json) |
|
38 | 38 | |
|
39 | 39 | # Resources files |
|
40 | 40 | FILE (GLOB_RECURSE PROJECT_RESOURCES ${RESOURCES_DIR}/*.qrc) |
|
41 | 41 | |
|
42 | 42 | # |
|
43 | 43 | # Compile the library |
|
44 | 44 | # |
|
45 | 45 | |
|
46 | 46 | ADD_DEFINITIONS(-DAMDA_LIB) |
|
47 | 47 | |
|
48 | 48 | FILE (GLOB_RECURSE MODULE_SOURCES |
|
49 | 49 | ${INCLUDES_DIR}/*.h |
|
50 | 50 | ${SOURCES_DIR}/*.c |
|
51 | 51 | ${SOURCES_DIR}/*.cpp |
|
52 | 52 | ${SOURCES_DIR}/*.h |
|
53 | 53 | ${PLUGIN_FILE}) |
|
54 | 54 | |
|
55 | 55 | QT5_ADD_RESOURCES(RCC_AMDA |
|
56 | 56 | ${PROJECT_RESOURCES} |
|
57 | 57 | ) |
|
58 | 58 | |
|
59 | 59 | ADD_LIBRARY(${SQPAMDA_LIBRARY_NAME} ${MODULE_SOURCES} ${RCC_AMDA}) |
|
60 | 60 | set_property(TARGET ${SQPAMDA_LIBRARY_NAME} PROPERTY CXX_STANDARD 14) |
|
61 | 61 | set_property(TARGET ${SQPAMDA_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) |
|
62 | 62 | |
|
63 | 63 | INSTALL(TARGETS ${SQPAMDA_LIBRARY_NAME} |
|
64 | 64 | RUNTIME DESTINATION ${INSTALL_BINARY_DIR} |
|
65 | 65 | LIBRARY DESTINATION ${INSTALL_PLUGINS_LIBRARY_DIR} |
|
66 | 66 | ARCHIVE DESTINATION ${INSTALL_PLUGINS_LIBRARY_DIR} |
|
67 | 67 | ) |
|
68 | 68 | |
|
69 | 69 | |
|
70 | 70 | TARGET_LINK_LIBRARIES(${SQPAMDA_LIBRARY_NAME} ${LIBRARIES}) |
|
71 | 71 | qt5_use_modules(${SQPAMDA_LIBRARY_NAME} Core Widgets Network) |
|
72 | 72 | |
|
73 | 73 | add_dependencies(${SQPAMDA_LIBRARY_NAME} ${SQPPLUGIN_LIBRARY_NAME} ${SQPGUI_LIBRARY_NAME} ${SQPCORE_LIBRARY_NAME}) |
|
74 | 74 | |
|
75 | 75 | # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html |
|
76 | 76 | # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order. |
|
77 | 77 | # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets |
|
78 | 78 | IF(BUILD_SHARED_LIBS) |
|
79 | 79 | SET_TARGET_PROPERTIES(${SQPAMDA_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT") |
|
80 | 80 | ELSE() |
|
81 | 81 | TARGET_COMPILE_DEFINITIONS(${SQPAMDA_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES") |
|
82 | 82 | ENDIF() |
|
83 | 83 | |
|
84 | 84 | # Set the variable to parent scope so that the other projects can copy the |
|
85 | 85 | # dependent shared libraries |
|
86 | 86 | SCIQLOP_SET_TO_PARENT_SCOPE(SQPAMDA_LIBRARY_NAME) |
|
87 | 87 | |
|
88 | 88 | # Copy extern shared libraries to the lib folder |
|
89 | 89 | SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPAMDA_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES}) |
|
90 | 90 | |
|
91 | 91 | # Add the files to the list of files to be analyzed |
|
92 | 92 | LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES}) |
|
93 | 93 | SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES) |
|
94 | 94 | # Vera++ exclusion files |
|
95 |
|
|
|
95 | LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt) | |
|
96 | 96 | SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) |
|
97 | 97 | |
|
98 | 98 | # |
|
99 | 99 | # Compile the tests |
|
100 | 100 | # |
|
101 | 101 | IF(BUILD_TESTS) |
|
102 | 102 | INCLUDE_DIRECTORIES(${SOURCES_DIR}) |
|
103 | 103 | FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp) |
|
104 | 104 | FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h) |
|
105 | 105 | SET( TEST_LIBRARIES ${SQPAMDA_LIBRARY_NAME}) |
|
106 | 106 | |
|
107 | 107 | FOREACH( testFile ${TESTS_SOURCES} ) |
|
108 | 108 | GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) |
|
109 | 109 | GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE ) |
|
110 | 110 | |
|
111 | 111 | # Add to the list of sources files all the sources in the same |
|
112 | 112 | # directory that aren't another test |
|
113 | 113 | FILE (GLOB currentTestSources |
|
114 | 114 | ${testDirectory}/*.c |
|
115 | 115 | ${testDirectory}/*.cpp |
|
116 | 116 | ${testDirectory}/*.h) |
|
117 | 117 | LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES}) |
|
118 | 118 | # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS}) |
|
119 | 119 | |
|
120 | 120 | ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) |
|
121 | 121 | set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14) |
|
122 | 122 | set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON) |
|
123 | 123 | TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} ) |
|
124 | 124 | qt5_use_modules(${testName} Test) |
|
125 | 125 | |
|
126 | 126 | ADD_TEST( NAME ${testName} COMMAND ${testName} ) |
|
127 | 127 | |
|
128 | 128 | SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES}) |
|
129 | 129 | ENDFOREACH( testFile ) |
|
130 | 130 | |
|
131 | 131 | LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) |
|
132 | 132 | LIST(APPEND testFilesToFormat ${TESTS_HEADERS}) |
|
133 | 133 | LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat}) |
|
134 | 134 | SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) |
|
135 | 135 | |
|
136 | 136 | ADD_DEFINITIONS(-DAMDA_TESTS_RESOURCES_DIR="${TESTS_RESOURCES_DIR}") |
|
137 | 137 | ENDIF(BUILD_TESTS) |
|
138 | 138 | |
|
139 | 139 | # |
|
140 | 140 | # Set the files that must be formatted by clang-format. |
|
141 | 141 | # |
|
142 | 142 | LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES}) |
|
143 | 143 | SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) |
|
144 | 144 | |
|
145 | 145 | # |
|
146 | 146 | # Set the directories that doxygen must browse to generate the |
|
147 | 147 | # documentation. |
|
148 | 148 | # |
|
149 | 149 | # Source directories: |
|
150 | 150 | LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs") |
|
151 | 151 | LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") |
|
152 | 152 | SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS) |
|
153 | 153 | # Source directories to exclude from the documentation generation |
|
154 | 154 | #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*") |
|
155 | 155 | SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS) |
|
156 | 156 | |
|
157 | 157 | # |
|
158 | 158 | # Set the directories with the sources to analyze and propagate the |
|
159 | 159 | # modification to the parent scope |
|
160 | 160 | # |
|
161 | 161 | # Source directories to analyze: |
|
162 | 162 | LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") |
|
163 | 163 | LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests") |
|
164 | 164 | SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS) |
|
165 | 165 | # Source directories to exclude from the analysis |
|
166 | 166 | #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir") |
|
167 | 167 | SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS) |
@@ -1,29 +1,29 | |||
|
1 | 1 | #ifndef SCIQLOP_AMDAPLUGIN_H |
|
2 | 2 | #define SCIQLOP_AMDAPLUGIN_H |
|
3 | 3 | |
|
4 | 4 | #include "AmdaGlobal.h" |
|
5 | 5 | |
|
6 | 6 | #include <Plugin/IPlugin.h> |
|
7 | 7 | |
|
8 | 8 | #include <QLoggingCategory> |
|
9 | 9 | |
|
10 | 10 | #include <memory> |
|
11 | 11 | |
|
12 | 12 | Q_DECLARE_LOGGING_CATEGORY(LOG_AmdaPlugin) |
|
13 | 13 | |
|
14 | #ifndef PLUGIN_JSON_FILE_PATH | |
|
15 | #define PLUGIN_JSON_FILE_PATH "amda.json" | |
|
14 | #ifndef SCIQLOP_PLUGIN_JSON_FILE_PATH | |
|
15 | #define SCIQLOP_PLUGIN_JSON_FILE_PATH "amda.json" | |
|
16 | 16 | #endif |
|
17 | 17 | |
|
18 | 18 | class DataSourceItem; |
|
19 | 19 | |
|
20 | 20 | class SCIQLOP_AMDA_EXPORT AmdaPlugin : public QObject, public IPlugin { |
|
21 | 21 | Q_OBJECT |
|
22 | 22 | Q_INTERFACES(IPlugin) |
|
23 | Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE PLUGIN_JSON_FILE_PATH) | |
|
23 | Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE SCIQLOP_PLUGIN_JSON_FILE_PATH) | |
|
24 | 24 | public: |
|
25 | 25 | /// @sa IPlugin::initialize() |
|
26 | 26 | void initialize() override; |
|
27 | 27 | }; |
|
28 | 28 | |
|
29 | 29 | #endif // SCIQLOP_AMDAPLUGIN_H |
@@ -1,44 +1,44 | |||
|
1 | 1 | #ifndef SCIQLOP_AMDAPROVIDER_H |
|
2 | 2 | #define SCIQLOP_AMDAPROVIDER_H |
|
3 | 3 | |
|
4 | 4 | #include "AmdaGlobal.h" |
|
5 | 5 | |
|
6 | 6 | #include <Data/IDataProvider.h> |
|
7 | 7 | |
|
8 | 8 | #include <QLoggingCategory> |
|
9 | 9 | |
|
10 | 10 | #include <map> |
|
11 | 11 | |
|
12 | 12 | Q_DECLARE_LOGGING_CATEGORY(LOG_AmdaProvider) |
|
13 | 13 | |
|
14 | 14 | class QNetworkReply; |
|
15 | 15 | class QNetworkRequest; |
|
16 | 16 | |
|
17 | 17 | /** |
|
18 | 18 | * @brief The AmdaProvider class is an example of how a data provider can generate data |
|
19 | 19 | */ |
|
20 | 20 | class SCIQLOP_AMDA_EXPORT AmdaProvider : public IDataProvider { |
|
21 | 21 | Q_OBJECT |
|
22 | 22 | public: |
|
23 | 23 | explicit AmdaProvider(); |
|
24 | 24 | std::shared_ptr<IDataProvider> clone() const override; |
|
25 | 25 | |
|
26 | 26 | void requestDataLoading(QUuid acqIdentifier, const DataProviderParameters ¶meters) override; |
|
27 | 27 | |
|
28 | 28 | void requestDataAborting(QUuid acqIdentifier) override; |
|
29 | 29 | |
|
30 | private slots: | |
|
31 | void onReplyDownloadProgress(QUuid acqIdentifier, | |
|
32 | std::shared_ptr<QNetworkRequest> networkRequest, double progress); | |
|
33 | ||
|
34 | 30 | private: |
|
35 | 31 | void retrieveData(QUuid token, const SqpRange &dateTime, const QVariantHash &data); |
|
36 | 32 | |
|
37 | 33 | void updateRequestProgress(QUuid acqIdentifier, std::shared_ptr<QNetworkRequest> request, |
|
38 | 34 | double progress); |
|
39 | 35 | |
|
40 | 36 | std::map<QUuid, std::map<std::shared_ptr<QNetworkRequest>, double> > |
|
41 | 37 | m_AcqIdToRequestProgressMap; |
|
38 | ||
|
39 | private slots: | |
|
40 | void onReplyDownloadProgress(QUuid acqIdentifier, | |
|
41 | std::shared_ptr<QNetworkRequest> networkRequest, double progress); | |
|
42 | 42 | }; |
|
43 | 43 | |
|
44 | 44 | #endif // SCIQLOP_AMDAPROVIDER_H |
@@ -1,76 +1,79 | |||
|
1 | 1 | #ifndef SCIQLOP_AMDARESULTPARSERDEFS_H |
|
2 | 2 | #define SCIQLOP_AMDARESULTPARSERDEFS_H |
|
3 | 3 | |
|
4 | 4 | #include <QtCore/QRegularExpression> |
|
5 | 5 | #include <QtCore/QString> |
|
6 | 6 | #include <QtCore/QVariantHash> |
|
7 | 7 | |
|
8 | 8 | // ////////// // |
|
9 | 9 | // Properties // |
|
10 | 10 | // ////////// // |
|
11 | 11 | |
|
12 | 12 | /// Alias to represent properties read in the header of AMDA file |
|
13 | 13 | using Properties = QVariantHash; |
|
14 | 14 | |
|
15 | 15 | extern const QString END_TIME_PROPERTY; |
|
16 | 16 | extern const QString FILL_VALUE_PROPERTY; |
|
17 | 17 | extern const QString MAX_BANDS_PROPERTY; |
|
18 | 18 | extern const QString MIN_BANDS_PROPERTY; |
|
19 | 19 | extern const QString MAX_SAMPLING_PROPERTY; |
|
20 | 20 | extern const QString MIN_SAMPLING_PROPERTY; |
|
21 | 21 | extern const QString START_TIME_PROPERTY; |
|
22 | 22 | extern const QString X_AXIS_UNIT_PROPERTY; |
|
23 | 23 | extern const QString Y_AXIS_UNIT_PROPERTY; |
|
24 | 24 | extern const QString VALUES_UNIT_PROPERTY; |
|
25 | 25 | |
|
26 | 26 | // /////////////////// // |
|
27 | 27 | // Regular expressions // |
|
28 | 28 | // /////////////////// // |
|
29 | 29 | |
|
30 | 30 | // AMDA V2 |
|
31 | 31 | // /// Regex to find the header of the data in the file. This header indicates the end of comments |
|
32 | 32 | // in the file |
|
33 | 33 | // const auto DATA_HEADER_REGEX = QRegularExpression{QStringLiteral("#\\s*DATA\\s*:")}; |
|
34 | 34 | |
|
35 | 35 | // AMDA V2 |
|
36 | 36 | // /// ... PARAMETER_UNITS : nT ... |
|
37 | 37 | // /// ... PARAMETER_UNITS:nT ... |
|
38 | 38 | // /// ... PARAMETER_UNITS: mΒ² ... |
|
39 | 39 | // /// ... PARAMETER_UNITS : m/s ... |
|
40 | 40 | // const auto UNIT_REGEX = QRegularExpression{QStringLiteral("\\s*PARAMETER_UNITS\\s*:\\s*(.+)")}; |
|
41 | 41 | |
|
42 | 42 | /// Regex to find x-axis unit in a line. Examples of valid lines: |
|
43 | 43 | /// ... - Units : nT - ... |
|
44 | 44 | /// ... -Units:nT- ... |
|
45 | 45 | /// ... -Units: mΒ²- ... |
|
46 | 46 | /// ... - Units : m/s - ... |
|
47 | 47 | extern const QRegularExpression DEFAULT_X_AXIS_UNIT_REGEX; |
|
48 | 48 | |
|
49 | /// Alternative regex to find x-axis unit in a line | |
|
50 | extern const QRegularExpression ALTERNATIVE_X_AXIS_UNIT_REGEX; | |
|
51 | ||
|
49 | 52 | /// Regex to find end time of data in a line for a spectrogram |
|
50 | 53 | extern const QRegularExpression SPECTROGRAM_END_TIME_REGEX; |
|
51 | 54 | |
|
52 | 55 | /// Regex to find fill value used in a line for a spectrogram |
|
53 | 56 | extern const QRegularExpression SPECTROGRAM_FILL_VALUE_REGEX; |
|
54 | 57 | |
|
55 | 58 | /// Regex to find max bands in a line for a spectrogram |
|
56 | 59 | extern const QRegularExpression SPECTROGRAM_MAX_BANDS_REGEX; |
|
57 | 60 | |
|
58 | 61 | /// Regex to find min bands in a line for a spectrogram |
|
59 | 62 | extern const QRegularExpression SPECTROGRAM_MIN_BANDS_REGEX; |
|
60 | 63 | |
|
61 | 64 | /// Regex to find max x-axis sampling in a line for a spectrogram |
|
62 | 65 | extern const QRegularExpression SPECTROGRAM_MAX_SAMPLING_REGEX; |
|
63 | 66 | |
|
64 | 67 | /// Regex to find min x-axis sampling in a line for a spectrogram |
|
65 | 68 | extern const QRegularExpression SPECTROGRAM_MIN_SAMPLING_REGEX; |
|
66 | 69 | |
|
67 | 70 | /// Regex to find start time of data in a line for a spectrogram |
|
68 | 71 | extern const QRegularExpression SPECTROGRAM_START_TIME_REGEX; |
|
69 | 72 | |
|
70 | 73 | /// Regex to find y-axis unit in a line for a spectrogram |
|
71 | 74 | extern const QRegularExpression SPECTROGRAM_Y_AXIS_UNIT_REGEX; |
|
72 | 75 | |
|
73 | 76 | /// Regex to find values unit in a line for a spectrogram |
|
74 | 77 | extern const QRegularExpression SPECTROGRAM_VALUES_UNIT_REGEX; |
|
75 | 78 | |
|
76 | 79 | #endif // SCIQLOP_AMDARESULTPARSERDEFS_H |
@@ -1,75 +1,76 | |||
|
1 | 1 | |
|
2 | 2 | amdaplugin_moc_headers = [ |
|
3 | 3 | 'include/AmdaPlugin.h', |
|
4 | 4 | 'include/AmdaProvider.h' |
|
5 | 5 | ] |
|
6 | 6 | |
|
7 | 7 | amdaplugin_sources = [ |
|
8 | 8 | 'src/AmdaDefs.cpp', |
|
9 | 9 | 'src/AmdaParser.cpp', |
|
10 | 10 | 'src/AmdaPlugin.cpp', |
|
11 | 11 | 'src/AmdaProvider.cpp', |
|
12 | 12 | 'src/AmdaResultParser.cpp', |
|
13 | 13 | 'src/AmdaResultParserDefs.cpp', |
|
14 | 'src/AmdaResultParserHelper.cpp' | |
|
14 | 'src/AmdaResultParserHelper.cpp', | |
|
15 | 'src/AmdaServer.cpp' | |
|
15 | 16 | ] |
|
16 | 17 | |
|
17 | 18 | amdaplugin_ui_files = [] |
|
18 | 19 | amdaplugin_resources_files = [ |
|
19 | 20 | 'resources/amdaresources.qrc' |
|
20 | 21 | ] |
|
21 | 22 | |
|
22 | 23 | amdaplugin_inc = include_directories(['include', '../../plugin/include']) |
|
23 | 24 | |
|
24 | 25 | moc_gen = generator(moc, |
|
25 | 26 | output : 'moc_@BASENAME@.cpp', |
|
26 | 27 | arguments : ['@INPUT@', |
|
27 | '-DPLUGIN_JSON_FILE_PATH="'+meson.source_root()+'/plugins/amda/resources/amda.json"', | |
|
28 | '-DSCIQLOP_PLUGIN_JSON_FILE_PATH="'+meson.source_root()+'/plugins/amda/resources/amda.json"', | |
|
28 | 29 | '-I', meson.current_source_dir()+'/include', |
|
29 | 30 | '-I', meson.current_source_dir()+'/../../plugin/include', |
|
30 | 31 | '-o', '@OUTPUT@']) |
|
31 | 32 | |
|
32 | 33 | rcc_gen = generator(rcc, |
|
33 | 34 | output : 'qrc_@BASENAME@.cpp', |
|
34 | 35 | arguments : ['--name=@BASENAME@"', |
|
35 | 36 | '--output', |
|
36 | 37 | '@OUTPUT@', |
|
37 | 38 | '@INPUT@']) |
|
38 | 39 | |
|
39 | 40 | amdaplugin_moc_plugin_files = moc_gen.process(amdaplugin_moc_headers) |
|
40 | 41 | |
|
41 | 42 | amdaplugin_rcc_plugin_files = rcc_gen.process(amdaplugin_resources_files) |
|
42 | 43 | |
|
43 | 44 | #amdaplugin_rcc_plugin_files = qt5.preprocess( |
|
44 | 45 | # qresources : amdaplugin_resources_files) |
|
45 | 46 | |
|
46 | 47 | amdaplugin_moc_files = qt5.preprocess( |
|
47 | 48 | ui_files : amdaplugin_ui_files) |
|
48 | 49 | |
|
49 | 50 | sciqlop_amdaplugin = library('amdaplugin', |
|
50 | 51 | amdaplugin_sources, |
|
51 | 52 | amdaplugin_moc_files, |
|
52 | 53 | amdaplugin_rcc_plugin_files, |
|
53 | 54 | amdaplugin_moc_plugin_files, |
|
54 | 55 | cpp_args : ['-DAMDA_LIB','-DQT_PLUGIN'], |
|
55 | 56 | include_directories : [amdaplugin_inc], |
|
56 | 57 | dependencies : [sciqlop_core, sciqlop_gui], |
|
57 | 58 | install : true |
|
58 | 59 | ) |
|
59 | 60 | |
|
60 | 61 | |
|
61 | 62 | tests = [ |
|
62 | 63 | [['tests/TestAmdaParser.cpp'],'test_amda_parser','AMDA parser test'], |
|
63 | 64 | [['tests/TestAmdaResultParser.cpp'],'test_amda_result_parser','AMDA result parser test'], |
|
64 | 65 | [['tests/TestAmdaAcquisition.cpp'],'test_amda_acquisition','AMDA Acquisition test'] |
|
65 | 66 | ] |
|
66 | 67 | |
|
67 | 68 | foreach unit_test : tests |
|
68 | 69 | test_moc_files = qt5.preprocess(moc_sources : unit_test[0]) |
|
69 | 70 | test_exe = executable(unit_test[1],unit_test[0] , test_moc_files, |
|
70 | 71 | link_with : [sciqlop_amdaplugin], |
|
71 | 72 | include_directories : [amdaplugin_inc], |
|
72 | 73 | cpp_args : ['-DAMDA_TESTS_RESOURCES_DIR="'+meson.current_source_dir()+'/tests-resources"'], |
|
73 | 74 | dependencies : [sciqlop_core, sciqlop_gui, qt5test]) |
|
74 | 75 | test(unit_test[2], test_exe, args: ['-teamcity', '-o', '@0@.teamcity.txt'.format(unit_test[1])], timeout: 3 * 60) |
|
75 | 76 | endforeach |
@@ -1,77 +1,78 | |||
|
1 | 1 | #include "AmdaPlugin.h" |
|
2 | 2 | #include "AmdaDefs.h" |
|
3 | 3 | #include "AmdaParser.h" |
|
4 | 4 | #include "AmdaProvider.h" |
|
5 | #include "AmdaServer.h" | |
|
5 | 6 | |
|
6 | 7 | #include <DataSource/DataSourceController.h> |
|
7 | 8 | #include <DataSource/DataSourceItem.h> |
|
8 | 9 | #include <DataSource/DataSourceItemAction.h> |
|
9 | 10 | |
|
10 | 11 | #include <SqpApplication.h> |
|
11 | 12 | |
|
12 | 13 | Q_LOGGING_CATEGORY(LOG_AmdaPlugin, "AmdaPlugin") |
|
13 | 14 | |
|
14 | 15 | namespace { |
|
15 | 16 | |
|
16 | /// Name of the data source | |
|
17 | const auto DATA_SOURCE_NAME = QStringLiteral("AMDA"); | |
|
18 | ||
|
19 | 17 | /// Path of the file used to generate the data source item for AMDA |
|
20 | 18 | const auto JSON_FILE_PATH = QStringLiteral(":/samples/AmdaSampleV3.json"); |
|
21 | 19 | |
|
22 | 20 | void associateActions(DataSourceItem &item, const QUuid &dataSourceUid) |
|
23 | 21 | { |
|
24 | 22 | auto addLoadAction = [&item, dataSourceUid](const QString &label) { |
|
25 | 23 | item.addAction( |
|
26 | 24 | std::make_unique<DataSourceItemAction>(label, [dataSourceUid](DataSourceItem &item) { |
|
27 | 25 | if (auto app = sqpApp) { |
|
28 | 26 | app->dataSourceController().loadProductItem(dataSourceUid, item); |
|
29 | 27 | } |
|
30 | 28 | })); |
|
31 | 29 | }; |
|
32 | 30 | |
|
33 | 31 | const auto itemType = item.type(); |
|
34 | 32 | if (itemType == DataSourceItemType::PRODUCT || itemType == DataSourceItemType::COMPONENT) { |
|
35 | 33 | // Adds plugin name to item metadata |
|
36 |
item.setData(DataSourceItem::PLUGIN_DATA_KEY, |
|
|
34 | item.setData(DataSourceItem::PLUGIN_DATA_KEY, AmdaServer::instance().name()); | |
|
37 | 35 | |
|
38 | 36 | // Adds load action |
|
39 | 37 | auto actionLabel = QObject::tr( |
|
40 | 38 | itemType == DataSourceItemType::PRODUCT ? "Load %1 product" : "Load %1 component"); |
|
41 | 39 | addLoadAction(actionLabel.arg(item.name())); |
|
42 | 40 | } |
|
43 | 41 | |
|
44 | 42 | auto count = item.childCount(); |
|
45 | 43 | for (auto i = 0; i < count; ++i) { |
|
46 | 44 | if (auto child = item.child(i)) { |
|
47 | 45 | associateActions(*child, dataSourceUid); |
|
48 | 46 | } |
|
49 | 47 | } |
|
50 | 48 | } |
|
51 | 49 | |
|
52 | 50 | } // namespace |
|
53 | 51 | |
|
54 | 52 | void AmdaPlugin::initialize() |
|
55 | 53 | { |
|
56 | 54 | if (auto app = sqpApp) { |
|
55 | auto dataSourceName = AmdaServer::instance().name(); | |
|
56 | ||
|
57 | 57 | // Registers to the data source controller |
|
58 | 58 | auto &dataSourceController = app->dataSourceController(); |
|
59 |
auto dataSourceUid = dataSourceController.registerDataSource( |
|
|
59 | auto dataSourceUid = dataSourceController.registerDataSource(dataSourceName); | |
|
60 | 60 | |
|
61 | 61 | // Sets data source tree |
|
62 | 62 | if (auto dataSourceItem = AmdaParser::readJson(JSON_FILE_PATH)) { |
|
63 | associateActions(*dataSourceItem, dataSourceUid); | |
|
63 | dataSourceItem->setData(DataSourceItem::NAME_DATA_KEY, dataSourceName); | |
|
64 | 64 | |
|
65 | associateActions(*dataSourceItem, dataSourceUid); | |
|
65 | 66 | dataSourceController.setDataSourceItem(dataSourceUid, std::move(dataSourceItem)); |
|
66 | 67 | } |
|
67 | 68 | else { |
|
68 | 69 | qCCritical(LOG_AmdaPlugin()) << tr("No data source item could be generated for AMDA"); |
|
69 | 70 | } |
|
70 | 71 | |
|
71 | 72 | // Sets data provider |
|
72 | 73 | dataSourceController.setDataProvider(dataSourceUid, std::make_unique<AmdaProvider>()); |
|
73 | 74 | } |
|
74 | 75 | else { |
|
75 | 76 | qCWarning(LOG_AmdaPlugin()) << tr("Can't access to SciQlop application"); |
|
76 | 77 | } |
|
77 | 78 | } |
@@ -1,307 +1,288 | |||
|
1 | 1 | #include "AmdaProvider.h" |
|
2 | 2 | #include "AmdaDefs.h" |
|
3 | 3 | #include "AmdaResultParser.h" |
|
4 | #include "AmdaServer.h" | |
|
4 | 5 | |
|
5 | 6 | #include <Common/DateUtils.h> |
|
6 | 7 | #include <Data/DataProviderParameters.h> |
|
7 | 8 | #include <Network/NetworkController.h> |
|
8 | 9 | #include <SqpApplication.h> |
|
9 | 10 | #include <Variable/Variable.h> |
|
10 | 11 | |
|
11 | 12 | #include <QNetworkAccessManager> |
|
12 | 13 | #include <QNetworkReply> |
|
13 | 14 | #include <QTemporaryFile> |
|
14 | 15 | #include <QThread> |
|
15 | 16 | |
|
16 | 17 | Q_LOGGING_CATEGORY(LOG_AmdaProvider, "AmdaProvider") |
|
17 | 18 | |
|
18 | 19 | namespace { |
|
19 | 20 | |
|
20 | /// URL of the default AMDA server | |
|
21 | const auto AMDA_SERVER_URL = QStringLiteral("amda.irap.omp.eu"); | |
|
22 | ||
|
23 | /// URL of the AMDA test server | |
|
24 | const auto AMDA_TEST_SERVER_URL = QStringLiteral("amdatest.irap.omp.eu"); | |
|
25 | ||
|
26 | 21 | /// URL format for a request on AMDA server. The parameters are as follows: |
|
27 | 22 | /// - %1: server URL |
|
28 | 23 | /// - %2: start date |
|
29 | 24 | /// - %3: end date |
|
30 | 25 | /// - %4: parameter id |
|
31 | 26 | /// AMDA V2: http://amdatest.irap.omp.eu/php/rest/ |
|
32 | 27 | const auto AMDA_URL_FORMAT = QStringLiteral( |
|
33 | 28 | "http://%1/php/rest/" |
|
34 | 29 | "getParameter.php?startTime=%2&stopTime=%3¶meterID=%4&outputFormat=ASCII&" |
|
35 | 30 | "timeFormat=ISO8601&gzip=0"); |
|
36 | 31 | |
|
37 | 32 | /// Dates format passed in the URL (e.g 2013-09-23T09:00) |
|
38 | 33 | const auto AMDA_TIME_FORMAT = QStringLiteral("yyyy-MM-ddThh:mm:ss"); |
|
39 | 34 | |
|
40 | 35 | /// Formats a time to a date that can be passed in URL |
|
41 | 36 | QString dateFormat(double sqpRange) noexcept |
|
42 | 37 | { |
|
43 | 38 | auto dateTime = DateUtils::dateTime(sqpRange); |
|
44 | 39 | return dateTime.toString(AMDA_TIME_FORMAT); |
|
45 | 40 | } |
|
46 | 41 | |
|
47 | /// Returns the URL of the AMDA server queried for requests, depending on the type of server passed | |
|
48 | /// as a parameter | |
|
49 | QString serverURL(const QString &server) | |
|
50 | { | |
|
51 | if (server == QString{"amdatest"}) { | |
|
52 | return AMDA_TEST_SERVER_URL; | |
|
53 | } | |
|
54 | else { | |
|
55 | return AMDA_SERVER_URL; | |
|
56 | } | |
|
57 | } | |
|
58 | ||
|
59 | 42 | AmdaResultParser::ValueType valueType(const QString &valueType) |
|
60 | 43 | { |
|
61 | 44 | if (valueType == QStringLiteral("scalar")) { |
|
62 | 45 | return AmdaResultParser::ValueType::SCALAR; |
|
63 | 46 | } |
|
64 | 47 | else if (valueType == QStringLiteral("spectrogram")) { |
|
65 | 48 | return AmdaResultParser::ValueType::SPECTROGRAM; |
|
66 | 49 | } |
|
67 | 50 | else if (valueType == QStringLiteral("vector")) { |
|
68 | 51 | return AmdaResultParser::ValueType::VECTOR; |
|
69 | 52 | } |
|
70 | 53 | else { |
|
71 | 54 | return AmdaResultParser::ValueType::UNKNOWN; |
|
72 | 55 | } |
|
73 | 56 | } |
|
74 | 57 | |
|
75 | 58 | } // namespace |
|
76 | 59 | |
|
77 | 60 | AmdaProvider::AmdaProvider() |
|
78 | 61 | { |
|
79 | 62 | qCDebug(LOG_AmdaProvider()) << tr("AmdaProvider::AmdaProvider") << QThread::currentThread(); |
|
80 | 63 | if (auto app = sqpApp) { |
|
81 | 64 | auto &networkController = app->networkController(); |
|
82 | 65 | connect(this, SIGNAL(requestConstructed(std::shared_ptr<QNetworkRequest>, QUuid, |
|
83 | 66 | std::function<void(QNetworkReply *, QUuid)>)), |
|
84 | 67 | &networkController, |
|
85 | 68 | SLOT(onProcessRequested(std::shared_ptr<QNetworkRequest>, QUuid, |
|
86 | 69 | std::function<void(QNetworkReply *, QUuid)>))); |
|
87 | 70 | |
|
88 | 71 | |
|
89 | 72 | connect(&sqpApp->networkController(), |
|
90 | 73 | SIGNAL(replyDownloadProgress(QUuid, std::shared_ptr<QNetworkRequest>, double)), |
|
91 | 74 | this, |
|
92 | 75 | SLOT(onReplyDownloadProgress(QUuid, std::shared_ptr<QNetworkRequest>, double))); |
|
93 | 76 | } |
|
94 | 77 | } |
|
95 | 78 | |
|
96 | 79 | std::shared_ptr<IDataProvider> AmdaProvider::clone() const |
|
97 | 80 | { |
|
98 | 81 | // No copy is made in the clone |
|
99 | 82 | return std::make_shared<AmdaProvider>(); |
|
100 | 83 | } |
|
101 | 84 | |
|
102 | 85 | void AmdaProvider::requestDataLoading(QUuid acqIdentifier, const DataProviderParameters ¶meters) |
|
103 | 86 | { |
|
104 | 87 | // NOTE: Try to use multithread if possible |
|
105 | 88 | const auto times = parameters.m_Times; |
|
106 | 89 | const auto data = parameters.m_Data; |
|
107 | 90 | for (const auto &dateTime : qAsConst(times)) { |
|
108 | 91 | qCDebug(LOG_AmdaProvider()) << tr("TORM AmdaProvider::requestDataLoading ") << acqIdentifier |
|
109 | 92 | << dateTime; |
|
110 | 93 | this->retrieveData(acqIdentifier, dateTime, data); |
|
111 | 94 | |
|
112 | 95 | |
|
113 | 96 | // TORM when AMDA will support quick asynchrone request |
|
114 | 97 | QThread::msleep(1000); |
|
115 | 98 | } |
|
116 | 99 | } |
|
117 | 100 | |
|
118 | 101 | void AmdaProvider::requestDataAborting(QUuid acqIdentifier) |
|
119 | 102 | { |
|
120 | 103 | if (auto app = sqpApp) { |
|
121 | 104 | auto &networkController = app->networkController(); |
|
122 | 105 | networkController.onReplyCanceled(acqIdentifier); |
|
123 | 106 | } |
|
124 | 107 | } |
|
125 | 108 | |
|
126 | 109 | void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier, |
|
127 | 110 | std::shared_ptr<QNetworkRequest> networkRequest, |
|
128 | 111 | double progress) |
|
129 | 112 | { |
|
130 | 113 | qCDebug(LOG_AmdaProvider()) << tr("onReplyDownloadProgress") << acqIdentifier |
|
131 | 114 | << networkRequest.get() << progress; |
|
132 | 115 | auto acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier); |
|
133 | 116 | if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) { |
|
134 | 117 | |
|
135 | 118 | // Update the progression for the current request |
|
136 | 119 | auto requestPtr = networkRequest; |
|
137 | 120 | auto findRequest = [requestPtr](const auto &entry) { return requestPtr == entry.first; }; |
|
138 | 121 | |
|
139 | 122 | auto &requestProgressMap = acqIdToRequestProgressMapIt->second; |
|
140 | 123 | auto requestProgressMapEnd = requestProgressMap.end(); |
|
141 | 124 | auto requestProgressMapIt |
|
142 | 125 | = std::find_if(requestProgressMap.begin(), requestProgressMapEnd, findRequest); |
|
143 | 126 | |
|
144 | 127 | if (requestProgressMapIt != requestProgressMapEnd) { |
|
145 | 128 | requestProgressMapIt->second = progress; |
|
146 | 129 | } |
|
147 | 130 | else { |
|
148 | 131 | // This case can happened when a progression is send after the request has been |
|
149 | 132 | // finished. |
|
150 | 133 | // Generaly the case when aborting a request |
|
151 | 134 | qCDebug(LOG_AmdaProvider()) << tr("Can't retrieve Request in progress") << acqIdentifier |
|
152 | 135 | << networkRequest.get() << progress; |
|
153 | 136 | } |
|
154 | 137 | |
|
155 | 138 | // Compute the current final progress and notify it |
|
156 | 139 | double finalProgress = 0.0; |
|
157 | 140 | |
|
158 | 141 | auto fraq = requestProgressMap.size(); |
|
159 | 142 | |
|
160 | 143 | for (auto requestProgress : requestProgressMap) { |
|
161 | 144 | finalProgress += requestProgress.second; |
|
162 | 145 | qCDebug(LOG_AmdaProvider()) << tr("Current final progress without fraq:") |
|
163 | 146 | << finalProgress << requestProgress.second; |
|
164 | 147 | } |
|
165 | 148 | |
|
166 | 149 | if (fraq > 0) { |
|
167 | 150 | finalProgress = finalProgress / fraq; |
|
168 | 151 | } |
|
169 | 152 | |
|
170 | 153 | qCDebug(LOG_AmdaProvider()) << tr("Current final progress: ") << fraq << finalProgress; |
|
171 | 154 | emit dataProvidedProgress(acqIdentifier, finalProgress); |
|
172 | 155 | } |
|
173 | 156 | else { |
|
174 | 157 | // This case can happened when a progression is send after the request has been finished. |
|
175 | 158 | // Generaly the case when aborting a request |
|
176 | 159 | emit dataProvidedProgress(acqIdentifier, 100.0); |
|
177 | 160 | } |
|
178 | 161 | } |
|
179 | 162 | |
|
180 | 163 | void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVariantHash &data) |
|
181 | 164 | { |
|
182 | 165 | // Retrieves product ID from data: if the value is invalid, no request is made |
|
183 | 166 | auto productId = data.value(AMDA_XML_ID_KEY).toString(); |
|
184 | 167 | if (productId.isNull()) { |
|
185 | 168 | qCCritical(LOG_AmdaProvider()) << tr("Can't retrieve data: unknown product id"); |
|
186 | 169 | return; |
|
187 | 170 | } |
|
188 | 171 | |
|
189 | 172 | // Retrieves the data type that determines whether the expected format for the result file is |
|
190 | 173 | // scalar, vector... |
|
191 | 174 | auto productValueType = valueType(data.value(AMDA_DATA_TYPE_KEY).toString()); |
|
192 | 175 | |
|
193 | // Gets the server being queried to retrieve the product. It's then used to set the server URL | |
|
194 | auto productServer = data.value(AMDA_SERVER_KEY).toString(); | |
|
195 | ||
|
196 | 176 | // /////////// // |
|
197 | 177 | // Creates URL // |
|
198 | 178 | // /////////// // |
|
199 | 179 | |
|
200 | 180 | auto startDate = dateFormat(dateTime.m_TStart); |
|
201 | 181 | auto endDate = dateFormat(dateTime.m_TEnd); |
|
202 | 182 | |
|
203 | auto url = QUrl{ | |
|
204 | QString{AMDA_URL_FORMAT}.arg(serverURL(productServer), startDate, endDate, productId)}; | |
|
183 | QVariantHash urlProperties{{AMDA_SERVER_KEY, data.value(AMDA_SERVER_KEY)}}; | |
|
184 | auto url = QUrl{QString{AMDA_URL_FORMAT}.arg(AmdaServer::instance().url(urlProperties), | |
|
185 | startDate, endDate, productId)}; | |
|
205 | 186 | qCInfo(LOG_AmdaProvider()) << tr("TORM AmdaProvider::retrieveData url:") << url; |
|
206 | 187 | auto tempFile = std::make_shared<QTemporaryFile>(); |
|
207 | 188 | |
|
208 | 189 | // LAMBDA |
|
209 | 190 | auto httpDownloadFinished = [this, dateTime, tempFile, |
|
210 | 191 | productValueType](QNetworkReply *reply, QUuid dataId) noexcept { |
|
211 | 192 | |
|
212 | 193 | // Don't do anything if the reply was abort |
|
213 | 194 | if (reply->error() == QNetworkReply::NoError) { |
|
214 | 195 | |
|
215 | 196 | if (tempFile) { |
|
216 | 197 | auto replyReadAll = reply->readAll(); |
|
217 | 198 | if (!replyReadAll.isEmpty()) { |
|
218 | 199 | tempFile->write(replyReadAll); |
|
219 | 200 | } |
|
220 | 201 | tempFile->close(); |
|
221 | 202 | |
|
222 | 203 | // Parse results file |
|
223 | 204 | if (auto dataSeries |
|
224 | 205 | = AmdaResultParser::readTxt(tempFile->fileName(), productValueType)) { |
|
225 | 206 | emit dataProvided(dataId, dataSeries, dateTime); |
|
226 | 207 | } |
|
227 | 208 | else { |
|
228 | 209 | /// @todo ALX : debug |
|
229 | 210 | emit dataProvidedFailed(dataId); |
|
230 | 211 | } |
|
231 | 212 | } |
|
232 | 213 | m_AcqIdToRequestProgressMap.erase(dataId); |
|
233 | 214 | } |
|
234 | 215 | else { |
|
235 | 216 | qCCritical(LOG_AmdaProvider()) << tr("httpDownloadFinished ERROR"); |
|
236 | 217 | emit dataProvidedFailed(dataId); |
|
237 | 218 | } |
|
238 | 219 | |
|
239 | 220 | }; |
|
240 | 221 | auto httpFinishedLambda |
|
241 | 222 | = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, QUuid dataId) noexcept { |
|
242 | 223 | |
|
243 | 224 | // Don't do anything if the reply was abort |
|
244 | 225 | if (reply->error() == QNetworkReply::NoError) { |
|
245 | 226 | auto downloadFileUrl = QUrl{QString{reply->readAll()}.trimmed()}; |
|
246 | 227 | |
|
247 | 228 | qCInfo(LOG_AmdaProvider()) |
|
248 | 229 | << tr("TORM AmdaProvider::retrieveData downloadFileUrl:") << downloadFileUrl; |
|
249 | 230 | // Executes request for downloading file // |
|
250 | 231 | |
|
251 | 232 | // Creates destination file |
|
252 | 233 | if (tempFile->open()) { |
|
253 | 234 | // Executes request and store the request for progression |
|
254 | 235 | auto request = std::make_shared<QNetworkRequest>(downloadFileUrl); |
|
255 | 236 | updateRequestProgress(dataId, request, 0.0); |
|
256 | 237 | emit requestConstructed(request, dataId, httpDownloadFinished); |
|
257 | 238 | } |
|
258 | 239 | else { |
|
259 | 240 | emit dataProvidedFailed(dataId); |
|
260 | 241 | } |
|
261 | 242 | } |
|
262 | 243 | else { |
|
263 | 244 | qCCritical(LOG_AmdaProvider()) << tr("httpFinishedLambda ERROR"); |
|
264 | 245 | m_AcqIdToRequestProgressMap.erase(dataId); |
|
265 | 246 | emit dataProvidedFailed(dataId); |
|
266 | 247 | } |
|
267 | 248 | }; |
|
268 | 249 | |
|
269 | 250 | // //////////////// // |
|
270 | 251 | // Executes request // |
|
271 | 252 | // //////////////// // |
|
272 | 253 | |
|
273 | 254 | auto request = std::make_shared<QNetworkRequest>(url); |
|
274 | 255 | qCDebug(LOG_AmdaProvider()) << tr("First Request creation") << request.get(); |
|
275 | 256 | updateRequestProgress(token, request, 0.0); |
|
276 | 257 | |
|
277 | 258 | emit requestConstructed(request, token, httpFinishedLambda); |
|
278 | 259 | } |
|
279 | 260 | |
|
280 | 261 | void AmdaProvider::updateRequestProgress(QUuid acqIdentifier, |
|
281 | 262 | std::shared_ptr<QNetworkRequest> request, double progress) |
|
282 | 263 | { |
|
283 | 264 | qCDebug(LOG_AmdaProvider()) << tr("updateRequestProgress request") << request.get(); |
|
284 | 265 | auto acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier); |
|
285 | 266 | if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) { |
|
286 | 267 | auto &requestProgressMap = acqIdToRequestProgressMapIt->second; |
|
287 | 268 | auto requestProgressMapIt = requestProgressMap.find(request); |
|
288 | 269 | if (requestProgressMapIt != requestProgressMap.end()) { |
|
289 | 270 | requestProgressMapIt->second = progress; |
|
290 | 271 | qCDebug(LOG_AmdaProvider()) << tr("updateRequestProgress new progress for request") |
|
291 | 272 | << acqIdentifier << request.get() << progress; |
|
292 | 273 | } |
|
293 | 274 | else { |
|
294 | 275 | qCDebug(LOG_AmdaProvider()) << tr("updateRequestProgress new request") << acqIdentifier |
|
295 | 276 | << request.get() << progress; |
|
296 | 277 | acqIdToRequestProgressMapIt->second.insert(std::make_pair(request, progress)); |
|
297 | 278 | } |
|
298 | 279 | } |
|
299 | 280 | else { |
|
300 | 281 | qCDebug(LOG_AmdaProvider()) << tr("updateRequestProgress new acqIdentifier") |
|
301 | 282 | << acqIdentifier << request.get() << progress; |
|
302 | 283 | auto requestProgressMap = std::map<std::shared_ptr<QNetworkRequest>, double>{}; |
|
303 | 284 | requestProgressMap.insert(std::make_pair(request, progress)); |
|
304 | 285 | m_AcqIdToRequestProgressMap.insert( |
|
305 | 286 | std::make_pair(acqIdentifier, std::move(requestProgressMap))); |
|
306 | 287 | } |
|
307 | 288 | } |
@@ -1,42 +1,49 | |||
|
1 | 1 | #include "AmdaResultParserDefs.h" |
|
2 | 2 | |
|
3 | 3 | const QString END_TIME_PROPERTY = QStringLiteral("endTime"); |
|
4 | 4 | const QString FILL_VALUE_PROPERTY = QStringLiteral("fillValue"); |
|
5 | 5 | const QString MAX_BANDS_PROPERTY = QStringLiteral("maxBands"); |
|
6 | 6 | const QString MIN_BANDS_PROPERTY = QStringLiteral("minBands"); |
|
7 | 7 | const QString MAX_SAMPLING_PROPERTY = QStringLiteral("maxSampling"); |
|
8 | 8 | const QString MIN_SAMPLING_PROPERTY = QStringLiteral("minSampling"); |
|
9 | 9 | const QString START_TIME_PROPERTY = QStringLiteral("startTime"); |
|
10 | 10 | const QString X_AXIS_UNIT_PROPERTY = QStringLiteral("xAxisUnit"); |
|
11 | 11 | const QString Y_AXIS_UNIT_PROPERTY = QStringLiteral("yAxisUnit"); |
|
12 | 12 | const QString VALUES_UNIT_PROPERTY = QStringLiteral("valuesUnit"); |
|
13 | 13 | |
|
14 | namespace { | |
|
15 | ||
|
16 | const auto PARAMETER_UNITS_REGEX | |
|
17 | = QRegularExpression{QStringLiteral("\\s*PARAMETER_UNITS\\s*:\\s*(.*)")}; | |
|
18 | } | |
|
19 | ||
|
14 | 20 | const QRegularExpression DEFAULT_X_AXIS_UNIT_REGEX |
|
15 | 21 | = QRegularExpression{QStringLiteral("-\\s*Units\\s*:\\s*(.+?)\\s*-")}; |
|
16 | 22 | |
|
23 | const QRegularExpression ALTERNATIVE_X_AXIS_UNIT_REGEX = PARAMETER_UNITS_REGEX; | |
|
24 | ||
|
17 | 25 | const QRegularExpression SPECTROGRAM_END_TIME_REGEX |
|
18 | 26 | = QRegularExpression{QStringLiteral("\\s*INTERVAL_STOP\\s*:\\s*(.*)")}; |
|
19 | 27 | |
|
20 | 28 | const QRegularExpression SPECTROGRAM_FILL_VALUE_REGEX |
|
21 | 29 | = QRegularExpression{QStringLiteral("\\s*PARAMETER_FILL_VALUE\\s*:\\s*(.*)")}; |
|
22 | 30 | |
|
23 | 31 | const QRegularExpression SPECTROGRAM_MAX_BANDS_REGEX |
|
24 | 32 | = QRegularExpression{QStringLiteral("\\s*PARAMETER_TABLE_MAX_VALUES\\[0\\]\\s*:\\s*(.*)")}; |
|
25 | 33 | |
|
26 | 34 | const QRegularExpression SPECTROGRAM_MIN_BANDS_REGEX |
|
27 | 35 | = QRegularExpression{QStringLiteral("\\s*PARAMETER_TABLE_MIN_VALUES\\[0\\]\\s*:\\s*(.*)")}; |
|
28 | 36 | |
|
29 | 37 | const QRegularExpression SPECTROGRAM_MAX_SAMPLING_REGEX |
|
30 | 38 | = QRegularExpression{QStringLiteral("\\s*DATASET_MAX_SAMPLING\\s*:\\s*(.*)")}; |
|
31 | 39 | |
|
32 | 40 | const QRegularExpression SPECTROGRAM_MIN_SAMPLING_REGEX |
|
33 | 41 | = QRegularExpression{QStringLiteral("\\s*DATASET_MIN_SAMPLING\\s*:\\s*(.*)")}; |
|
34 | 42 | |
|
35 | 43 | const QRegularExpression SPECTROGRAM_START_TIME_REGEX |
|
36 | 44 | = QRegularExpression{QStringLiteral("\\s*INTERVAL_START\\s*:\\s*(.*)")}; |
|
37 | 45 | |
|
38 | 46 | const QRegularExpression SPECTROGRAM_Y_AXIS_UNIT_REGEX |
|
39 | 47 | = QRegularExpression{QStringLiteral("\\s*PARAMETER_TABLE_UNITS\\[0\\]\\s*:\\s*(.*)")}; |
|
40 | 48 | |
|
41 | const QRegularExpression SPECTROGRAM_VALUES_UNIT_REGEX | |
|
42 | = QRegularExpression{QStringLiteral("\\s*PARAMETER_UNITS\\s*:\\s*(.*)")}; | |
|
49 | const QRegularExpression SPECTROGRAM_VALUES_UNIT_REGEX = PARAMETER_UNITS_REGEX; |
@@ -1,423 +1,432 | |||
|
1 | 1 | #include "AmdaResultParserHelper.h" |
|
2 | 2 | |
|
3 | 3 | #include <Common/DateUtils.h> |
|
4 | 4 | #include <Common/SortUtils.h> |
|
5 | 5 | |
|
6 | 6 | #include <Data/DataSeriesUtils.h> |
|
7 | 7 | #include <Data/ScalarSeries.h> |
|
8 | 8 | #include <Data/SpectrogramSeries.h> |
|
9 | 9 | #include <Data/Unit.h> |
|
10 | 10 | #include <Data/VectorSeries.h> |
|
11 | 11 | |
|
12 | 12 | #include <QtCore/QDateTime> |
|
13 | 13 | #include <QtCore/QRegularExpression> |
|
14 | 14 | |
|
15 | 15 | #include <functional> |
|
16 | 16 | |
|
17 | 17 | Q_LOGGING_CATEGORY(LOG_AmdaResultParserHelper, "AmdaResultParserHelper") |
|
18 | 18 | |
|
19 | 19 | namespace { |
|
20 | 20 | |
|
21 | 21 | // ///////// // |
|
22 | 22 | // Constants // |
|
23 | 23 | // ///////// // |
|
24 | 24 | |
|
25 | 25 | /// Separator between values in a result line |
|
26 | 26 | const auto RESULT_LINE_SEPARATOR = QRegularExpression{QStringLiteral("\\s+")}; |
|
27 | 27 | |
|
28 | 28 | /// Format for dates in result files |
|
29 | 29 | const auto DATE_FORMAT = QStringLiteral("yyyy-MM-ddThh:mm:ss.zzz"); |
|
30 | 30 | |
|
31 | 31 | // /////// // |
|
32 | 32 | // Methods // |
|
33 | 33 | // /////// // |
|
34 | 34 | |
|
35 | 35 | /** |
|
36 | 36 | * Checks that the properties contain a specific unit and that this unit is valid |
|
37 | 37 | * @param properties the properties map in which to search unit |
|
38 | 38 | * @param key the key to search for the unit in the properties |
|
39 | 39 | * @param errorMessage the error message to log in case the unit is invalid |
|
40 | 40 | * @return true if the unit is valid, false it it's invalid or was not found in the properties |
|
41 | 41 | */ |
|
42 | 42 | bool checkUnit(const Properties &properties, const QString &key, const QString &errorMessage) |
|
43 | 43 | { |
|
44 | 44 | auto unit = properties.value(key).value<Unit>(); |
|
45 | 45 | if (unit.m_Name.isEmpty()) { |
|
46 | 46 | qCWarning(LOG_AmdaResultParserHelper()) << errorMessage; |
|
47 | 47 | return false; |
|
48 | 48 | } |
|
49 | 49 | |
|
50 | 50 | return true; |
|
51 | 51 | } |
|
52 | 52 | |
|
53 | 53 | QDateTime dateTimeFromString(const QString &stringDate) noexcept |
|
54 | 54 | { |
|
55 | 55 | #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) |
|
56 | 56 | return QDateTime::fromString(stringDate, Qt::ISODateWithMs); |
|
57 | 57 | #else |
|
58 | 58 | return QDateTime::fromString(stringDate, DATE_FORMAT); |
|
59 | 59 | #endif |
|
60 | 60 | } |
|
61 | 61 | |
|
62 | 62 | /// Converts a string date to a double date |
|
63 | 63 | /// @return a double that represents the date in seconds, NaN if the string date can't be converted |
|
64 | 64 | double doubleDate(const QString &stringDate) noexcept |
|
65 | 65 | { |
|
66 | 66 | // Format: yyyy-MM-ddThh:mm:ss.zzz |
|
67 | 67 | auto dateTime = dateTimeFromString(stringDate); |
|
68 | 68 | dateTime.setTimeSpec(Qt::UTC); |
|
69 | 69 | return dateTime.isValid() ? DateUtils::secondsSinceEpoch(dateTime) |
|
70 | 70 | : std::numeric_limits<double>::quiet_NaN(); |
|
71 | 71 | } |
|
72 | 72 | |
|
73 | 73 | /** |
|
74 | 74 | * Reads a line from the AMDA file and tries to extract a x-axis data and value data from it |
|
75 | 75 | * @param xAxisData the vector in which to store the x-axis data extracted |
|
76 | 76 | * @param valuesData the vector in which to store the value extracted |
|
77 | 77 | * @param line the line to read to extract the property |
|
78 | 78 | * @param valuesIndexes indexes of insertion of read values. For example, if the line contains three |
|
79 | 79 | * columns of values, and valuesIndexes are {2, 0, 1}, the value of the third column will be read |
|
80 | 80 | * and inserted first, then the value of the first column, and finally the value of the second |
|
81 | 81 | * column. |
|
82 | 82 | * @param fillValue value that tags an invalid data. For example, if fillValue is -1 and a read |
|
83 | 83 | * value is -1, then this value is considered as invalid and converted to NaN |
|
84 | 84 | */ |
|
85 | 85 | void tryReadResult(std::vector<double> &xAxisData, std::vector<double> &valuesData, |
|
86 | 86 | const QString &line, const std::vector<int> &valuesIndexes, |
|
87 | 87 | double fillValue = std::numeric_limits<double>::quiet_NaN()) |
|
88 | 88 | { |
|
89 | 89 | auto lineData = line.split(RESULT_LINE_SEPARATOR, QString::SkipEmptyParts); |
|
90 | 90 | |
|
91 | 91 | // Checks that the line contains expected number of values + x-axis value |
|
92 | 92 | if (static_cast<size_t>(lineData.size()) == valuesIndexes.size() + 1) { |
|
93 | 93 | // X : the data is converted from date to double (in secs) |
|
94 | 94 | auto x = doubleDate(lineData.at(0)); |
|
95 | 95 | |
|
96 | 96 | // Adds result only if x is valid. Then, if value is invalid, it is set to NaN |
|
97 | 97 | if (!std::isnan(x)) { |
|
98 | 98 | xAxisData.push_back(x); |
|
99 | 99 | |
|
100 | 100 | // Values |
|
101 | 101 | for (auto valueIndex : valuesIndexes) { |
|
102 | 102 | bool valueOk; |
|
103 | 103 | // we use valueIndex + 1 to skip column 0 (x-axis value) |
|
104 | 104 | auto value = lineData.at(valueIndex + 1).toDouble(&valueOk); |
|
105 | 105 | |
|
106 | 106 | if (!valueOk) { |
|
107 | 107 | qCWarning(LOG_AmdaResultParserHelper()) |
|
108 | 108 | << QObject::tr( |
|
109 | 109 | "Value from (line %1, column %2) is invalid and will be " |
|
110 | 110 | "converted to NaN") |
|
111 | 111 | .arg(line, valueIndex); |
|
112 | 112 | value = std::numeric_limits<double>::quiet_NaN(); |
|
113 | 113 | } |
|
114 | 114 | |
|
115 | 115 | // Handles fill value |
|
116 | 116 | if (!std::isnan(fillValue) && !std::isnan(value) && fillValue == value) { |
|
117 | 117 | value = std::numeric_limits<double>::quiet_NaN(); |
|
118 | 118 | } |
|
119 | 119 | |
|
120 | 120 | valuesData.push_back(value); |
|
121 | 121 | } |
|
122 | 122 | } |
|
123 | 123 | else { |
|
124 | 124 | qCWarning(LOG_AmdaResultParserHelper()) |
|
125 | 125 | << QObject::tr("Can't retrieve results from line %1: x is invalid").arg(line); |
|
126 | 126 | } |
|
127 | 127 | } |
|
128 | 128 | else { |
|
129 | 129 | qCWarning(LOG_AmdaResultParserHelper()) |
|
130 | 130 | << QObject::tr("Can't retrieve results from line %1: invalid line").arg(line); |
|
131 | 131 | } |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | /** |
|
135 | 135 | * Reads a line from the AMDA file and tries to extract a property from it |
|
136 | 136 | * @param properties the properties map in which to put the property extracted from the line |
|
137 | 137 | * @param key the key to which the property is added in the properties map |
|
138 | 138 | * @param line the line to read to extract the property |
|
139 |
* @param regex the expected regex to extract the property. If the line matches |
|
|
139 | * @param regexes the expected regexes to extract the property. If the line matches one regex, the | |
|
140 | 140 | * property is generated |
|
141 | 141 | * @param fun the function used to generate the property |
|
142 | 142 | * @return true if the property could be generated, false if the line does not match the regex, or |
|
143 | 143 | * if a property has already been generated for the key |
|
144 | 144 | */ |
|
145 | 145 | template <typename GeneratePropertyFun> |
|
146 | 146 | bool tryReadProperty(Properties &properties, const QString &key, const QString &line, |
|
147 | const QRegularExpression ®ex, GeneratePropertyFun fun) | |
|
147 | const std::vector<QRegularExpression> ®exes, GeneratePropertyFun fun) | |
|
148 | 148 | { |
|
149 | 149 | if (properties.contains(key)) { |
|
150 | 150 | return false; |
|
151 | 151 | } |
|
152 | 152 | |
|
153 | auto match = regex.match(line); | |
|
154 | if (match.hasMatch()) { | |
|
155 | properties.insert(key, fun(match)); | |
|
153 | // Searches for a match among all possible regexes | |
|
154 | auto hasMatch = false; | |
|
155 | for (auto regexIt = regexes.cbegin(), end = regexes.cend(); regexIt != end && !hasMatch; | |
|
156 | ++regexIt) { | |
|
157 | auto match = regexIt->match(line); | |
|
158 | auto hasMatch = match.hasMatch(); | |
|
159 | if (hasMatch) { | |
|
160 | properties.insert(key, fun(match)); | |
|
161 | } | |
|
156 | 162 | } |
|
157 | 163 | |
|
158 |
return |
|
|
164 | return hasMatch; | |
|
159 | 165 | } |
|
160 | 166 | |
|
161 | 167 | /** |
|
162 | 168 | * Reads a line from the AMDA file and tries to extract a data from it. Date is converted to double |
|
163 | 169 | * @sa tryReadProperty() |
|
164 | 170 | */ |
|
165 | 171 | bool tryReadDate(Properties &properties, const QString &key, const QString &line, |
|
166 | const QRegularExpression ®ex, bool timeUnit = false) | |
|
172 | const std::vector<QRegularExpression> ®exes, bool timeUnit = false) | |
|
167 | 173 | { |
|
168 | return tryReadProperty(properties, key, line, regex, [timeUnit](const auto &match) { | |
|
174 | return tryReadProperty(properties, key, line, regexes, [timeUnit](const auto &match) { | |
|
169 | 175 | return QVariant::fromValue(doubleDate(match.captured(1))); |
|
170 | 176 | }); |
|
171 | 177 | } |
|
172 | 178 | |
|
173 | 179 | /** |
|
174 | 180 | * Reads a line from the AMDA file and tries to extract a double from it |
|
175 | 181 | * @sa tryReadProperty() |
|
176 | 182 | */ |
|
177 | 183 | bool tryReadDouble(Properties &properties, const QString &key, const QString &line, |
|
178 | const QRegularExpression ®ex) | |
|
184 | const std::vector<QRegularExpression> ®exes) | |
|
179 | 185 | { |
|
180 | return tryReadProperty(properties, key, line, regex, [](const auto &match) { | |
|
186 | return tryReadProperty(properties, key, line, regexes, [](const auto &match) { | |
|
181 | 187 | bool ok; |
|
182 | 188 | |
|
183 | 189 | // If the value can't be converted to double, it is set to NaN |
|
184 | 190 | auto doubleValue = match.captured(1).toDouble(&ok); |
|
185 | 191 | if (!ok) { |
|
186 | 192 | doubleValue = std::numeric_limits<double>::quiet_NaN(); |
|
187 | 193 | } |
|
188 | 194 | |
|
189 | 195 | return QVariant::fromValue(doubleValue); |
|
190 | 196 | }); |
|
191 | 197 | } |
|
192 | 198 | |
|
193 | 199 | /** |
|
194 | 200 | * Reads a line from the AMDA file and tries to extract a vector of doubles from it |
|
195 | 201 | * @param sep the separator of double values in the line |
|
196 | 202 | * @sa tryReadProperty() |
|
197 | 203 | */ |
|
198 | 204 | bool tryReadDoubles(Properties &properties, const QString &key, const QString &line, |
|
199 |
const QRegularExpression ®ex, |
|
|
205 | const std::vector<QRegularExpression> ®exes, | |
|
206 | const QString &sep = QStringLiteral(",")) | |
|
200 | 207 | { |
|
201 | return tryReadProperty(properties, key, line, regex, [sep](const auto &match) { | |
|
208 | return tryReadProperty(properties, key, line, regexes, [sep](const auto &match) { | |
|
202 | 209 | std::vector<double> doubleValues{}; |
|
203 | 210 | |
|
204 | 211 | // If the value can't be converted to double, it is set to NaN |
|
205 | 212 | auto values = match.captured(1).split(sep); |
|
206 | 213 | for (auto value : values) { |
|
207 | 214 | bool ok; |
|
208 | 215 | |
|
209 | 216 | auto doubleValue = value.toDouble(&ok); |
|
210 | 217 | if (!ok) { |
|
211 | 218 | doubleValue = std::numeric_limits<double>::quiet_NaN(); |
|
212 | 219 | } |
|
213 | 220 | |
|
214 | 221 | doubleValues.push_back(doubleValue); |
|
215 | 222 | } |
|
216 | 223 | |
|
217 | 224 | return QVariant::fromValue(doubleValues); |
|
218 | 225 | }); |
|
219 | 226 | } |
|
220 | 227 | |
|
221 | 228 | /** |
|
222 | 229 | * Reads a line from the AMDA file and tries to extract a unit from it |
|
223 | 230 | * @sa tryReadProperty() |
|
224 | 231 | */ |
|
225 | 232 | bool tryReadUnit(Properties &properties, const QString &key, const QString &line, |
|
226 | const QRegularExpression ®ex, bool timeUnit = false) | |
|
233 | const std::vector<QRegularExpression> ®exes, bool timeUnit = false) | |
|
227 | 234 | { |
|
228 | return tryReadProperty(properties, key, line, regex, [timeUnit](const auto &match) { | |
|
235 | return tryReadProperty(properties, key, line, regexes, [timeUnit](const auto &match) { | |
|
229 | 236 | return QVariant::fromValue(Unit{match.captured(1), timeUnit}); |
|
230 | 237 | }); |
|
231 | 238 | } |
|
232 | 239 | |
|
233 | 240 | } // namespace |
|
234 | 241 | |
|
235 | 242 | // ////////////////// // |
|
236 | 243 | // ScalarParserHelper // |
|
237 | 244 | // ////////////////// // |
|
238 | 245 | |
|
239 | 246 | bool ScalarParserHelper::checkProperties() |
|
240 | 247 | { |
|
241 | 248 | return checkUnit(m_Properties, X_AXIS_UNIT_PROPERTY, |
|
242 | 249 | QObject::tr("The x-axis unit could not be found in the file")); |
|
243 | 250 | } |
|
244 | 251 | |
|
245 | 252 | std::shared_ptr<IDataSeries> ScalarParserHelper::createSeries() |
|
246 | 253 | { |
|
247 | 254 | return std::make_shared<ScalarSeries>(std::move(m_XAxisData), std::move(m_ValuesData), |
|
248 | 255 | m_Properties.value(X_AXIS_UNIT_PROPERTY).value<Unit>(), |
|
249 | 256 | m_Properties.value(VALUES_UNIT_PROPERTY).value<Unit>()); |
|
250 | 257 | } |
|
251 | 258 | |
|
252 | 259 | void ScalarParserHelper::readPropertyLine(const QString &line) |
|
253 | 260 | { |
|
254 |
tryReadUnit(m_Properties, X_AXIS_UNIT_PROPERTY, line, |
|
|
261 | tryReadUnit(m_Properties, X_AXIS_UNIT_PROPERTY, line, | |
|
262 | {DEFAULT_X_AXIS_UNIT_REGEX, ALTERNATIVE_X_AXIS_UNIT_REGEX}, true); | |
|
255 | 263 | } |
|
256 | 264 | |
|
257 | 265 | void ScalarParserHelper::readResultLine(const QString &line) |
|
258 | 266 | { |
|
259 | 267 | tryReadResult(m_XAxisData, m_ValuesData, line, valuesIndexes()); |
|
260 | 268 | } |
|
261 | 269 | |
|
262 | 270 | std::vector<int> ScalarParserHelper::valuesIndexes() const |
|
263 | 271 | { |
|
264 | 272 | // Only one value to read |
|
265 | 273 | static auto result = std::vector<int>{0}; |
|
266 | 274 | return result; |
|
267 | 275 | } |
|
268 | 276 | |
|
269 | 277 | // /////////////////////// // |
|
270 | 278 | // SpectrogramParserHelper // |
|
271 | 279 | // /////////////////////// // |
|
272 | 280 | |
|
273 | 281 | bool SpectrogramParserHelper::checkProperties() |
|
274 | 282 | { |
|
275 | 283 | // Generates y-axis data from bands extracted (take the middle of the intervals) |
|
276 | 284 | auto minBands = m_Properties.value(MIN_BANDS_PROPERTY).value<std::vector<double> >(); |
|
277 | 285 | auto maxBands = m_Properties.value(MAX_BANDS_PROPERTY).value<std::vector<double> >(); |
|
278 | 286 | |
|
279 | 287 | if (minBands.size() < 2 || minBands.size() != maxBands.size()) { |
|
280 | 288 | qCWarning(LOG_AmdaResultParserHelper()) << QObject::tr( |
|
281 | 289 | "Can't generate y-axis data from bands extracted: bands intervals are invalid"); |
|
282 | 290 | return false; |
|
283 | 291 | } |
|
284 | 292 | |
|
285 | 293 | std::transform( |
|
286 | 294 | minBands.begin(), minBands.end(), maxBands.begin(), std::back_inserter(m_YAxisData), |
|
287 | 295 | [](const auto &minValue, const auto &maxValue) { return (minValue + maxValue) / 2.; }); |
|
288 | 296 | |
|
289 | 297 | // Generates values indexes, i.e. the order in which each value will be retrieved (in ascending |
|
290 | 298 | // order of the associated bands) |
|
291 | 299 | m_ValuesIndexes = SortUtils::sortPermutation(m_YAxisData, std::less<double>()); |
|
292 | 300 | |
|
293 | 301 | // Sorts y-axis data accoding to the ascending order |
|
294 | 302 | m_YAxisData = SortUtils::sort(m_YAxisData, 1, m_ValuesIndexes); |
|
295 | 303 | |
|
296 | 304 | // Sets fill value |
|
297 | 305 | m_FillValue = m_Properties.value(FILL_VALUE_PROPERTY).value<double>(); |
|
298 | 306 | |
|
299 | 307 | return true; |
|
300 | 308 | } |
|
301 | 309 | |
|
302 | 310 | std::shared_ptr<IDataSeries> SpectrogramParserHelper::createSeries() |
|
303 | 311 | { |
|
304 | 312 | // Before creating the series, we handle its data holes |
|
305 | 313 | handleDataHoles(); |
|
306 | 314 | |
|
307 | 315 | return std::make_shared<SpectrogramSeries>( |
|
308 | 316 | std::move(m_XAxisData), std::move(m_YAxisData), std::move(m_ValuesData), |
|
309 | 317 | Unit{"t", true}, // x-axis unit is always a time unit |
|
310 | 318 | m_Properties.value(Y_AXIS_UNIT_PROPERTY).value<Unit>(), |
|
311 | 319 | m_Properties.value(VALUES_UNIT_PROPERTY).value<Unit>(), |
|
312 | 320 | m_Properties.value(MIN_SAMPLING_PROPERTY).value<double>()); |
|
313 | 321 | } |
|
314 | 322 | |
|
315 | 323 | void SpectrogramParserHelper::readPropertyLine(const QString &line) |
|
316 | 324 | { |
|
317 | 325 | // Set of functions to test on the line to generate a property. If a function is valid (i.e. a |
|
318 | 326 | // property has been generated for the line), the line is treated as processed and the other |
|
319 | 327 | // functions are not called |
|
320 | 328 | std::vector<std::function<bool()> > functions{ |
|
321 | 329 | // values unit |
|
322 | 330 | [&] { |
|
323 | 331 | return tryReadUnit(m_Properties, VALUES_UNIT_PROPERTY, line, |
|
324 | SPECTROGRAM_VALUES_UNIT_REGEX); | |
|
332 | {SPECTROGRAM_VALUES_UNIT_REGEX}); | |
|
325 | 333 | }, |
|
326 | 334 | // y-axis unit |
|
327 | 335 | [&] { |
|
328 | 336 | return tryReadUnit(m_Properties, Y_AXIS_UNIT_PROPERTY, line, |
|
329 | SPECTROGRAM_Y_AXIS_UNIT_REGEX); | |
|
337 | {SPECTROGRAM_Y_AXIS_UNIT_REGEX}); | |
|
330 | 338 | }, |
|
331 | 339 | // min sampling |
|
332 | 340 | [&] { |
|
333 | 341 | return tryReadDouble(m_Properties, MIN_SAMPLING_PROPERTY, line, |
|
334 | SPECTROGRAM_MIN_SAMPLING_REGEX); | |
|
342 | {SPECTROGRAM_MIN_SAMPLING_REGEX}); | |
|
335 | 343 | }, |
|
336 | 344 | // max sampling |
|
337 | 345 | [&] { |
|
338 | 346 | return tryReadDouble(m_Properties, MAX_SAMPLING_PROPERTY, line, |
|
339 | SPECTROGRAM_MAX_SAMPLING_REGEX); | |
|
347 | {SPECTROGRAM_MAX_SAMPLING_REGEX}); | |
|
340 | 348 | }, |
|
341 | 349 | // fill value |
|
342 | 350 | [&] { |
|
343 | 351 | return tryReadDouble(m_Properties, FILL_VALUE_PROPERTY, line, |
|
344 | SPECTROGRAM_FILL_VALUE_REGEX); | |
|
352 | {SPECTROGRAM_FILL_VALUE_REGEX}); | |
|
345 | 353 | }, |
|
346 | 354 | // min bounds of each band |
|
347 | 355 | [&] { |
|
348 | 356 | return tryReadDoubles(m_Properties, MIN_BANDS_PROPERTY, line, |
|
349 | SPECTROGRAM_MIN_BANDS_REGEX); | |
|
357 | {SPECTROGRAM_MIN_BANDS_REGEX}); | |
|
350 | 358 | }, |
|
351 | 359 | // max bounds of each band |
|
352 | 360 | [&] { |
|
353 | 361 | return tryReadDoubles(m_Properties, MAX_BANDS_PROPERTY, line, |
|
354 | SPECTROGRAM_MAX_BANDS_REGEX); | |
|
362 | {SPECTROGRAM_MAX_BANDS_REGEX}); | |
|
355 | 363 | }, |
|
356 | 364 | // start time of data |
|
357 | 365 | [&] { |
|
358 | 366 | return tryReadDate(m_Properties, START_TIME_PROPERTY, line, |
|
359 | SPECTROGRAM_START_TIME_REGEX); | |
|
367 | {SPECTROGRAM_START_TIME_REGEX}); | |
|
360 | 368 | }, |
|
361 | 369 | // end time of data |
|
362 | 370 | [&] { |
|
363 | return tryReadDate(m_Properties, END_TIME_PROPERTY, line, SPECTROGRAM_END_TIME_REGEX); | |
|
371 | return tryReadDate(m_Properties, END_TIME_PROPERTY, line, {SPECTROGRAM_END_TIME_REGEX}); | |
|
364 | 372 | }}; |
|
365 | 373 | |
|
366 | 374 | for (auto function : functions) { |
|
367 | 375 | // Stops at the first function that is valid |
|
368 | 376 | if (function()) { |
|
369 | 377 | return; |
|
370 | 378 | } |
|
371 | 379 | } |
|
372 | 380 | } |
|
373 | 381 | |
|
374 | 382 | void SpectrogramParserHelper::readResultLine(const QString &line) |
|
375 | 383 | { |
|
376 | 384 | tryReadResult(m_XAxisData, m_ValuesData, line, m_ValuesIndexes, m_FillValue); |
|
377 | 385 | } |
|
378 | 386 | |
|
379 | 387 | void SpectrogramParserHelper::handleDataHoles() |
|
380 | 388 | { |
|
381 | 389 | // Fills data holes according to the max resolution found in the AMDA file |
|
382 | 390 | auto resolution = m_Properties.value(MAX_SAMPLING_PROPERTY).value<double>(); |
|
383 | 391 | auto fillValue = m_Properties.value(FILL_VALUE_PROPERTY).value<double>(); |
|
384 | 392 | auto minBound = m_Properties.value(START_TIME_PROPERTY).value<double>(); |
|
385 | 393 | auto maxBound = m_Properties.value(END_TIME_PROPERTY).value<double>(); |
|
386 | 394 | |
|
387 | 395 | DataSeriesUtils::fillDataHoles(m_XAxisData, m_ValuesData, resolution, fillValue, minBound, |
|
388 | 396 | maxBound); |
|
389 | 397 | } |
|
390 | 398 | |
|
391 | 399 | // ////////////////// // |
|
392 | 400 | // VectorParserHelper // |
|
393 | 401 | // ////////////////// // |
|
394 | 402 | |
|
395 | 403 | bool VectorParserHelper::checkProperties() |
|
396 | 404 | { |
|
397 | 405 | return checkUnit(m_Properties, X_AXIS_UNIT_PROPERTY, |
|
398 | 406 | QObject::tr("The x-axis unit could not be found in the file")); |
|
399 | 407 | } |
|
400 | 408 | |
|
401 | 409 | std::shared_ptr<IDataSeries> VectorParserHelper::createSeries() |
|
402 | 410 | { |
|
403 | 411 | return std::make_shared<VectorSeries>(std::move(m_XAxisData), std::move(m_ValuesData), |
|
404 | 412 | m_Properties.value(X_AXIS_UNIT_PROPERTY).value<Unit>(), |
|
405 | 413 | m_Properties.value(VALUES_UNIT_PROPERTY).value<Unit>()); |
|
406 | 414 | } |
|
407 | 415 | |
|
408 | 416 | void VectorParserHelper::readPropertyLine(const QString &line) |
|
409 | 417 | { |
|
410 |
tryReadUnit(m_Properties, X_AXIS_UNIT_PROPERTY, line, |
|
|
418 | tryReadUnit(m_Properties, X_AXIS_UNIT_PROPERTY, line, | |
|
419 | {DEFAULT_X_AXIS_UNIT_REGEX, ALTERNATIVE_X_AXIS_UNIT_REGEX}, true); | |
|
411 | 420 | } |
|
412 | 421 | |
|
413 | 422 | void VectorParserHelper::readResultLine(const QString &line) |
|
414 | 423 | { |
|
415 | 424 | tryReadResult(m_XAxisData, m_ValuesData, line, valuesIndexes()); |
|
416 | 425 | } |
|
417 | 426 | |
|
418 | 427 | std::vector<int> VectorParserHelper::valuesIndexes() const |
|
419 | 428 | { |
|
420 | 429 | // 3 values to read, in order in the file (x, y, z) |
|
421 | 430 | static auto result = std::vector<int>{0, 1, 2}; |
|
422 | 431 | return result; |
|
423 | 432 | } |
General Comments 0
You need to be logged in to leave comments.
Login now