@@ -0,0 +1,29 | |||
|
1 | # - Try to find CatalogueAPI Module | |
|
2 | # Once done this will define | |
|
3 | # CATALOGUEAPI_FOUND - System has CatalogueAPI | |
|
4 | # CATALOGUEAPI_INCLUDE_DIRS - The CatalogueAPI include directories | |
|
5 | # CATALOGUEAPI_LIBRARIES - The libraries needed to use CatalogueAPI | |
|
6 | # CATALOGUEAPI_SHARED_LIBRARIES - The shared libraries for CatalogueAPI | |
|
7 | ||
|
8 | set(CATALOGUEAPI_ROOT_DIR "${CATALOGUEAPI_EXTERN_FOLDER}" | |
|
9 | CACHE PATHS | |
|
10 | "Path to the installation of CatalogueAPI" | |
|
11 | ${libRootDirForceValue}) | |
|
12 | ||
|
13 | find_path(CATALOGUEAPI_INCLUDE_DIR CatalogueDao.h | |
|
14 | HINTS ${CATALOGUEAPI_ROOT_DIR} ${CATALOGUEAPI_EXTERN_FOLDER} | |
|
15 | PATH_SUFFIXES src ) | |
|
16 | ||
|
17 | find_library(CATALOGUEAPI_LIBRARY NAMES CatalogueAPI | |
|
18 | HINTS ${CATALOGUEAPI_ROOT_DIR} ${CATALOGUEAPI_EXTERN_FOLDER} | |
|
19 | PATH_SUFFIXES lib) | |
|
20 | ||
|
21 | set(CATALOGUEAPI_LIBRARIES ${CATALOGUEAPI_LIBRARY} ) | |
|
22 | set(CATALOGUEAPI_INCLUDE_DIRS ${CATALOGUEAPI_INCLUDE_DIR} ) | |
|
23 | ||
|
24 | include(FindPackageHandleStandardArgs) | |
|
25 | # handle the QUIETLY and REQUIRED arguments and set CATALOGUEAPI_FOUND to TRUE | |
|
26 | # if all listed variables are TRUE | |
|
27 | find_package_handle_standard_args(CatalogueAPI FOUND_VAR CATALOGUEAPI_FOUND | |
|
28 | REQUIRED_VARS CATALOGUEAPI_LIBRARY CATALOGUEAPI_INCLUDE_DIR) | |
|
29 | mark_as_advanced(CATALOGUEAPI_INCLUDE_DIR CATALOGUEAPI_LIBRARY ) |
@@ -0,0 +1,51 | |||
|
1 | #ifndef SCIQLOP_CATALOGUECONTROLLER_H | |
|
2 | #define SCIQLOP_CATALOGUECONTROLLER_H | |
|
3 | ||
|
4 | #include "CoreGlobal.h" | |
|
5 | ||
|
6 | #include <Data/SqpRange.h> | |
|
7 | ||
|
8 | #include <QLoggingCategory> | |
|
9 | #include <QObject> | |
|
10 | #include <QUuid> | |
|
11 | ||
|
12 | #include <Common/spimpl.h> | |
|
13 | ||
|
14 | Q_DECLARE_LOGGING_CATEGORY(LOG_CatalogueController) | |
|
15 | ||
|
16 | class DataSourceItem; | |
|
17 | class Variable; | |
|
18 | ||
|
19 | /** | |
|
20 | * @brief The CatalogueController class aims to make the link between SciQlop and its plugins. | |
|
21 | * This is the intermediate class that SciQlop has to use in the way to connect a data source. | |
|
22 | * Please first use register method to initialize a plugin specified by its metadata name (JSON | |
|
23 | * plugin source) then others specifics method will be able to access it. You can load a data source | |
|
24 | * driver plugin then create a data source. | |
|
25 | */ | |
|
26 | class SCIQLOP_CORE_EXPORT CatalogueController : public QObject { | |
|
27 | Q_OBJECT | |
|
28 | public: | |
|
29 | explicit CatalogueController(QObject *parent = 0); | |
|
30 | virtual ~CatalogueController(); | |
|
31 | ||
|
32 | signals: | |
|
33 | /// Signal emitted when a variable is about to be deleted from SciQlop | |
|
34 | void variableAboutToBeDeleted(std::shared_ptr<Variable> variable); | |
|
35 | ||
|
36 | /// Signal emitted when a data acquisition is requested on a range for a variable | |
|
37 | void rangeChanged(std::shared_ptr<Variable> variable, const SqpRange &range); | |
|
38 | ||
|
39 | public slots: | |
|
40 | /// Manage init/end of the controller | |
|
41 | void initialize(); | |
|
42 | void finalize(); | |
|
43 | ||
|
44 | private: | |
|
45 | void waitForFinish(); | |
|
46 | ||
|
47 | class CatalogueControllerPrivate; | |
|
48 | spimpl::unique_impl_ptr<CatalogueControllerPrivate> impl; | |
|
49 | }; | |
|
50 | ||
|
51 | #endif // SCIQLOP_CATALOGUECONTROLLER_H |
@@ -0,0 +1,52 | |||
|
1 | #include <Catalogue/CatalogueController.h> | |
|
2 | ||
|
3 | #include <Variable/Variable.h> | |
|
4 | ||
|
5 | #include <CatalogueDao.h> | |
|
6 | ||
|
7 | #include <QMutex> | |
|
8 | #include <QThread> | |
|
9 | ||
|
10 | #include <QDir> | |
|
11 | #include <QStandardPaths> | |
|
12 | ||
|
13 | Q_LOGGING_CATEGORY(LOG_CatalogueController, "CatalogueController") | |
|
14 | ||
|
15 | class CatalogueController::CatalogueControllerPrivate { | |
|
16 | public: | |
|
17 | QMutex m_WorkingMutex; | |
|
18 | CatalogueDao m_CatalogueDao; | |
|
19 | }; | |
|
20 | ||
|
21 | CatalogueController::CatalogueController(QObject *parent) | |
|
22 | : impl{spimpl::make_unique_impl<CatalogueControllerPrivate>()} | |
|
23 | { | |
|
24 | qCDebug(LOG_CatalogueController()) << tr("CatalogueController construction") | |
|
25 | << QThread::currentThread(); | |
|
26 | } | |
|
27 | ||
|
28 | CatalogueController::~CatalogueController() | |
|
29 | { | |
|
30 | qCDebug(LOG_CatalogueController()) << tr("CatalogueController destruction") | |
|
31 | << QThread::currentThread(); | |
|
32 | this->waitForFinish(); | |
|
33 | } | |
|
34 | ||
|
35 | void CatalogueController::initialize() | |
|
36 | { | |
|
37 | qCDebug(LOG_CatalogueController()) << tr("CatalogueController init") | |
|
38 | << QThread::currentThread(); | |
|
39 | impl->m_WorkingMutex.lock(); | |
|
40 | impl->m_CatalogueDao.initialize(); | |
|
41 | qCDebug(LOG_CatalogueController()) << tr("CatalogueController init END"); | |
|
42 | } | |
|
43 | ||
|
44 | void CatalogueController::finalize() | |
|
45 | { | |
|
46 | impl->m_WorkingMutex.unlock(); | |
|
47 | } | |
|
48 | ||
|
49 | void CatalogueController::waitForFinish() | |
|
50 | { | |
|
51 | QMutexLocker locker{&impl->m_WorkingMutex}; | |
|
52 | } |
@@ -0,0 +1,73 | |||
|
1 | # - Clone and build CatalogueAPI Module | |
|
2 | include(ExternalProject) | |
|
3 | ||
|
4 | find_package(Git REQUIRED) | |
|
5 | ||
|
6 | if(WIN32) | |
|
7 | find_program(MesonExec meson PATHS C:/Appli/Meson) | |
|
8 | if(NOT MesonExec) | |
|
9 | Message("Error: Meson not found") | |
|
10 | else() | |
|
11 | message("Meson found: ${MesonExec}" ) | |
|
12 | endif() | |
|
13 | find_program(NinjaExec ninja PATHS C:/Appli/Meson) | |
|
14 | if(NOT NinjaExec) | |
|
15 | Message("Error: Ninja not found") | |
|
16 | else() | |
|
17 | message("Ninja found: ${NinjaExec}" ) | |
|
18 | endif() | |
|
19 | endif() | |
|
20 | if(NOT MesonExec) | |
|
21 | set (MesonExec meson) | |
|
22 | endif() | |
|
23 | if(NOT NinjaExec) | |
|
24 | set (NinjaExec ninja) | |
|
25 | endif() | |
|
26 | ||
|
27 | SET(CATALOGUEAPI_SOURCES_PATH ${CMAKE_SOURCE_DIR}/3rdparty/CatalogueAPI) | |
|
28 | SET(CATALOGUEAPI_BUILD_PATH ${CATALOGUEAPI_SOURCES_PATH}/build) | |
|
29 | SET(CATALOGUEAPI_QXORM_LIB_PATH ${CATALOGUEAPI_BUILD_PATH}/subprojects/QxOrm) | |
|
30 | SET(CatalogueAPI_build_type plain) | |
|
31 | ||
|
32 | if(CMAKE_BUILD_TYPE STREQUAL "") | |
|
33 | set(CMAKE_BUILD_TYPE Release) | |
|
34 | endif() | |
|
35 | string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) | |
|
36 | ||
|
37 | ExternalProject_Add( | |
|
38 | CatalogueAPI | |
|
39 | ||
|
40 | GIT_REPOSITORY https://perrinel@hephaistos.lpp.polytechnique.fr/rhodecode/GIT_REPOSITORIES/LPP/Users/mperrinel/CatalogueAPI | |
|
41 | GIT_TAG develop | |
|
42 | ||
|
43 | UPDATE_COMMAND ${GIT_EXECUTABLE} pull | |
|
44 | PATCH_COMMAND "" | |
|
45 | ||
|
46 | SOURCE_DIR "${CATALOGUEAPI_SOURCES_PATH}" | |
|
47 | CONFIGURE_COMMAND ${MesonExec} --prefix=${CATALOGUEAPI_SOURCES_PATH} --buildtype=${CMAKE_BUILD_TYPE_TOLOWER} "${CATALOGUEAPI_SOURCES_PATH}" "${CATALOGUEAPI_BUILD_PATH}" | |
|
48 | ||
|
49 | BUILD_COMMAND ${NinjaExec} -C "${CATALOGUEAPI_BUILD_PATH}" | |
|
50 | INSTALL_COMMAND ${NinjaExec} -C "${CATALOGUEAPI_BUILD_PATH}" install | |
|
51 | LOG_DOWNLOAD 1 | |
|
52 | LOG_UPDATE 1 | |
|
53 | ) | |
|
54 | ||
|
55 | set(CATALOG_LIB_PATH lib) | |
|
56 | if(WIN32) | |
|
57 | set(CATALOG_LIB_PATH bin) | |
|
58 | endif() | |
|
59 | ||
|
60 | ExternalProject_Add_Step( | |
|
61 | CatalogueAPI CopyToBin | |
|
62 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CATALOGUEAPI_SOURCES_PATH}/lib64 ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH} | |
|
63 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CATALOGUEAPI_QXORM_LIB_PATH} ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH} | |
|
64 | DEPENDEES install | |
|
65 | ) | |
|
66 | ||
|
67 | ||
|
68 | set(CATALOGUEAPI_INCLUDE ${CATALOGUEAPI_SOURCES_PATH}/src) | |
|
69 | set(CATALOGUEAPI_LIBRARIES ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}CatalogueAPI${CMAKE_SHARED_LIBRARY_SUFFIX}) | |
|
70 | list(APPEND CATALOGUEAPI_LIBRARIES ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}QxOrm${CMAKE_SHARED_LIBRARY_SUFFIX}) | |
|
71 | ||
|
72 | mark_as_advanced(CATALOGUEAPI_INCLUDE) | |
|
73 | mark_as_advanced(CATALOGUEAPI_LIBRARIES) |
@@ -0,0 +1,4 | |||
|
1 | [wrap-git] | |
|
2 | directory=CatalogueAPI | |
|
3 | url=https://hephaistos.lpp.polytechnique.fr/rhodecode/GIT_REPOSITORIES/LPP/Users/mperrinel/CatalogueAPI.git | |
|
4 | revision=head |
@@ -0,0 +1,5 | |||
|
1 | [wrap-git] | |
|
2 | directory=QxOrm | |
|
3 | url=https://github.com/jeandet/qxorm.git | |
|
4 | revision=head | |
|
5 |
@@ -1,5 +1,6 | |||
|
1 | 1 | build/ |
|
2 | 2 | CMakeLists.txt.user |
|
3 | 3 | /.project |
|
4 | 4 | core/src/Version.cpp |
|
5 | 5 | core/include/Version.h |
|
6 | 3rdparty/ |
@@ -1,12 +1,18 | |||
|
1 | 1 | ο»Ώ |
|
2 | 2 | |
|
3 | 3 | ## Main CMakeLists for SCIQLOP |
|
4 | 4 | CMAKE_MINIMUM_REQUIRED (VERSION 3.6.1) |
|
5 | 5 | cmake_policy(VERSION 3.6) |
|
6 | 6 | |
|
7 | 7 | PROJECT(SCIQLOP) |
|
8 | 8 | |
|
9 | ||
|
10 | # | |
|
11 | # build the CatalogueAPI dependencu | |
|
12 | # | |
|
13 | INCLUDE("extern/CatalogueAPI.cmake") | |
|
14 | ||
|
9 | 15 | # |
|
10 | 16 | # build the project |
|
11 | 17 | # |
|
12 | INCLUDE("cmake/sciqlop.cmake") No newline at end of file | |
|
18 | INCLUDE("cmake/sciqlop.cmake") |
@@ -1,36 +1,36 | |||
|
1 | 1 | STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TO_LOWER) |
|
2 | SET(WINDEPLOYQT_ARGS --${CMAKE_BUILD_TYPE_TO_LOWER} --list mapping --no-system-d3d-compiler --compiler-runtime --dry-run) | |
|
2 | SET(WINDEPLOYQT_ARGS --${CMAKE_BUILD_TYPE_TO_LOWER} --list mapping -network -sql --no-system-d3d-compiler --compiler-runtime --dry-run) | |
|
3 | 3 | |
|
4 | 4 | #FOREACH(qtModule @_qt5_modules@) |
|
5 | 5 | # STRING(TOLOWER ${qtModule} qtLowerModule) |
|
6 | 6 | # SET(WINDEPLOYQT_ARGS ${WINDEPLOYQT_ARGS} -${qtLowerModule}) |
|
7 | 7 | #ENDFOREACH() |
|
8 | 8 | |
|
9 | 9 | EXECUTE_PROCESS( |
|
10 | 10 | COMMAND windeployqt ${WINDEPLOYQT_ARGS} -printsupport ${SCIQLOP_EXE_LOCATION} |
|
11 | 11 | OUTPUT_VARIABLE QT_FILES |
|
12 | 12 | ) |
|
13 | 13 | |
|
14 | 14 | IF( QT_FILES ) |
|
15 | 15 | |
|
16 | 16 | STRING(REPLACE "\n" ";" QT_FILES ${QT_FILES}) |
|
17 | 17 | LIST(APPEND QT_FILES_LIST ${QT_FILES}) |
|
18 | 18 | FOREACH(QtFile ${QT_FILES_LIST}) |
|
19 | 19 | STRING(REPLACE "\"" "" QtFile ${QtFile}) |
|
20 | 20 | STRING(REPLACE "\\" "/" QtFile ${QtFile}) |
|
21 | 21 | STRING(REGEX MATCH "^(.*) " QtFileSource ${QtFile}) |
|
22 | 22 | STRING(REGEX MATCH " (.*)$" QtFileTarget ${QtFile}) |
|
23 | 23 | |
|
24 | 24 | STRING(STRIP ${QtFileSource} QtFileSource) |
|
25 | 25 | STRING(STRIP ${QtFileTarget} QtFileTarget) |
|
26 | 26 | GET_FILENAME_COMPONENT(QtFileTargetDir ${QtFileTarget} DIRECTORY) |
|
27 | 27 | |
|
28 | 28 | IF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/${EXECUTABLE_OUTPUT_PATH}/${QtFileTarget}") |
|
29 | 29 | GET_FILENAME_COMPONENT(QtFileTargetDir ${QtFileTarget} DIRECTORY) |
|
30 | 30 | FILE(INSTALL DESTINATION "${EXECUTABLE_OUTPUT_PATH}/${QtFileTargetDir}" FILES "${QtFileSource}") |
|
31 | 31 | ENDIF() |
|
32 | 32 | ENDFOREACH() |
|
33 | 33 | |
|
34 | 34 | ENDIF() |
|
35 | 35 | |
|
36 | 36 | MESSAGE( "Exec windeployqt done" ) |
@@ -1,159 +1,173 | |||
|
1 | ||
|
2 | 1 | ## core - CMakeLists.txt |
|
3 | 2 | STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX) |
|
4 | 3 | SET(SQPCORE_LIBRARY_NAME "${LIBRARY_PREFFIX}_core${DEBUG_SUFFIX}") |
|
5 | 4 | SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/") |
|
6 | 5 | SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/") |
|
7 | 6 | SET(TESTS_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests-resources") |
|
8 | 7 | |
|
9 | 8 | # Include core directory |
|
10 | 9 | include_directories("${INCLUDES_DIR}") |
|
11 | 10 | |
|
12 | 11 | # Set a variable to display a warning in the version files. |
|
13 | 12 | SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.") |
|
14 | 13 | # Generate the version file from the cmake version variables. The version |
|
15 | 14 | # variables are defined in the cmake/sciqlop_version.cmake file. |
|
16 | 15 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.h.in" |
|
17 | 16 | "${INCLUDES_DIR}/Version.h") |
|
18 | 17 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.cpp.in" |
|
19 | 18 | "${SOURCES_DIR}/Version.cpp") |
|
20 | 19 | |
|
21 | 20 | # Find dependent modules |
|
22 | 21 | find_package(sciqlop-plugin) |
|
23 | 22 | INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR}) |
|
24 | 23 | |
|
25 | 24 | # |
|
26 | 25 | # Find Qt modules |
|
27 | 26 | # |
|
28 | 27 | SCIQLOP_FIND_QT(Core Network) |
|
29 | 28 | |
|
30 | 29 | # |
|
31 | 30 | # Compile the library library |
|
32 | 31 | # |
|
33 | 32 | |
|
34 | 33 | ADD_DEFINITIONS(-DCORE_LIB) |
|
35 | 34 | |
|
36 | 35 | FILE (GLOB_RECURSE MODULE_SOURCES |
|
37 | 36 | ${INCLUDES_DIR}/*.h |
|
38 | 37 | ${SOURCES_DIR}/*.c |
|
39 | 38 | ${SOURCES_DIR}/*.cpp |
|
40 | 39 | ${SOURCES_DIR}/*.h) |
|
41 | 40 | |
|
42 | 41 | ADD_LIBRARY(${SQPCORE_LIBRARY_NAME} ${MODULE_SOURCES}) |
|
43 | 42 | set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD 14) |
|
44 | 43 | set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) |
|
45 | 44 | TARGET_LINK_LIBRARIES(${SQPCORE_LIBRARY_NAME}) |
|
46 | 45 | qt5_use_modules(${SQPCORE_LIBRARY_NAME} Core Network) |
|
47 | 46 | |
|
47 | # Find CATALOGUE_API | |
|
48 | include_directories("${CATALOGUEAPI_INCLUDE}") | |
|
49 | TARGET_LINK_LIBRARIES(${SQPCORE_LIBRARY_NAME} ${CATALOGUEAPI_LIBRARIES}) | |
|
48 | 50 | INSTALL(TARGETS ${SQPCORE_LIBRARY_NAME} |
|
49 | 51 | RUNTIME DESTINATION ${INSTALL_BINARY_DIR} |
|
50 | 52 | LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} |
|
51 | 53 | ARCHIVE DESTINATION ${INSTALL_LIBRARY_DIR} |
|
52 | 54 | ) |
|
53 | 55 | |
|
56 | add_dependencies(${SQPCORE_LIBRARY_NAME} CatalogueAPI) | |
|
57 | ||
|
54 | 58 | # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html |
|
55 | 59 | # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order. |
|
56 | 60 | # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets |
|
57 | 61 | IF(BUILD_SHARED_LIBS) |
|
58 | 62 | SET_TARGET_PROPERTIES(${SQPCORE_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT") |
|
59 | 63 | ELSE() |
|
60 | 64 | TARGET_COMPILE_DEFINITIONS(${SQPCORE_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES") |
|
61 | 65 | ENDIF() |
|
62 | 66 | |
|
63 | 67 | # Set the variable to parent scope so that the other projects can copy the |
|
64 | 68 | # dependent shared libraries |
|
65 | 69 | SCIQLOP_SET_TO_PARENT_SCOPE(SQPCORE_LIBRARY_NAME) |
|
66 | 70 | |
|
67 | # Copy extern shared libraries to the lib folder | |
|
68 | SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPCORE_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES}) | |
|
69 | ||
|
71 | ## Copy extern shared libraries to the lib folder | |
|
72 | LIST (APPEND ${EXTERN_SHARED_LIBRARIES} ${CATALOGUEAPI_LIBRARIES}) | |
|
73 | ||
|
74 | ||
|
75 | SET (COPY_LIBS_DESTINATION LIBRARY) | |
|
76 | if(APPLE) | |
|
77 | SET (COPY_LIBS_DESTINATION RUNTIME) | |
|
78 | endif() | |
|
79 | ||
|
80 | add_custom_command(TARGET ${SQPCORE_LIBRARY_NAME} POST_BUILD | |
|
81 | COMMAND ${CMAKE_COMMAND} -E copy ${CATALOGUEAPI_LIBRARIES} ${EXECUTABLE_OUTPUT_PATH} | |
|
82 | ) | |
|
83 | ||
|
70 | 84 | # Add the files to the list of files to be analyzed |
|
71 | 85 | LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES}) |
|
72 | 86 | SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES) |
|
73 | 87 | # Vera++ exclusion files |
|
74 | 88 | LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt) |
|
75 | 89 | SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) |
|
76 | 90 | |
|
77 | 91 | # |
|
78 | 92 | # Compile the tests |
|
79 | 93 | # |
|
80 | 94 | IF(BUILD_TESTS) |
|
81 | 95 | INCLUDE_DIRECTORIES(${SOURCES_DIR}) |
|
82 | 96 | FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp) |
|
83 | 97 | FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h) |
|
84 | 98 | SET( TEST_LIBRARIES ${SQPCORE_LIBRARY_NAME}) |
|
99 | list(APPEND TEST_LIBRARIES ${CATALOGUEAPI_LIBRARIES}) | |
|
85 | 100 | |
|
86 | 101 | SET(TARGETS_COV) |
|
87 | 102 | FOREACH( testFile ${TESTS_SOURCES} ) |
|
88 | 103 | GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) |
|
89 | 104 | GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE ) |
|
90 | 105 | |
|
91 | 106 | # Add to the list of sources files all the sources in the same |
|
92 | 107 | # directory that aren't another test |
|
93 | 108 | FILE (GLOB currentTestSources |
|
94 | 109 | ${testDirectory}/*.c |
|
95 | 110 | ${testDirectory}/*.cpp |
|
96 | 111 | ${testDirectory}/*.h) |
|
97 | 112 | LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES}) |
|
98 | 113 | # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS}) |
|
99 | 114 | |
|
100 | 115 | ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) |
|
101 | 116 | set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14) |
|
102 | 117 | set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON) |
|
103 |
TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} |
|
|
118 | TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES}) | |
|
104 | 119 | qt5_use_modules(${testName} Test) |
|
105 | 120 | |
|
106 | 121 | ADD_TEST( NAME ${testName} COMMAND ${testName} ) |
|
107 | 122 | |
|
108 | SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES}) | |
|
109 | 123 | set(Coverage_NAME ${testName}) |
|
110 | 124 | if(UNIX) |
|
111 | 125 | SETUP_TARGET_FOR_COVERAGE(TARGET ${testName}_coverage OUTPUT ${testFile}-path NAME ${testFile} EXECUTABLE ${testName}) |
|
112 | 126 | LIST( APPEND TARGETS_COV ${testName}_coverage) |
|
113 | 127 | endif(UNIX) |
|
114 | 128 | |
|
115 | 129 | ENDFOREACH( testFile ) |
|
116 | 130 | |
|
117 | 131 | add_custom_target(coverage) |
|
118 | 132 | |
|
119 | 133 | FOREACH( target_cov ${TARGETS_COV} ) |
|
120 | 134 | add_custom_command(TARGET coverage PRE_BUILD COMMAND make ${target_cov}) |
|
121 | 135 | ENDFOREACH( target_cov ) |
|
122 | 136 | |
|
123 | 137 | LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) |
|
124 | 138 | LIST(APPEND testFilesToFormat ${TESTS_HEADERS}) |
|
125 | 139 | LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat}) |
|
126 | 140 | SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) |
|
127 | 141 | |
|
128 | 142 | ADD_DEFINITIONS(-DCORE_TESTS_RESOURCES_DIR="${TESTS_RESOURCES_DIR}") |
|
129 | 143 | ENDIF(BUILD_TESTS) |
|
130 | 144 | |
|
131 | 145 | # |
|
132 | 146 | # Set the files that must be formatted by clang-format. |
|
133 | 147 | # |
|
134 | 148 | LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES}) |
|
135 | 149 | SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) |
|
136 | 150 | |
|
137 | 151 | # |
|
138 | 152 | # Set the directories that doxygen must browse to generate the |
|
139 | 153 | # documentation. |
|
140 | 154 | # |
|
141 | 155 | # Source directories: |
|
142 | 156 | LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs") |
|
143 | 157 | LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") |
|
144 | 158 | SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS) |
|
145 | 159 | # Source directories to exclude from the documentation generation |
|
146 | 160 | #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*") |
|
147 | 161 | SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS) |
|
148 | 162 | |
|
149 | 163 | # |
|
150 | 164 | # Set the directories with the sources to analyze and propagate the |
|
151 | 165 | # modification to the parent scope |
|
152 | 166 | # |
|
153 | 167 | # Source directories to analyze: |
|
154 | 168 | LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") |
|
155 | 169 | LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests") |
|
156 | 170 | SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS) |
|
157 | 171 | # Source directories to exclude from the analysis |
|
158 | 172 | #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir") |
|
159 | 173 | SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS) |
@@ -1,66 +1,73 | |||
|
1 | 1 | |
|
2 | qxorm_dep = dependency('QxOrm', required : true, fallback:['QxOrm','qxorm_dep']) | |
|
3 | catalogueapi_dep = dependency('CatalogueAPI', required : true, fallback:['CatalogueAPI','CatalogueAPI_dep']) | |
|
4 | ||
|
5 | ||
|
2 | 6 | core_moc_headers = [ |
|
7 | 'include/Catalogue/CatalogueController.h', | |
|
3 | 8 | 'include/Data/IDataProvider.h', |
|
4 | 9 | 'include/DataSource/DataSourceController.h', |
|
5 | 10 | 'include/DataSource/DataSourceItemAction.h', |
|
6 | 11 | 'include/Network/NetworkController.h', |
|
7 | 12 | 'include/Time/TimeController.h', |
|
8 | 13 | 'include/Variable/Variable.h', |
|
9 | 14 | 'include/Variable/VariableCacheController.h', |
|
10 | 15 | 'include/Variable/VariableController.h', |
|
11 | 16 | 'include/Variable/VariableAcquisitionWorker.h', |
|
12 | 17 | 'include/Variable/VariableSynchronizationGroup.h', |
|
13 | 18 | 'include/Variable/VariableModel.h', |
|
14 | 19 | 'include/Visualization/VisualizationController.h' |
|
15 | 20 | ] |
|
16 | 21 | |
|
17 | 22 | |
|
18 | 23 | core_moc_files = qt5.preprocess(moc_headers : core_moc_headers) |
|
19 | 24 | |
|
20 | 25 | core_sources = [ |
|
21 | 26 | 'src/Common/DateUtils.cpp', |
|
22 | 27 | 'src/Common/StringUtils.cpp', |
|
23 | 28 | 'src/Common/MimeTypesDef.cpp', |
|
29 | 'src/Catalogue/CatalogueController.cpp', | |
|
24 | 30 | 'src/Data/ScalarSeries.cpp', |
|
25 | 31 | 'src/Data/SpectrogramSeries.cpp', |
|
26 | 32 | 'src/Data/DataSeriesIterator.cpp', |
|
27 | 33 | 'src/Data/ArrayDataIterator.cpp', |
|
28 | 34 | 'src/Data/VectorSeries.cpp', |
|
29 | 35 | 'src/Data/OptionalAxis.cpp', |
|
30 | 36 | 'src/Data/DataSeriesUtils.cpp', |
|
31 | 37 | 'src/DataSource/DataSourceController.cpp', |
|
32 | 38 | 'src/DataSource/DataSourceItem.cpp', |
|
33 | 39 | 'src/DataSource/DataSourceItemAction.cpp', |
|
34 | 40 | 'src/DataSource/DataSourceItemMergeHelper.cpp', |
|
35 | 41 | 'src/Network/NetworkController.cpp', |
|
36 | 42 | 'src/Plugin/PluginManager.cpp', |
|
37 | 43 | 'src/Settings/SqpSettingsDefs.cpp', |
|
38 | 44 | 'src/Time/TimeController.cpp', |
|
39 | 45 | 'src/Variable/Variable.cpp', |
|
40 | 46 | 'src/Variable/VariableCacheController.cpp', |
|
41 | 47 | 'src/Variable/VariableController.cpp', |
|
42 | 48 | 'src/Variable/VariableAcquisitionWorker.cpp', |
|
43 | 49 | 'src/Variable/VariableSynchronizationGroup.cpp', |
|
44 | 50 | 'src/Variable/VariableModel.cpp', |
|
45 | 51 | 'src/Visualization/VisualizationController.cpp' |
|
46 | 52 | ] |
|
47 | 53 | |
|
48 | 54 | core_inc = include_directories(['include', '../plugin/include']) |
|
49 | 55 | |
|
50 | 56 | sciqlop_core_lib = library('sciqlopcore', |
|
51 | 57 | core_sources, |
|
52 | 58 | core_moc_files, |
|
53 | 59 | cpp_args : '-DCORE_LIB', |
|
54 | 60 | include_directories : core_inc, |
|
55 | dependencies : [qt5core, qt5network], | |
|
61 | dependencies : [qt5core, qt5network, catalogueapi_dep], | |
|
56 | 62 | install : true |
|
57 | 63 | ) |
|
58 | 64 | |
|
59 | 65 | |
|
60 | 66 | sciqlop_core = declare_dependency(link_with : sciqlop_core_lib, |
|
61 | 67 | include_directories : core_inc, |
|
62 | dependencies : [qt5core, qt5network]) | |
|
68 | dependencies : [qt5core, qt5network, catalogueapi_dep]) | |
|
69 | ||
|
63 | 70 | |
|
64 | 71 | |
|
65 | 72 | subdir('tests') |
|
66 | 73 |
@@ -1,188 +1,203 | |||
|
1 | 1 | #include "SqpApplication.h" |
|
2 | 2 | |
|
3 | #include <Catalogue/CatalogueController.h> | |
|
3 | 4 | #include <Data/IDataProvider.h> |
|
4 | 5 | #include <DataSource/DataSourceController.h> |
|
5 | 6 | #include <DragAndDrop/DragDropHelper.h> |
|
6 | 7 | #include <Network/NetworkController.h> |
|
7 | 8 | #include <QThread> |
|
8 | 9 | #include <Time/TimeController.h> |
|
9 | 10 | #include <Variable/Variable.h> |
|
10 | 11 | #include <Variable/VariableController.h> |
|
11 | 12 | #include <Variable/VariableModel.h> |
|
12 | 13 | #include <Visualization/VisualizationController.h> |
|
13 | 14 | |
|
14 | 15 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") |
|
15 | 16 | |
|
16 | 17 | class SqpApplication::SqpApplicationPrivate { |
|
17 | 18 | public: |
|
18 | 19 | SqpApplicationPrivate() |
|
19 | 20 | : m_DataSourceController{std::make_unique<DataSourceController>()}, |
|
20 | 21 | m_VariableController{std::make_unique<VariableController>()}, |
|
21 | 22 | m_TimeController{std::make_unique<TimeController>()}, |
|
22 | 23 | m_NetworkController{std::make_unique<NetworkController>()}, |
|
23 | 24 | m_VisualizationController{std::make_unique<VisualizationController>()}, |
|
24 | 25 | m_DragDropHelper{std::make_unique<DragDropHelper>()}, |
|
26 | m_CatalogueController{std::make_unique<CatalogueController>()}, | |
|
25 | 27 | m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None), |
|
26 | 28 | m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor) |
|
27 | 29 | { |
|
28 | 30 | // /////////////////////////////// // |
|
29 | 31 | // Connections between controllers // |
|
30 | 32 | // /////////////////////////////// // |
|
31 | 33 | |
|
32 | 34 | // VariableController <-> DataSourceController |
|
33 | 35 | connect(m_DataSourceController.get(), |
|
34 | 36 | SIGNAL(variableCreationRequested(const QString &, const QVariantHash &, |
|
35 | 37 | std::shared_ptr<IDataProvider>)), |
|
36 | 38 | m_VariableController.get(), |
|
37 | 39 | SLOT(createVariable(const QString &, const QVariantHash &, |
|
38 | 40 | std::shared_ptr<IDataProvider>))); |
|
39 | 41 | |
|
40 | 42 | connect(m_VariableController->variableModel(), &VariableModel::requestVariable, |
|
41 | 43 | m_DataSourceController.get(), &DataSourceController::requestVariable); |
|
42 | 44 | |
|
43 | 45 | // VariableController <-> VisualizationController |
|
44 | 46 | connect(m_VariableController.get(), |
|
45 | 47 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), |
|
46 | 48 | m_VisualizationController.get(), |
|
47 | 49 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection); |
|
48 | 50 | |
|
49 | 51 | connect(m_VariableController.get(), |
|
50 | 52 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)), |
|
51 | 53 | m_VisualizationController.get(), |
|
52 | 54 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &))); |
|
53 | 55 | |
|
54 | 56 | |
|
55 | 57 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); |
|
56 | 58 | m_DataSourceControllerThread.setObjectName("DataSourceControllerThread"); |
|
57 | 59 | m_NetworkController->moveToThread(&m_NetworkControllerThread); |
|
58 | 60 | m_NetworkControllerThread.setObjectName("NetworkControllerThread"); |
|
59 | 61 | m_VariableController->moveToThread(&m_VariableControllerThread); |
|
60 | 62 | m_VariableControllerThread.setObjectName("VariableControllerThread"); |
|
61 | 63 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); |
|
62 | 64 | m_VisualizationControllerThread.setObjectName("VsualizationControllerThread"); |
|
65 | m_CatalogueController->moveToThread(&m_CatalogueControllerThread); | |
|
66 | m_CatalogueControllerThread.setObjectName("CatalogueControllerThread"); | |
|
63 | 67 | |
|
64 | 68 | |
|
65 | 69 | // Additionnal init |
|
66 | 70 | m_VariableController->setTimeController(m_TimeController.get()); |
|
67 | 71 | } |
|
68 | 72 | |
|
69 | 73 | virtual ~SqpApplicationPrivate() |
|
70 | 74 | { |
|
71 | 75 | m_DataSourceControllerThread.quit(); |
|
72 | 76 | m_DataSourceControllerThread.wait(); |
|
73 | 77 | |
|
74 | 78 | m_NetworkControllerThread.quit(); |
|
75 | 79 | m_NetworkControllerThread.wait(); |
|
76 | 80 | |
|
77 | 81 | m_VariableControllerThread.quit(); |
|
78 | 82 | m_VariableControllerThread.wait(); |
|
79 | 83 | |
|
80 | 84 | m_VisualizationControllerThread.quit(); |
|
81 | 85 | m_VisualizationControllerThread.wait(); |
|
86 | ||
|
87 | m_CatalogueControllerThread.quit(); | |
|
88 | m_CatalogueControllerThread.wait(); | |
|
82 | 89 | } |
|
83 | 90 | |
|
84 | 91 | std::unique_ptr<DataSourceController> m_DataSourceController; |
|
85 | 92 | std::unique_ptr<VariableController> m_VariableController; |
|
86 | 93 | std::unique_ptr<TimeController> m_TimeController; |
|
87 | 94 | std::unique_ptr<NetworkController> m_NetworkController; |
|
88 | 95 | std::unique_ptr<VisualizationController> m_VisualizationController; |
|
96 | std::unique_ptr<CatalogueController> m_CatalogueController; | |
|
89 | 97 | QThread m_DataSourceControllerThread; |
|
90 | 98 | QThread m_NetworkControllerThread; |
|
91 | 99 | QThread m_VariableControllerThread; |
|
92 | 100 | QThread m_VisualizationControllerThread; |
|
101 | QThread m_CatalogueControllerThread; | |
|
93 | 102 | |
|
94 | 103 | std::unique_ptr<DragDropHelper> m_DragDropHelper; |
|
95 | 104 | |
|
96 | 105 | SqpApplication::PlotsInteractionMode m_PlotInterractionMode; |
|
97 | 106 | SqpApplication::PlotsCursorMode m_PlotCursorMode; |
|
98 | 107 | }; |
|
99 | 108 | |
|
100 | 109 | |
|
101 | 110 | SqpApplication::SqpApplication(int &argc, char **argv) |
|
102 | 111 | : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} |
|
103 | 112 | { |
|
104 | 113 | qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread(); |
|
105 | 114 | |
|
106 | 115 | connect(&impl->m_DataSourceControllerThread, &QThread::started, |
|
107 | 116 | impl->m_DataSourceController.get(), &DataSourceController::initialize); |
|
108 | 117 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, |
|
109 | 118 | impl->m_DataSourceController.get(), &DataSourceController::finalize); |
|
110 | 119 | |
|
111 | 120 | connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(), |
|
112 | 121 | &NetworkController::initialize); |
|
113 | 122 | connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(), |
|
114 | 123 | &NetworkController::finalize); |
|
115 | 124 | |
|
116 | 125 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), |
|
117 | 126 | &VariableController::initialize); |
|
118 | 127 | connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), |
|
119 | 128 | &VariableController::finalize); |
|
120 | 129 | |
|
121 | 130 | connect(&impl->m_VisualizationControllerThread, &QThread::started, |
|
122 | 131 | impl->m_VisualizationController.get(), &VisualizationController::initialize); |
|
123 | 132 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, |
|
124 | 133 | impl->m_VisualizationController.get(), &VisualizationController::finalize); |
|
125 | 134 | |
|
135 | connect(&impl->m_CatalogueControllerThread, &QThread::started, | |
|
136 | impl->m_CatalogueController.get(), &CatalogueController::initialize); | |
|
137 | connect(&impl->m_CatalogueControllerThread, &QThread::finished, | |
|
138 | impl->m_CatalogueController.get(), &CatalogueController::finalize); | |
|
139 | ||
|
126 | 140 | impl->m_DataSourceControllerThread.start(); |
|
127 | 141 | impl->m_NetworkControllerThread.start(); |
|
128 | 142 | impl->m_VariableControllerThread.start(); |
|
129 | 143 | impl->m_VisualizationControllerThread.start(); |
|
144 | impl->m_CatalogueControllerThread.start(); | |
|
130 | 145 | } |
|
131 | 146 | |
|
132 | 147 | SqpApplication::~SqpApplication() |
|
133 | 148 | { |
|
134 | 149 | } |
|
135 | 150 | |
|
136 | 151 | void SqpApplication::initialize() |
|
137 | 152 | { |
|
138 | 153 | } |
|
139 | 154 | |
|
140 | 155 | DataSourceController &SqpApplication::dataSourceController() noexcept |
|
141 | 156 | { |
|
142 | 157 | return *impl->m_DataSourceController; |
|
143 | 158 | } |
|
144 | 159 | |
|
145 | 160 | NetworkController &SqpApplication::networkController() noexcept |
|
146 | 161 | { |
|
147 | 162 | return *impl->m_NetworkController; |
|
148 | 163 | } |
|
149 | 164 | |
|
150 | 165 | TimeController &SqpApplication::timeController() noexcept |
|
151 | 166 | { |
|
152 | 167 | return *impl->m_TimeController; |
|
153 | 168 | } |
|
154 | 169 | |
|
155 | 170 | VariableController &SqpApplication::variableController() noexcept |
|
156 | 171 | { |
|
157 | 172 | return *impl->m_VariableController; |
|
158 | 173 | } |
|
159 | 174 | |
|
160 | 175 | VisualizationController &SqpApplication::visualizationController() noexcept |
|
161 | 176 | { |
|
162 | 177 | return *impl->m_VisualizationController; |
|
163 | 178 | } |
|
164 | 179 | |
|
165 | 180 | DragDropHelper &SqpApplication::dragDropHelper() noexcept |
|
166 | 181 | { |
|
167 | 182 | return *impl->m_DragDropHelper; |
|
168 | 183 | } |
|
169 | 184 | |
|
170 | 185 | SqpApplication::PlotsInteractionMode SqpApplication::plotsInteractionMode() const |
|
171 | 186 | { |
|
172 | 187 | return impl->m_PlotInterractionMode; |
|
173 | 188 | } |
|
174 | 189 | |
|
175 | 190 | void SqpApplication::setPlotsInteractionMode(SqpApplication::PlotsInteractionMode mode) |
|
176 | 191 | { |
|
177 | 192 | impl->m_PlotInterractionMode = mode; |
|
178 | 193 | } |
|
179 | 194 | |
|
180 | 195 | SqpApplication::PlotsCursorMode SqpApplication::plotsCursorMode() const |
|
181 | 196 | { |
|
182 | 197 | return impl->m_PlotCursorMode; |
|
183 | 198 | } |
|
184 | 199 | |
|
185 | 200 | void SqpApplication::setPlotsCursorMode(SqpApplication::PlotsCursorMode mode) |
|
186 | 201 | { |
|
187 | 202 | impl->m_PlotCursorMode = mode; |
|
188 | 203 | } |
@@ -1,195 +1,195 | |||
|
1 | 1 | #include "CosinusProvider.h" |
|
2 | 2 | #include "MockDefs.h" |
|
3 | 3 | |
|
4 | 4 | #include <Data/DataProviderParameters.h> |
|
5 | 5 | #include <Data/ScalarSeries.h> |
|
6 | 6 | #include <SqpApplication.h> |
|
7 | 7 | #include <Time/TimeController.h> |
|
8 | 8 | #include <Variable/Variable.h> |
|
9 | 9 | #include <Variable/VariableController.h> |
|
10 | 10 | |
|
11 | 11 | #include <QObject> |
|
12 | 12 | #include <QtTest> |
|
13 | 13 | |
|
14 | 14 | #include <cmath> |
|
15 | 15 | #include <memory> |
|
16 | 16 | |
|
17 | 17 | namespace { |
|
18 | 18 | |
|
19 | 19 | /// Path for the tests |
|
20 | 20 | const auto TESTS_RESOURCES_PATH = QFileInfo{ |
|
21 | 21 | QString{MOCKPLUGIN_TESTS_RESOURCES_DIR}, |
|
22 | 22 | "TestCosinusAcquisition"}.absoluteFilePath(); |
|
23 | 23 | |
|
24 | 24 | /// Format of dates in data files |
|
25 | 25 | const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss:zzz"); |
|
26 | 26 | |
|
27 | 27 | /** |
|
28 | 28 | * Verifies that the data in the candidate series are identical to the data in the reference series |
|
29 | 29 | * in a specific range |
|
30 | 30 | * @param candidate the candidate data series |
|
31 | 31 | * @param range the range to check |
|
32 | 32 | * @param reference the reference data series |
|
33 | 33 | * @return true if the data of the candidate series and the reference series are identical in the |
|
34 | 34 | * range, false otherwise |
|
35 | 35 | */ |
|
36 | 36 | bool checkDataSeries(std::shared_ptr<IDataSeries> candidate, const SqpRange &range, |
|
37 | 37 | std::shared_ptr<IDataSeries> reference) |
|
38 | 38 | { |
|
39 | 39 | if (candidate == nullptr || reference == nullptr) { |
|
40 | 40 | return candidate == reference; |
|
41 | 41 | } |
|
42 | 42 | |
|
43 | 43 | auto referenceIt = reference->xAxisRange(range.m_TStart, range.m_TEnd); |
|
44 | 44 | |
|
45 | 45 | qInfo() << "candidateSize" << std::distance(candidate->cbegin(), candidate->cend()); |
|
46 | 46 | qInfo() << "refSize" << std::distance(referenceIt.first, referenceIt.second); |
|
47 | 47 | |
|
48 | 48 | return std::equal(candidate->cbegin(), candidate->cend(), referenceIt.first, referenceIt.second, |
|
49 | 49 | [](const auto &it1, const auto &it2) { |
|
50 | 50 | // - milliseconds precision for time |
|
51 | 51 | // - 1e-6 precision for value |
|
52 | 52 | return std::abs(it1.x() - it2.x()) < 1e-3 |
|
53 | 53 | && std::abs(it1.value() - it2.value()) < 1e-6; |
|
54 | 54 | }); |
|
55 | 55 | } |
|
56 | 56 | |
|
57 | 57 | } // namespace |
|
58 | 58 | |
|
59 | 59 | /** |
|
60 | 60 | * @brief The TestCosinusAcquisition class tests acquisition in SciQlop (operations like zooms in, |
|
61 | 61 | * zooms out, pans) of data from CosinusProvider |
|
62 | 62 | * @sa CosinusProvider |
|
63 | 63 | */ |
|
64 | 64 | class TestCosinusAcquisition : public QObject { |
|
65 | 65 | Q_OBJECT |
|
66 | 66 | |
|
67 | 67 | private slots: |
|
68 | 68 | /// Input data for @sa testAcquisition() |
|
69 | 69 | void testAcquisition_data(); |
|
70 | 70 | void testAcquisition(); |
|
71 | 71 | }; |
|
72 | 72 | |
|
73 | 73 | void TestCosinusAcquisition::testAcquisition_data() |
|
74 | 74 | { |
|
75 | 75 | // ////////////// // |
|
76 | 76 | // Test structure // |
|
77 | 77 | // ////////////// // |
|
78 | 78 | |
|
79 | 79 | QTest::addColumn<SqpRange>("referenceRange"); // Range for generating reference series |
|
80 | 80 | QTest::addColumn<SqpRange>("initialRange"); // First acquisition |
|
81 | 81 | QTest::addColumn<int>("operationDelay"); // Acquisitions to make |
|
82 | 82 | QTest::addColumn<std::vector<SqpRange> >("operations"); // Acquisitions to make |
|
83 | 83 | |
|
84 | 84 | // ////////// // |
|
85 | 85 | // Test cases // |
|
86 | 86 | // ////////// // |
|
87 | 87 | |
|
88 | 88 | auto dateTime = [](int year, int month, int day, int hours, int minutes, int seconds) { |
|
89 | 89 | return DateUtils::secondsSinceEpoch( |
|
90 | 90 | QDateTime{{year, month, day}, {hours, minutes, seconds}, Qt::UTC}); |
|
91 | 91 | }; |
|
92 | 92 | |
|
93 | 93 | QTest::newRow("cosinus") |
|
94 | 94 | << SqpRange{dateTime(2017, 1, 1, 12, 0, 0), dateTime(2017, 1, 1, 13, 0, 0)} |
|
95 | 95 | << SqpRange{dateTime(2017, 1, 1, 12, 30, 0), dateTime(2017, 1, 1, 12, 35, 1)} << 250 |
|
96 | 96 | << std::vector<SqpRange>{ |
|
97 | 97 | // Pan (jump) left |
|
98 | 98 | SqpRange{dateTime(2017, 1, 1, 12, 45, 0), dateTime(2017, 1, 1, 12, 50, 0)}, |
|
99 | 99 | // Pan (jump) right |
|
100 | 100 | SqpRange{dateTime(2017, 1, 1, 12, 15, 0), dateTime(2017, 1, 1, 12, 20, 0)}, |
|
101 | 101 | // Pan (overlay) right |
|
102 | 102 | SqpRange{dateTime(2017, 1, 1, 12, 14, 0), dateTime(2017, 1, 1, 12, 19, 0)}, |
|
103 | 103 | // Pan (overlay) left |
|
104 | 104 | SqpRange{dateTime(2017, 1, 1, 12, 15, 0), dateTime(2017, 1, 1, 12, 20, 0)}, |
|
105 | 105 | // Pan (overlay) left |
|
106 | 106 | SqpRange{dateTime(2017, 1, 1, 12, 16, 0), dateTime(2017, 1, 1, 12, 21, 0)}, |
|
107 | 107 | // Zoom in |
|
108 | 108 | SqpRange{dateTime(2017, 1, 1, 12, 17, 30), dateTime(2017, 1, 1, 12, 19, 30)}, |
|
109 | 109 | // Zoom out |
|
110 | 110 | SqpRange{dateTime(2017, 1, 1, 12, 12, 30), dateTime(2017, 1, 1, 12, 24, 30)}}; |
|
111 | 111 | |
|
112 | 112 | QTest::newRow("cosinus_big") |
|
113 | 113 | << SqpRange{dateTime(2017, 1, 1, 1, 0, 0), dateTime(2017, 1, 5, 13, 0, 0)} |
|
114 | 114 | << SqpRange{dateTime(2017, 1, 2, 6, 30, 0), dateTime(2017, 1, 2, 18, 30, 0)} << 5000 |
|
115 | 115 | << std::vector<SqpRange>{ |
|
116 | 116 | // Pan (jump) left |
|
117 | 117 | SqpRange{dateTime(2017, 1, 1, 13, 30, 0), dateTime(2017, 1, 1, 18, 30, 0)}, |
|
118 | 118 | // Pan (jump) right |
|
119 | 119 | SqpRange{dateTime(2017, 1, 3, 4, 30, 0), dateTime(2017, 1, 3, 10, 30, 0)}, |
|
120 | 120 | // Pan (overlay) right |
|
121 | 121 | SqpRange{dateTime(2017, 1, 3, 8, 30, 0), dateTime(2017, 1, 3, 12, 30, 0)}, |
|
122 | 122 | // Pan (overlay) left |
|
123 | 123 | SqpRange{dateTime(2017, 1, 2, 8, 30, 0), dateTime(2017, 1, 3, 10, 30, 0)}, |
|
124 | 124 | // Pan (overlay) left |
|
125 | 125 | SqpRange{dateTime(2017, 1, 1, 12, 30, 0), dateTime(2017, 1, 3, 5, 30, 0)}, |
|
126 | 126 | // Zoom in |
|
127 | 127 | SqpRange{dateTime(2017, 1, 2, 2, 30, 0), dateTime(2017, 1, 2, 8, 30, 0)}, |
|
128 | 128 | // Zoom out |
|
129 | 129 | SqpRange{dateTime(2017, 1, 1, 14, 30, 0), dateTime(2017, 1, 3, 12, 30, 0)}}; |
|
130 | 130 | } |
|
131 | 131 | |
|
132 | 132 | void TestCosinusAcquisition::testAcquisition() |
|
133 | 133 | { |
|
134 | 134 | // Retrieves reference range |
|
135 | 135 | QFETCH(SqpRange, referenceRange); |
|
136 | 136 | CosinusProvider referenceProvider{}; |
|
137 | 137 | auto dataSeries = referenceProvider.provideDataSeries( |
|
138 |
referenceRange, {{COSINUS_TYPE_KEY, "scalar"}, {COSINUS_FREQUENCY_KEY, 10 |
|
|
138 | referenceRange, {{COSINUS_TYPE_KEY, "scalar"}, {COSINUS_FREQUENCY_KEY, 10.}}); | |
|
139 | 139 | |
|
140 | 140 | auto end = dataSeries->cend() - 1; |
|
141 | 141 | qInfo() << dataSeries->nbPoints() << dataSeries->cbegin()->x() << end->x(); |
|
142 | 142 | |
|
143 | 143 | /// Lambda used to validate a variable at each step |
|
144 | 144 | auto validateVariable |
|
145 | 145 | = [dataSeries](std::shared_ptr<Variable> variable, const SqpRange &range) { |
|
146 | 146 | // Checks that the variable's range has changed |
|
147 | 147 | qInfo() << "range vs expected range" << variable->range() << range; |
|
148 | 148 | QCOMPARE(variable->range(), range); |
|
149 | 149 | |
|
150 | 150 | // Checks the variable's data series |
|
151 | 151 | QVERIFY(checkDataSeries(variable->dataSeries(), variable->cacheRange(), dataSeries)); |
|
152 | 152 | }; |
|
153 | 153 | |
|
154 | 154 | // Creates variable |
|
155 | 155 | QFETCH(SqpRange, initialRange); |
|
156 | 156 | sqpApp->timeController().onTimeToUpdate(initialRange); |
|
157 | 157 | auto provider = std::make_shared<CosinusProvider>(); |
|
158 | 158 | auto variable = sqpApp->variableController().createVariable( |
|
159 |
"MMS", {{COSINUS_TYPE_KEY, "scalar"}, {COSINUS_FREQUENCY_KEY, 10 |
|
|
159 | "MMS", {{COSINUS_TYPE_KEY, "scalar"}, {COSINUS_FREQUENCY_KEY, 10.}}, provider); | |
|
160 | 160 | |
|
161 | 161 | |
|
162 | 162 | QFETCH(int, operationDelay); |
|
163 | 163 | QTest::qWait(operationDelay); |
|
164 | 164 | validateVariable(variable, initialRange); |
|
165 | 165 | |
|
166 | 166 | QTest::qWait(operationDelay); |
|
167 | 167 | // Makes operations on the variable |
|
168 | 168 | QFETCH(std::vector<SqpRange>, operations); |
|
169 | 169 | for (const auto &operation : operations) { |
|
170 | 170 | // Asks request on the variable and waits during its execution |
|
171 | 171 | sqpApp->variableController().onRequestDataLoading({variable}, operation, false); |
|
172 | 172 | |
|
173 | 173 | QTest::qWait(operationDelay); |
|
174 | 174 | validateVariable(variable, operation); |
|
175 | 175 | } |
|
176 | 176 | |
|
177 | 177 | |
|
178 | 178 | for (const auto &operation : operations) { |
|
179 | 179 | // Asks request on the variable and waits during its execution |
|
180 | 180 | sqpApp->variableController().onRequestDataLoading({variable}, operation, false); |
|
181 | 181 | } |
|
182 | 182 | QTest::qWait(operationDelay); |
|
183 | 183 | validateVariable(variable, operations.back()); |
|
184 | 184 | } |
|
185 | 185 | |
|
186 | 186 | int main(int argc, char *argv[]) |
|
187 | 187 | { |
|
188 | 188 | SqpApplication app{argc, argv}; |
|
189 | 189 | app.setAttribute(Qt::AA_Use96Dpi, true); |
|
190 | 190 | TestCosinusAcquisition testObject{}; |
|
191 | 191 | QTEST_SET_MAIN_SOURCE_PATH |
|
192 | 192 | return QTest::qExec(&testObject, argc, argv); |
|
193 | 193 | } |
|
194 | 194 | |
|
195 | 195 | #include "TestCosinusAcquisition.moc" |
General Comments 0
You need to be logged in to leave comments.
Login now