@@ -0,0 +1,18 | |||||
|
1 | #include <cmath> | |||
|
2 | #include <limits> | |||
|
3 | #include <type_traits> | |||
|
4 | #include <algorithm> | |||
|
5 | ||||
|
6 | /* | |||
|
7 | taken from here https://en.cppreference.com/w/cpp/types/numeric_limits/epsilon | |||
|
8 | */ | |||
|
9 | template<class T> | |||
|
10 | typename std::enable_if<!std::numeric_limits<T>::is_integer, bool>::type | |||
|
11 | almost_equal(T x, T y, int ulp) | |||
|
12 | { | |||
|
13 | // the machine epsilon has to be scaled to the magnitude of the values used | |||
|
14 | // and multiplied by the desired precision in ULPs (units in the last place) | |||
|
15 | return std::abs(x-y) <= std::numeric_limits<T>::epsilon() * std::abs(x+y) * ulp | |||
|
16 | // unless the result is subnormal | |||
|
17 | || std::abs(x-y) < std::numeric_limits<T>::min(); | |||
|
18 | } |
@@ -0,0 +1,32 | |||||
|
1 | #include <memory> | |||
|
2 | #include <vector> | |||
|
3 | #include <QHash> | |||
|
4 | #include <Variable/Variable.h> | |||
|
5 | #include <Variable/VariableSynchronizationGroup.h> | |||
|
6 | #include "Data/SqpRange.h" | |||
|
7 | #include <QMutexLocker> | |||
|
8 | #include <QUuid> | |||
|
9 | ||||
|
10 | class VariableController2 | |||
|
11 | { | |||
|
12 | ||||
|
13 | QHash<QUuid, std::shared_ptr<Variable>> _variables; | |||
|
14 | QMutex _variables_lock; | |||
|
15 | ||||
|
16 | std::vector<std::unique_ptr<VariableSynchronizationGroup>> _groups; | |||
|
17 | QMutex _variables_groups_lock; | |||
|
18 | public: | |||
|
19 | ||||
|
20 | QUuid addVariable(std::shared_ptr<Variable> variable) | |||
|
21 | { | |||
|
22 | QMutexLocker lock(&_variables_lock); | |||
|
23 | QMutexLocker glock(&_variables_groups_lock); | |||
|
24 | ||||
|
25 | QUuid uuid = QUuid::createUuid(); | |||
|
26 | this->_variables[uuid] = variable; | |||
|
27 | this->_groups.push_back(std::make_unique<VariableSynchronizationGroup>(uuid)); | |||
|
28 | return uuid; | |||
|
29 | } | |||
|
30 | void changeRange(int variable, DateTimeRange r); | |||
|
31 | void asyncChangeRange(int variable, DateTimeRange r); | |||
|
32 | }; |
@@ -0,0 +1,1 | |||||
|
1 | #include "Variable/VariableController2.h" |
@@ -0,0 +1,30 | |||||
|
1 | #include <QtTest> | |||
|
2 | #include <QObject> | |||
|
3 | ||||
|
4 | ||||
|
5 | class TestVariableController2 : public QObject | |||
|
6 | ||||
|
7 | { | |||
|
8 | Q_OBJECT | |||
|
9 | public: | |||
|
10 | explicit TestVariableController2(QObject *parent = nullptr) : QObject(parent){} | |||
|
11 | signals: | |||
|
12 | ||||
|
13 | private slots: | |||
|
14 | void initTestCase(){} | |||
|
15 | void cleanupTestCase(){} | |||
|
16 | ||||
|
17 | void test1() | |||
|
18 | { | |||
|
19 | QCOMPARE(1+1, 2); | |||
|
20 | } | |||
|
21 | ||||
|
22 | private: | |||
|
23 | ||||
|
24 | }; | |||
|
25 | ||||
|
26 | ||||
|
27 | QTEST_MAIN(TestVariableController2) | |||
|
28 | ||||
|
29 | #include "TestVariableController2.moc" | |||
|
30 |
@@ -0,0 +1,38 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the SciQLOP Software | |||
|
3 | -- Copyright (C) 2018, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
|
22 | #include <string> | |||
|
23 | ||||
|
24 | #include <pybind11/pybind11.h> | |||
|
25 | #include <pybind11/embed.h> | |||
|
26 | ||||
|
27 | namespace py = pybind11; | |||
|
28 | ||||
|
29 | ||||
|
30 | int pytestamda_test(const char* testScriptPath ) | |||
|
31 | { | |||
|
32 | py::scoped_interpreter guard{}; | |||
|
33 | py::globals()["__file__"] = py::str(testScriptPath); | |||
|
34 | py::eval_file(testScriptPath); | |||
|
35 | return 0; | |||
|
36 | } | |||
|
37 | ||||
|
38 |
@@ -6,3 +6,6 core/include/Version.h | |||||
6 | 3rdparty/ |
|
6 | 3rdparty/ | |
7 | subprojects/CatalogueAPI/ |
|
7 | subprojects/CatalogueAPI/ | |
8 | subprojects/QxOrm/ |
|
8 | subprojects/QxOrm/ | |
|
9 | documentation/* | |||
|
10 | .idea/* | |||
|
11 | **/__pycache__/* |
@@ -319,8 +319,8 MainWindow::MainWindow(QWidget *parent) | |||||
319 | // /////////// // |
|
319 | // /////////// // | |
320 |
|
320 | |||
321 | // Controllers / controllers connections |
|
321 | // Controllers / controllers connections | |
322 |
connect(&sqpApp->timeController(), SIGNAL(timeUpdated( |
|
322 | connect(&sqpApp->timeController(), SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->variableController(), | |
323 |
SLOT(onDateTimeOnSelection( |
|
323 | SLOT(onDateTimeOnSelection(DateTimeRange))); | |
324 |
|
324 | |||
325 | // Widgets / controllers connections |
|
325 | // Widgets / controllers connections | |
326 |
|
326 | |||
@@ -329,8 +329,8 MainWindow::MainWindow(QWidget *parent) | |||||
329 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *))); |
|
329 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *))); | |
330 |
|
330 | |||
331 | // Time |
|
331 | // Time | |
332 |
connect(timeWidget, SIGNAL(timeUpdated( |
|
332 | connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(), | |
333 |
SLOT(onTimeToUpdate( |
|
333 | SLOT(onTimeToUpdate(DateTimeRange))); | |
334 |
|
334 | |||
335 | // Visualization |
|
335 | // Visualization | |
336 | connect(&sqpApp->visualizationController(), |
|
336 | connect(&sqpApp->visualizationController(), | |
@@ -338,8 +338,8 MainWindow::MainWindow(QWidget *parent) | |||||
338 | SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable>))); |
|
338 | SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable>))); | |
339 |
|
339 | |||
340 | connect(&sqpApp->visualizationController(), |
|
340 | connect(&sqpApp->visualizationController(), | |
341 |
SIGNAL(rangeChanged(std::shared_ptr<Variable>, const |
|
341 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const DateTimeRange &)), m_Ui->view, | |
342 |
SLOT(onRangeChanged(std::shared_ptr<Variable>, const |
|
342 | SLOT(onRangeChanged(std::shared_ptr<Variable>, const DateTimeRange &))); | |
343 |
|
343 | |||
344 | // Widgets / widgets connections |
|
344 | // Widgets / widgets connections | |
345 |
|
345 |
@@ -10,6 +10,7 FILE (GLOB_RECURSE core_SRCS | |||||
10 | ./include/Common/StringUtils.h |
|
10 | ./include/Common/StringUtils.h | |
11 | ./include/Common/SignalWaiter.h |
|
11 | ./include/Common/SignalWaiter.h | |
12 | ./include/Common/DateUtils.h |
|
12 | ./include/Common/DateUtils.h | |
|
13 | ./include/Common/Numeric.h | |||
13 | ./include/Plugin/IPlugin.h |
|
14 | ./include/Plugin/IPlugin.h | |
14 | ./include/Data/ArrayDataIterator.h |
|
15 | ./include/Data/ArrayDataIterator.h | |
15 | ./include/Data/VariableRequest.h |
|
16 | ./include/Data/VariableRequest.h | |
@@ -32,6 +33,7 FILE (GLOB_RECURSE core_SRCS | |||||
32 | ./include/Data/IDataProvider.h |
|
33 | ./include/Data/IDataProvider.h | |
33 | ./include/Data/IDataSeries.h |
|
34 | ./include/Data/IDataSeries.h | |
34 | ./include/Network/NetworkController.h |
|
35 | ./include/Network/NetworkController.h | |
|
36 | ./include/Network/Downloader.h | |||
35 | ./include/Version.h |
|
37 | ./include/Version.h | |
36 | ./include/CoreGlobal.h |
|
38 | ./include/CoreGlobal.h | |
37 | ./include/Catalogue/CatalogueController.h |
|
39 | ./include/Catalogue/CatalogueController.h | |
@@ -46,6 +48,7 FILE (GLOB_RECURSE core_SRCS | |||||
46 | ./include/Variable/Variable.h |
|
48 | ./include/Variable/Variable.h | |
47 | ./include/Variable/VariableCacheController.h |
|
49 | ./include/Variable/VariableCacheController.h | |
48 | ./include/Variable/VariableController.h |
|
50 | ./include/Variable/VariableController.h | |
|
51 | ./include/Variable/VariableController2.h | |||
49 | ./include/Time/TimeController.h |
|
52 | ./include/Time/TimeController.h | |
50 | ./include/Settings/ISqpSettingsBindable.h |
|
53 | ./include/Settings/ISqpSettingsBindable.h | |
51 | ./include/Settings/SqpSettingsDefs.h |
|
54 | ./include/Settings/SqpSettingsDefs.h | |
@@ -71,6 +74,7 FILE (GLOB_RECURSE core_SRCS | |||||
71 | ./src/Visualization/VisualizationController.cpp |
|
74 | ./src/Visualization/VisualizationController.cpp | |
72 | ./src/PluginManager/PluginManager.cpp |
|
75 | ./src/PluginManager/PluginManager.cpp | |
73 | ./src/Variable/VariableController.cpp |
|
76 | ./src/Variable/VariableController.cpp | |
|
77 | ./src/Variable/VariableController2.cpp | |||
74 | ./src/Variable/VariableModel.cpp |
|
78 | ./src/Variable/VariableModel.cpp | |
75 | ./src/Variable/VariableCacheController.cpp |
|
79 | ./src/Variable/VariableCacheController.cpp | |
76 | ./src/Variable/VariableSynchronizationGroup.cpp |
|
80 | ./src/Variable/VariableSynchronizationGroup.cpp |
@@ -16,7 +16,7 | |||||
16 | */ |
|
16 | */ | |
17 | struct AcquisitionDataPacket { |
|
17 | struct AcquisitionDataPacket { | |
18 | std::shared_ptr<IDataSeries> m_DateSeries; |
|
18 | std::shared_ptr<IDataSeries> m_DateSeries; | |
19 |
|
|
19 | DateTimeRange m_Range; | |
20 | }; |
|
20 | }; | |
21 |
|
21 | |||
22 | SCIQLOP_REGISTER_META_TYPE(ACQUISITIONDATAPACKET_REGISTRY, AcquisitionDataPacket) |
|
22 | SCIQLOP_REGISTER_META_TYPE(ACQUISITIONDATAPACKET_REGISTRY, AcquisitionDataPacket) |
@@ -28,8 +28,8 struct AcquisitionRequest { | |||||
28 | QUuid m_AcqIdentifier; |
|
28 | QUuid m_AcqIdentifier; | |
29 | QUuid m_vIdentifier; |
|
29 | QUuid m_vIdentifier; | |
30 | DataProviderParameters m_DataProviderParameters; |
|
30 | DataProviderParameters m_DataProviderParameters; | |
31 |
|
|
31 | DateTimeRange m_RangeRequested; | |
32 |
|
|
32 | DateTimeRange m_CacheRangeRequested; | |
33 | int m_Size; |
|
33 | int m_Size; | |
34 | int m_Progression; |
|
34 | int m_Progression; | |
35 | std::shared_ptr<IDataProvider> m_Provider; |
|
35 | std::shared_ptr<IDataProvider> m_Provider; |
@@ -10,7 +10,7 | |||||
10 | */ |
|
10 | */ | |
11 | struct DataProviderParameters { |
|
11 | struct DataProviderParameters { | |
12 | /// Times for which retrieve data |
|
12 | /// Times for which retrieve data | |
13 |
QVector< |
|
13 | QVector<DateTimeRange> m_Times; | |
14 | /// Extra data that can be used by the provider to retrieve data |
|
14 | /// Extra data that can be used by the provider to retrieve data | |
15 | QVariantHash m_Data; |
|
15 | QVariantHash m_Data; | |
16 | }; |
|
16 | }; |
@@ -52,7 +52,7 signals: | |||||
52 | * identified by acqIdentifier |
|
52 | * identified by acqIdentifier | |
53 | */ |
|
53 | */ | |
54 | void dataProvided(QUuid acqIdentifier, std::shared_ptr<IDataSeries> dateSeriesAcquired, |
|
54 | void dataProvided(QUuid acqIdentifier, std::shared_ptr<IDataSeries> dateSeriesAcquired, | |
55 |
const |
|
55 | const DateTimeRange &dataRangeAcquired); | |
56 |
|
56 | |||
57 | /** |
|
57 | /** | |
58 | * @brief dataProvidedProgress notify the progression of the data identifier by acqIdentifier |
|
58 | * @brief dataProvidedProgress notify the progression of the data identifier by acqIdentifier |
@@ -49,7 +49,7 public: | |||||
49 | virtual void purge(double min, double max) = 0; |
|
49 | virtual void purge(double min, double max) = 0; | |
50 |
|
50 | |||
51 | /// @todo Review the name and signature of this method |
|
51 | /// @todo Review the name and signature of this method | |
52 |
virtual std::shared_ptr<IDataSeries> subDataSeries(const |
|
52 | virtual std::shared_ptr<IDataSeries> subDataSeries(const DateTimeRange &range) = 0; | |
53 |
|
53 | |||
54 | virtual std::unique_ptr<IDataSeries> clone() const = 0; |
|
54 | virtual std::unique_ptr<IDataSeries> clone() const = 0; | |
55 |
|
55 |
@@ -21,7 +21,7 public: | |||||
21 |
|
21 | |||
22 | std::unique_ptr<IDataSeries> clone() const override; |
|
22 | std::unique_ptr<IDataSeries> clone() const override; | |
23 |
|
23 | |||
24 |
std::shared_ptr<IDataSeries> subDataSeries(const |
|
24 | std::shared_ptr<IDataSeries> subDataSeries(const DateTimeRange &range) override; | |
25 | }; |
|
25 | }; | |
26 |
|
26 | |||
27 | #endif // SCIQLOP_SCALARSERIES_H |
|
27 | #endif // SCIQLOP_SCALARSERIES_H |
@@ -29,7 +29,7 public: | |||||
29 | std::unique_ptr<IDataSeries> clone() const override; |
|
29 | std::unique_ptr<IDataSeries> clone() const override; | |
30 |
|
30 | |||
31 | /// @sa DataSeries::subDataSeries() |
|
31 | /// @sa DataSeries::subDataSeries() | |
32 |
std::shared_ptr<IDataSeries> subDataSeries(const |
|
32 | std::shared_ptr<IDataSeries> subDataSeries(const DateTimeRange &range) override; | |
33 |
|
33 | |||
34 | inline double xResolution() const noexcept { return m_XResolution; } |
|
34 | inline double xResolution() const noexcept { return m_XResolution; } | |
35 |
|
35 |
@@ -13,9 +13,9 | |||||
13 | /** |
|
13 | /** | |
14 | * @brief The SqpRange struct holds the information of time parameters |
|
14 | * @brief The SqpRange struct holds the information of time parameters | |
15 | */ |
|
15 | */ | |
16 |
struct |
|
16 | struct DateTimeRange { | |
17 | /// Creates SqpRange from dates and times |
|
17 | /// Creates SqpRange from dates and times | |
18 |
static |
|
18 | static DateTimeRange fromDateTime(const QDate &startDate, const QTime &startTime, | |
19 | const QDate &endDate, const QTime &endTime) |
|
19 | const QDate &endDate, const QTime &endTime) | |
20 | { |
|
20 | { | |
21 | return {DateUtils::secondsSinceEpoch(QDateTime{startDate, startTime, Qt::UTC}), |
|
21 | return {DateUtils::secondsSinceEpoch(QDateTime{startDate, startTime, Qt::UTC}), | |
@@ -27,17 +27,19 struct SqpRange { | |||||
27 | /// End time (UTC) |
|
27 | /// End time (UTC) | |
28 | double m_TEnd; |
|
28 | double m_TEnd; | |
29 |
|
29 | |||
30 | bool contains(const SqpRange &dateTime) const noexcept |
|
30 | double delta()const {return this->m_TEnd - this->m_TStart;} | |
|
31 | ||||
|
32 | bool contains(const DateTimeRange &dateTime) const noexcept | |||
31 | { |
|
33 | { | |
32 | return (m_TStart <= dateTime.m_TStart && m_TEnd >= dateTime.m_TEnd); |
|
34 | return (m_TStart <= dateTime.m_TStart && m_TEnd >= dateTime.m_TEnd); | |
33 | } |
|
35 | } | |
34 |
|
36 | |||
35 |
bool intersect(const |
|
37 | bool intersect(const DateTimeRange &dateTime) const noexcept | |
36 | { |
|
38 | { | |
37 | return (m_TEnd >= dateTime.m_TStart && m_TStart <= dateTime.m_TEnd); |
|
39 | return (m_TEnd >= dateTime.m_TStart && m_TStart <= dateTime.m_TEnd); | |
38 | } |
|
40 | } | |
39 |
|
41 | |||
40 |
bool operator==(const |
|
42 | bool operator==(const DateTimeRange &other) const | |
41 | { |
|
43 | { | |
42 | auto equals = [](const auto &v1, const auto &v2) { |
|
44 | auto equals = [](const auto &v1, const auto &v2) { | |
43 | return (std::isnan(v1) && std::isnan(v2)) || v1 == v2; |
|
45 | return (std::isnan(v1) && std::isnan(v2)) || v1 == v2; | |
@@ -45,13 +47,13 struct SqpRange { | |||||
45 |
|
47 | |||
46 | return equals(m_TStart, other.m_TStart) && equals(m_TEnd, other.m_TEnd); |
|
48 | return equals(m_TStart, other.m_TStart) && equals(m_TEnd, other.m_TEnd); | |
47 | } |
|
49 | } | |
48 |
bool operator!=(const |
|
50 | bool operator!=(const DateTimeRange &other) const { return !(*this == other); } | |
49 | }; |
|
51 | }; | |
50 |
|
52 | |||
51 | const auto INVALID_RANGE |
|
53 | const auto INVALID_RANGE | |
52 |
= |
|
54 | = DateTimeRange{std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()}; | |
53 |
|
55 | |||
54 |
inline QDebug operator<<(QDebug d, |
|
56 | inline QDebug operator<<(QDebug d, DateTimeRange obj) | |
55 | { |
|
57 | { | |
56 | auto tendDateTimeStart = DateUtils::dateTime(obj.m_TStart); |
|
58 | auto tendDateTimeStart = DateUtils::dateTime(obj.m_TStart); | |
57 | auto tendDateTimeEnd = DateUtils::dateTime(obj.m_TEnd); |
|
59 | auto tendDateTimeEnd = DateUtils::dateTime(obj.m_TEnd); | |
@@ -61,6 +63,6 inline QDebug operator<<(QDebug d, SqpRange obj) | |||||
61 | } |
|
63 | } | |
62 |
|
64 | |||
63 | // Required for using shared_ptr in signals/slots |
|
65 | // Required for using shared_ptr in signals/slots | |
64 |
SCIQLOP_REGISTER_META_TYPE(SQPRANGE_REGISTRY, |
|
66 | SCIQLOP_REGISTER_META_TYPE(SQPRANGE_REGISTRY, DateTimeRange) | |
65 |
|
67 | |||
66 | #endif // SCIQLOP_SQPRANGE_H |
|
68 | #endif // SCIQLOP_SQPRANGE_H |
@@ -16,8 +16,8 | |||||
16 | */ |
|
16 | */ | |
17 | struct VariableRequest { |
|
17 | struct VariableRequest { | |
18 | QUuid m_VariableGroupId; |
|
18 | QUuid m_VariableGroupId; | |
19 |
|
|
19 | DateTimeRange m_RangeRequested; | |
20 |
|
|
20 | DateTimeRange m_CacheRangeRequested; | |
21 | std::shared_ptr<IDataSeries> m_DataSeries; |
|
21 | std::shared_ptr<IDataSeries> m_DataSeries; | |
22 | }; |
|
22 | }; | |
23 |
|
23 |
@@ -28,7 +28,7 public: | |||||
28 |
|
28 | |||
29 | std::unique_ptr<IDataSeries> clone() const; |
|
29 | std::unique_ptr<IDataSeries> clone() const; | |
30 |
|
30 | |||
31 |
std::shared_ptr<IDataSeries> subDataSeries(const |
|
31 | std::shared_ptr<IDataSeries> subDataSeries(const DateTimeRange &range) override; | |
32 | }; |
|
32 | }; | |
33 |
|
33 | |||
34 | #endif // SCIQLOP_VECTORSERIES_H |
|
34 | #endif // SCIQLOP_VECTORSERIES_H |
@@ -14,11 +14,45 | |||||
14 |
|
14 | |||
15 | /** |
|
15 | /** | |
16 | * @brief The Downloader handles all data donwloads in SciQLOP. |
|
16 | * @brief The Downloader handles all data donwloads in SciQLOP. | |
|
17 | * | |||
|
18 | * Simple synchronous GET example: | |||
|
19 | * @code{.cpp} | |||
|
20 | * auto response = Downloader::get("http://example.com") | |||
|
21 | * std::cout << "Status code: " << response.status_code() << std::endl << "Data: " << response.data().toStdString() << std::endl; | |||
|
22 | * @endcode | |||
|
23 | * | |||
|
24 | * @note | |||
|
25 | * This is a quick and KISS implementation using QNetworkAccessManager isolating from Qt stuff (Signal/slots). | |||
|
26 | * This could be impemented with a different backend in the future. | |||
|
27 | * | |||
|
28 | * @sa Response | |||
17 | */ |
|
29 | */ | |
18 | class SCIQLOP_CORE_EXPORT Downloader{ |
|
30 | class SCIQLOP_CORE_EXPORT Downloader{ | |
19 | public: |
|
31 | public: | |
|
32 | /** | |||
|
33 | * @brief does a synchronous GET request on the given url | |||
|
34 | * @param url | |||
|
35 | * @param user | |||
|
36 | * @param passwd | |||
|
37 | * @return Response object containing request data and http status code | |||
|
38 | * @sa Downloader::getAsync | |||
|
39 | */ | |||
20 | static Response get(const QString& url, const QString& user="", const QString& passwd=""); |
|
40 | static Response get(const QString& url, const QString& user="", const QString& passwd=""); | |
|
41 | /** | |||
|
42 | * @brief does an asynchronous GET request on the given url | |||
|
43 | * @param url | |||
|
44 | * @param callback | |||
|
45 | * @param user | |||
|
46 | * @param passwd | |||
|
47 | * @return QUuid an unique identifier associated to this request | |||
|
48 | * @sa Downloader::get, Downloader::downloadFinished | |||
|
49 | */ | |||
21 | static QUuid getAsync(const QString& url, std::function<void (QUuid, Response)> callback, const QString& user="", const QString& passwd=""); |
|
50 | static QUuid getAsync(const QString& url, std::function<void (QUuid, Response)> callback, const QString& user="", const QString& passwd=""); | |
|
51 | /** | |||
|
52 | * @brief downloadFinished | |||
|
53 | * @param uuid | |||
|
54 | * @return true if the request associated to this uuid is complete | |||
|
55 | */ | |||
22 | static bool downloadFinished(QUuid uuid); |
|
56 | static bool downloadFinished(QUuid uuid); | |
23 |
|
57 | |||
24 | static Downloader& instance() |
|
58 | static Downloader& instance() |
@@ -21,21 +21,21 class SCIQLOP_CORE_EXPORT TimeController : public QObject { | |||||
21 | public: |
|
21 | public: | |
22 | explicit TimeController(QObject *parent = 0); |
|
22 | explicit TimeController(QObject *parent = 0); | |
23 |
|
23 | |||
24 |
|
|
24 | DateTimeRange dateTime() const noexcept; | |
25 |
|
25 | |||
26 | /// Returns the MIME data associated to a time range |
|
26 | /// Returns the MIME data associated to a time range | |
27 |
static QByteArray mimeDataForTimeRange(const |
|
27 | static QByteArray mimeDataForTimeRange(const DateTimeRange &timeRange); | |
28 |
|
28 | |||
29 | /// Returns the time range contained in a MIME data |
|
29 | /// Returns the time range contained in a MIME data | |
30 |
static |
|
30 | static DateTimeRange timeRangeForMimeData(const QByteArray &mimeData); | |
31 |
|
31 | |||
32 | signals: |
|
32 | signals: | |
33 | /// Signal emitted to notify that time parameters has beed updated |
|
33 | /// Signal emitted to notify that time parameters has beed updated | |
34 |
void timeUpdated( |
|
34 | void timeUpdated(DateTimeRange time); | |
35 |
|
35 | |||
36 | public slots: |
|
36 | public slots: | |
37 | /// Slot called when a new dateTime has been defined. |
|
37 | /// Slot called when a new dateTime has been defined. | |
38 |
void setDateTimeRange( |
|
38 | void setDateTimeRange(DateTimeRange dateTime); | |
39 |
|
39 | |||
40 | /// Slot called when the dateTime has to be notified. Call timeUpdated signal |
|
40 | /// Slot called when the dateTime has to be notified. Call timeUpdated signal | |
41 | void onTimeNotify(); |
|
41 | void onTimeNotify(); |
@@ -35,10 +35,10 public: | |||||
35 |
|
35 | |||
36 | QString name() const noexcept; |
|
36 | QString name() const noexcept; | |
37 | void setName(const QString &name) noexcept; |
|
37 | void setName(const QString &name) noexcept; | |
38 |
|
|
38 | DateTimeRange range() const noexcept; | |
39 |
void setRange(const |
|
39 | void setRange(const DateTimeRange &range) noexcept; | |
40 |
|
|
40 | DateTimeRange cacheRange() const noexcept; | |
41 |
void setCacheRange(const |
|
41 | void setCacheRange(const DateTimeRange &cacheRange) noexcept; | |
42 |
|
42 | |||
43 | /// @return the number of points hold by the variable. The number of points is updated each time |
|
43 | /// @return the number of points hold by the variable. The number of points is updated each time | |
44 | /// the data series changes |
|
44 | /// the data series changes | |
@@ -50,7 +50,7 public: | |||||
50 | /// @return the real range, invalid range if the data series is null or empty |
|
50 | /// @return the real range, invalid range if the data series is null or empty | |
51 | /// @sa setDataSeries() |
|
51 | /// @sa setDataSeries() | |
52 | /// @sa setRange() |
|
52 | /// @sa setRange() | |
53 |
|
|
53 | DateTimeRange realRange() const noexcept; | |
54 |
|
54 | |||
55 | /// @return the data of the variable, nullptr if there is no data |
|
55 | /// @return the data of the variable, nullptr if there is no data | |
56 | std::shared_ptr<IDataSeries> dataSeries() const noexcept; |
|
56 | std::shared_ptr<IDataSeries> dataSeries() const noexcept; | |
@@ -60,23 +60,23 public: | |||||
60 |
|
60 | |||
61 | QVariantHash metadata() const noexcept; |
|
61 | QVariantHash metadata() const noexcept; | |
62 |
|
62 | |||
63 |
bool contains(const |
|
63 | bool contains(const DateTimeRange &range) const noexcept; | |
64 |
bool intersect(const |
|
64 | bool intersect(const DateTimeRange &range) const noexcept; | |
65 |
bool isInside(const |
|
65 | bool isInside(const DateTimeRange &range) const noexcept; | |
66 |
|
66 | |||
67 |
bool cacheContains(const |
|
67 | bool cacheContains(const DateTimeRange &range) const noexcept; | |
68 |
bool cacheIntersect(const |
|
68 | bool cacheIntersect(const DateTimeRange &range) const noexcept; | |
69 |
bool cacheIsInside(const |
|
69 | bool cacheIsInside(const DateTimeRange &range) const noexcept; | |
70 |
|
70 | |||
71 |
QVector< |
|
71 | QVector<DateTimeRange> provideNotInCacheRangeList(const DateTimeRange &range) const noexcept; | |
72 |
QVector< |
|
72 | QVector<DateTimeRange> provideInCacheRangeList(const DateTimeRange &range) const noexcept; | |
73 | void mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept; |
|
73 | void mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept; | |
74 |
|
74 | |||
75 |
static QVector< |
|
75 | static QVector<DateTimeRange> provideNotInCacheRangeList(const DateTimeRange &oldRange, | |
76 |
const |
|
76 | const DateTimeRange &nextRange); | |
77 |
|
77 | |||
78 |
static QVector< |
|
78 | static QVector<DateTimeRange> provideInCacheRangeList(const DateTimeRange &oldRange, | |
79 |
const |
|
79 | const DateTimeRange &nextRange); | |
80 |
|
80 | |||
81 | signals: |
|
81 | signals: | |
82 | void updated(); |
|
82 | void updated(); |
@@ -28,8 +28,8 public: | |||||
28 | explicit VariableAcquisitionWorker(QObject *parent = 0); |
|
28 | explicit VariableAcquisitionWorker(QObject *parent = 0); | |
29 | virtual ~VariableAcquisitionWorker(); |
|
29 | virtual ~VariableAcquisitionWorker(); | |
30 |
|
30 | |||
31 |
QUuid pushVariableRequest(QUuid varRequestId, QUuid vIdentifier, |
|
31 | QUuid pushVariableRequest(QUuid varRequestId, QUuid vIdentifier, DateTimeRange rangeRequested, | |
32 |
|
|
32 | DateTimeRange cacheRangeRequested, DataProviderParameters parameters, | |
33 | std::shared_ptr<IDataProvider> provider); |
|
33 | std::shared_ptr<IDataProvider> provider); | |
34 |
|
34 | |||
35 | void abortProgressRequested(QUuid vIdentifier); |
|
35 | void abortProgressRequested(QUuid vIdentifier); | |
@@ -37,8 +37,8 public: | |||||
37 | void initialize(); |
|
37 | void initialize(); | |
38 | void finalize(); |
|
38 | void finalize(); | |
39 | signals: |
|
39 | signals: | |
40 |
void dataProvided(QUuid vIdentifier, const |
|
40 | void dataProvided(QUuid vIdentifier, const DateTimeRange &rangeRequested, | |
41 |
const |
|
41 | const DateTimeRange &cacheRangeRequested, | |
42 | QVector<AcquisitionDataPacket> dataAcquired); |
|
42 | QVector<AcquisitionDataPacket> dataAcquired); | |
43 |
|
43 | |||
44 | void variableRequestInProgress(QUuid vIdentifier, double progress); |
|
44 | void variableRequestInProgress(QUuid vIdentifier, double progress); | |
@@ -49,7 +49,7 signals: | |||||
49 |
|
49 | |||
50 | public slots: |
|
50 | public slots: | |
51 | void onVariableDataAcquired(QUuid acqIdentifier, std::shared_ptr<IDataSeries> dataSeries, |
|
51 | void onVariableDataAcquired(QUuid acqIdentifier, std::shared_ptr<IDataSeries> dataSeries, | |
52 |
|
|
52 | DateTimeRange dataRangeAcquired); | |
53 | void onVariableRetrieveDataInProgress(QUuid acqIdentifier, double progress); |
|
53 | void onVariableRetrieveDataInProgress(QUuid acqIdentifier, double progress); | |
54 | void onVariableAcquisitionFailed(QUuid acqIdentifier); |
|
54 | void onVariableAcquisitionFailed(QUuid acqIdentifier); | |
55 |
|
55 |
@@ -23,17 +23,17 public: | |||||
23 | explicit VariableCacheController(QObject *parent = 0); |
|
23 | explicit VariableCacheController(QObject *parent = 0); | |
24 |
|
24 | |||
25 |
|
25 | |||
26 |
void addDateTime(std::shared_ptr<Variable> variable, const |
|
26 | void addDateTime(std::shared_ptr<Variable> variable, const DateTimeRange &dateTime); | |
27 |
|
27 | |||
28 | /// Clears cache concerning a variable |
|
28 | /// Clears cache concerning a variable | |
29 | void clear(std::shared_ptr<Variable> variable) noexcept; |
|
29 | void clear(std::shared_ptr<Variable> variable) noexcept; | |
30 |
|
30 | |||
31 | /// Return all of the SqpDataTime part of the dateTime whose are not in the cache |
|
31 | /// Return all of the SqpDataTime part of the dateTime whose are not in the cache | |
32 |
QVector< |
|
32 | QVector<DateTimeRange> provideNotInCacheDateTimeList(std::shared_ptr<Variable> variable, | |
33 |
const |
|
33 | const DateTimeRange &dateTime); | |
34 |
|
34 | |||
35 |
|
35 | |||
36 |
QVector< |
|
36 | QVector<DateTimeRange> dateCacheList(std::shared_ptr<Variable> variable) const noexcept; | |
37 |
|
37 | |||
38 | void displayCache(std::shared_ptr<Variable> variable) const; |
|
38 | void displayCache(std::shared_ptr<Variable> variable) const; | |
39 |
|
39 |
@@ -23,8 +23,8 class SCIQLOP_CORE_EXPORT VariableCacheStrategy { | |||||
23 |
|
23 | |||
24 | public: |
|
24 | public: | |
25 | virtual ~VariableCacheStrategy() noexcept = default; |
|
25 | virtual ~VariableCacheStrategy() noexcept = default; | |
26 |
virtual std::pair< |
|
26 | virtual std::pair<DateTimeRange, DateTimeRange> computeRange(const DateTimeRange &vRange, | |
27 |
const |
|
27 | const DateTimeRange &rangeRequested) | |
28 | = 0; |
|
28 | = 0; | |
29 | }; |
|
29 | }; | |
30 |
|
30 |
@@ -53,7 +53,7 public: | |||||
53 | /// Returns the list of variables contained in a MIME data |
|
53 | /// Returns the list of variables contained in a MIME data | |
54 | QList<std::shared_ptr<Variable> > variablesForMimeData(const QByteArray &mimeData) const; |
|
54 | QList<std::shared_ptr<Variable> > variablesForMimeData(const QByteArray &mimeData) const; | |
55 |
|
55 | |||
56 |
static AcquisitionZoomType getZoomType(const |
|
56 | static AcquisitionZoomType getZoomType(const DateTimeRange &range, const DateTimeRange &oldRange); | |
57 |
|
57 | |||
58 | /// Returns True if there are pending downloads |
|
58 | /// Returns True if there are pending downloads | |
59 | bool hasPendingDownloads(); |
|
59 | bool hasPendingDownloads(); | |
@@ -62,10 +62,10 signals: | |||||
62 | void variableAboutToBeDeleted(std::shared_ptr<Variable> variable); |
|
62 | void variableAboutToBeDeleted(std::shared_ptr<Variable> variable); | |
63 |
|
63 | |||
64 | /// Signal emitted when a data acquisition is requested on a range for a variable |
|
64 | /// Signal emitted when a data acquisition is requested on a range for a variable | |
65 |
void rangeChanged(std::shared_ptr<Variable> variable, const |
|
65 | void rangeChanged(std::shared_ptr<Variable> variable, const DateTimeRange &range); | |
66 |
|
66 | |||
67 | /// Signal emitted when a sub range of the cacheRange of the variable can be displayed |
|
67 | /// Signal emitted when a sub range of the cacheRange of the variable can be displayed | |
68 |
void updateVarDisplaying(std::shared_ptr<Variable> variable, const |
|
68 | void updateVarDisplaying(std::shared_ptr<Variable> variable, const DateTimeRange &range); | |
69 |
|
69 | |||
70 | /// Signal emitted when all acquisitions related to the variables have been completed (whether |
|
70 | /// Signal emitted when all acquisitions related to the variables have been completed (whether | |
71 | /// validated, canceled, or failed) |
|
71 | /// validated, canceled, or failed) | |
@@ -95,7 +95,7 public slots: | |||||
95 | void deleteVariables(const QVector<std::shared_ptr<Variable> > &variables) noexcept; |
|
95 | void deleteVariables(const QVector<std::shared_ptr<Variable> > &variables) noexcept; | |
96 |
|
96 | |||
97 | /// Request the data loading of the variable whithin range |
|
97 | /// Request the data loading of the variable whithin range | |
98 |
void onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, const |
|
98 | void onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, const DateTimeRange &range, | |
99 | bool synchronise); |
|
99 | bool synchronise); | |
100 | /** |
|
100 | /** | |
101 | * Creates a new variable and adds it to the model |
|
101 | * Creates a new variable and adds it to the model | |
@@ -105,17 +105,17 public slots: | |||||
105 | * @return the pointer to the new variable or nullptr if the creation failed |
|
105 | * @return the pointer to the new variable or nullptr if the creation failed | |
106 | */ |
|
106 | */ | |
107 | std::shared_ptr<Variable> createVariable(const QString &name, const QVariantHash &metadata, |
|
107 | std::shared_ptr<Variable> createVariable(const QString &name, const QVariantHash &metadata, | |
108 |
std::shared_ptr<IDataProvider> provider, const |
|
108 | std::shared_ptr<IDataProvider> provider, const DateTimeRange &range) noexcept; | |
109 |
|
109 | |||
110 | /// Update the temporal parameters of every selected variable to dateTime |
|
110 | /// Update the temporal parameters of every selected variable to dateTime | |
111 |
void onDateTimeOnSelection(const |
|
111 | void onDateTimeOnSelection(const DateTimeRange &dateTime); | |
112 |
|
112 | |||
113 | /// Update the temporal parameters of the specified variable |
|
113 | /// Update the temporal parameters of the specified variable | |
114 |
void onUpdateDateTime(std::shared_ptr<Variable> variable, const |
|
114 | void onUpdateDateTime(std::shared_ptr<Variable> variable, const DateTimeRange &dateTime); | |
115 |
|
115 | |||
116 |
|
116 | |||
117 |
void onDataProvided(QUuid vIdentifier, const |
|
117 | void onDataProvided(QUuid vIdentifier, const DateTimeRange &rangeRequested, | |
118 |
const |
|
118 | const DateTimeRange &cacheRangeRequested, | |
119 | QVector<AcquisitionDataPacket> dataAcquired); |
|
119 | QVector<AcquisitionDataPacket> dataAcquired); | |
120 |
|
120 | |||
121 | void onVariableRetrieveDataInProgress(QUuid identifier, double progress); |
|
121 | void onVariableRetrieveDataInProgress(QUuid identifier, double progress); |
@@ -94,7 +94,7 public: | |||||
94 | signals: |
|
94 | signals: | |
95 | void abortProgessRequested(std::shared_ptr<Variable> variable); |
|
95 | void abortProgessRequested(std::shared_ptr<Variable> variable); | |
96 | void requestVariable(const QVariantHash &productData); |
|
96 | void requestVariable(const QVariantHash &productData); | |
97 |
void requestVariableRangeUpdate(std::shared_ptr<Variable> variable, const |
|
97 | void requestVariableRangeUpdate(std::shared_ptr<Variable> variable, const DateTimeRange &range); | |
98 |
|
98 | |||
99 | private: |
|
99 | private: | |
100 | class VariableModelPrivate; |
|
100 | class VariableModelPrivate; |
@@ -10,11 +10,11 class SCIQLOP_CORE_EXPORT VariableSingleThresholdCacheStrategy : public Variable | |||||
10 | public: |
|
10 | public: | |
11 | VariableSingleThresholdCacheStrategy() = default; |
|
11 | VariableSingleThresholdCacheStrategy() = default; | |
12 |
|
12 | |||
13 |
std::pair< |
|
13 | std::pair<DateTimeRange, DateTimeRange> computeRange(const DateTimeRange &vRange, | |
14 |
const |
|
14 | const DateTimeRange &rangeRequested) override | |
15 | { |
|
15 | { | |
16 |
|
16 | |||
17 |
auto varRanges = std::pair< |
|
17 | auto varRanges = std::pair<DateTimeRange, DateTimeRange>{}; | |
18 |
|
18 | |||
19 | auto toleranceFactor = SqpSettings::toleranceValue( |
|
19 | auto toleranceFactor = SqpSettings::toleranceValue( | |
20 | GENERAL_TOLERANCE_AT_UPDATE_KEY, GENERAL_TOLERANCE_AT_UPDATE_DEFAULT_VALUE); |
|
20 | GENERAL_TOLERANCE_AT_UPDATE_KEY, GENERAL_TOLERANCE_AT_UPDATE_DEFAULT_VALUE); | |
@@ -22,7 +22,7 public: | |||||
22 |
|
22 | |||
23 | varRanges.first = rangeRequested; |
|
23 | varRanges.first = rangeRequested; | |
24 | varRanges.second |
|
24 | varRanges.second | |
25 |
= |
|
25 | = DateTimeRange{rangeRequested.m_TStart - tolerance, rangeRequested.m_TEnd + tolerance}; | |
26 |
|
26 | |||
27 | return varRanges; |
|
27 | return varRanges; | |
28 | } |
|
28 | } |
@@ -23,10 +23,11 class Variable; | |||||
23 | class SCIQLOP_CORE_EXPORT VariableSynchronizationGroup : public QObject { |
|
23 | class SCIQLOP_CORE_EXPORT VariableSynchronizationGroup : public QObject { | |
24 | Q_OBJECT |
|
24 | Q_OBJECT | |
25 | public: |
|
25 | public: | |
26 |
explicit VariableSynchronizationGroup(QObject *parent = |
|
26 | explicit VariableSynchronizationGroup(QObject *parent = Q_NULLPTR); | |
|
27 | explicit VariableSynchronizationGroup(QUuid variable, QObject *parent = Q_NULLPTR); | |||
27 |
|
28 | |||
28 |
void addVariable |
|
29 | void addVariable(QUuid vIdentifier); | |
29 |
void removeVariable |
|
30 | void removeVariable(QUuid vIdentifier); | |
30 |
|
31 | |||
31 | const std::set<QUuid> &getIds() const noexcept; |
|
32 | const std::set<QUuid> &getIds() const noexcept; | |
32 |
|
33 |
@@ -34,7 +34,7 signals: | |||||
34 | void variableAboutToBeDeleted(std::shared_ptr<Variable> variable); |
|
34 | void variableAboutToBeDeleted(std::shared_ptr<Variable> variable); | |
35 |
|
35 | |||
36 | /// Signal emitted when a data acquisition is requested on a range for a variable |
|
36 | /// Signal emitted when a data acquisition is requested on a range for a variable | |
37 |
void rangeChanged(std::shared_ptr<Variable> variable, const |
|
37 | void rangeChanged(std::shared_ptr<Variable> variable, const DateTimeRange &range); | |
38 |
|
38 | |||
39 | public slots: |
|
39 | public slots: | |
40 | /// Manage init/end of the controller |
|
40 | /// Manage init/end of the controller |
@@ -12,7 +12,7 std::unique_ptr<IDataSeries> ScalarSeries::clone() const | |||||
12 | return std::make_unique<ScalarSeries>(*this); |
|
12 | return std::make_unique<ScalarSeries>(*this); | |
13 | } |
|
13 | } | |
14 |
|
14 | |||
15 |
std::shared_ptr<IDataSeries> ScalarSeries::subDataSeries(const |
|
15 | std::shared_ptr<IDataSeries> ScalarSeries::subDataSeries(const DateTimeRange &range) | |
16 | { |
|
16 | { | |
17 | auto subXAxisData = std::vector<double>(); |
|
17 | auto subXAxisData = std::vector<double>(); | |
18 | auto subValuesData = std::vector<double>(); |
|
18 | auto subValuesData = std::vector<double>(); |
@@ -29,7 +29,7 std::unique_ptr<IDataSeries> SpectrogramSeries::clone() const | |||||
29 | return std::make_unique<SpectrogramSeries>(*this); |
|
29 | return std::make_unique<SpectrogramSeries>(*this); | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 |
std::shared_ptr<IDataSeries> SpectrogramSeries::subDataSeries(const |
|
32 | std::shared_ptr<IDataSeries> SpectrogramSeries::subDataSeries(const DateTimeRange &range) | |
33 | { |
|
33 | { | |
34 | auto subXAxisData = std::vector<double>(); |
|
34 | auto subXAxisData = std::vector<double>(); | |
35 | auto subValuesData = QVector<double>(); // Uses QVector to append easily values to it |
|
35 | auto subValuesData = QVector<double>(); // Uses QVector to append easily values to it |
@@ -61,7 +61,7 std::unique_ptr<IDataSeries> VectorSeries::clone() const | |||||
61 | return std::make_unique<VectorSeries>(*this); |
|
61 | return std::make_unique<VectorSeries>(*this); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 |
std::shared_ptr<IDataSeries> VectorSeries::subDataSeries(const |
|
64 | std::shared_ptr<IDataSeries> VectorSeries::subDataSeries(const DateTimeRange &range) | |
65 | { |
|
65 | { | |
66 | auto subXAxisData = std::vector<double>(); |
|
66 | auto subXAxisData = std::vector<double>(); | |
67 | auto subValuesData = std::vector<double>(); |
|
67 | auto subValuesData = std::vector<double>(); |
@@ -6,7 +6,7 Q_LOGGING_CATEGORY(LOG_TimeController, "TimeController") | |||||
6 |
|
6 | |||
7 | struct TimeController::TimeControllerPrivate { |
|
7 | struct TimeController::TimeControllerPrivate { | |
8 |
|
8 | |||
9 |
|
|
9 | DateTimeRange m_DateTime; | |
10 | }; |
|
10 | }; | |
11 |
|
11 | |||
12 | TimeController::TimeController(QObject *parent) |
|
12 | TimeController::TimeController(QObject *parent) | |
@@ -15,12 +15,12 TimeController::TimeController(QObject *parent) | |||||
15 | qCDebug(LOG_TimeController()) << tr("TimeController construction"); |
|
15 | qCDebug(LOG_TimeController()) << tr("TimeController construction"); | |
16 | } |
|
16 | } | |
17 |
|
17 | |||
18 |
|
|
18 | DateTimeRange TimeController::dateTime() const noexcept | |
19 | { |
|
19 | { | |
20 | return impl->m_DateTime; |
|
20 | return impl->m_DateTime; | |
21 | } |
|
21 | } | |
22 |
|
22 | |||
23 |
QByteArray TimeController::mimeDataForTimeRange(const |
|
23 | QByteArray TimeController::mimeDataForTimeRange(const DateTimeRange &timeRange) | |
24 | { |
|
24 | { | |
25 | QByteArray encodedData; |
|
25 | QByteArray encodedData; | |
26 | QDataStream stream{&encodedData, QIODevice::WriteOnly}; |
|
26 | QDataStream stream{&encodedData, QIODevice::WriteOnly}; | |
@@ -30,17 +30,17 QByteArray TimeController::mimeDataForTimeRange(const SqpRange &timeRange) | |||||
30 | return encodedData; |
|
30 | return encodedData; | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 |
|
|
33 | DateTimeRange TimeController::timeRangeForMimeData(const QByteArray &mimeData) | |
34 | { |
|
34 | { | |
35 | QDataStream stream{mimeData}; |
|
35 | QDataStream stream{mimeData}; | |
36 |
|
36 | |||
37 |
|
|
37 | DateTimeRange timeRange; | |
38 | stream >> timeRange.m_TStart >> timeRange.m_TEnd; |
|
38 | stream >> timeRange.m_TStart >> timeRange.m_TEnd; | |
39 |
|
39 | |||
40 | return timeRange; |
|
40 | return timeRange; | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 |
void TimeController::setDateTimeRange( |
|
43 | void TimeController::setDateTimeRange(DateTimeRange dateTime) | |
44 | { |
|
44 | { | |
45 | impl->m_DateTime = dateTime; |
|
45 | impl->m_DateTime = dateTime; | |
46 | } |
|
46 | } |
@@ -83,7 +83,7 struct Variable::VariablePrivate { | |||||
83 |
|
83 | |||
84 | m_RealRange |
|
84 | m_RealRange | |
85 | = (minXAxisIt != end && maxXAxisIt != end && minXAxisIt->x() <= maxXAxisIt->x()) |
|
85 | = (minXAxisIt != end && maxXAxisIt != end && minXAxisIt->x() <= maxXAxisIt->x()) | |
86 |
? |
|
86 | ? DateTimeRange{minXAxisIt->x(), maxXAxisIt->x()} | |
87 | : INVALID_RANGE; |
|
87 | : INVALID_RANGE; | |
88 | m_DataSeries->unlock(); |
|
88 | m_DataSeries->unlock(); | |
89 | } |
|
89 | } | |
@@ -94,11 +94,11 struct Variable::VariablePrivate { | |||||
94 |
|
94 | |||
95 | QString m_Name; |
|
95 | QString m_Name; | |
96 |
|
96 | |||
97 |
|
|
97 | DateTimeRange m_Range; | |
98 |
|
|
98 | DateTimeRange m_CacheRange; | |
99 | QVariantHash m_Metadata; |
|
99 | QVariantHash m_Metadata; | |
100 | std::shared_ptr<IDataSeries> m_DataSeries; |
|
100 | std::shared_ptr<IDataSeries> m_DataSeries; | |
101 |
|
|
101 | DateTimeRange m_RealRange; | |
102 | int m_NbPoints; |
|
102 | int m_NbPoints; | |
103 | DataSeriesType m_Type; |
|
103 | DataSeriesType m_Type; | |
104 |
|
104 | |||
@@ -135,7 +135,7 void Variable::setName(const QString &name) noexcept | |||||
135 | impl->unlock(); |
|
135 | impl->unlock(); | |
136 | } |
|
136 | } | |
137 |
|
137 | |||
138 |
|
|
138 | DateTimeRange Variable::range() const noexcept | |
139 | { |
|
139 | { | |
140 | impl->lockRead(); |
|
140 | impl->lockRead(); | |
141 | auto range = impl->m_Range; |
|
141 | auto range = impl->m_Range; | |
@@ -143,7 +143,7 SqpRange Variable::range() const noexcept | |||||
143 | return range; |
|
143 | return range; | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 |
void Variable::setRange(const |
|
146 | void Variable::setRange(const DateTimeRange &range) noexcept | |
147 | { |
|
147 | { | |
148 | impl->lockWrite(); |
|
148 | impl->lockWrite(); | |
149 | impl->m_Range = range; |
|
149 | impl->m_Range = range; | |
@@ -151,7 +151,7 void Variable::setRange(const SqpRange &range) noexcept | |||||
151 | impl->unlock(); |
|
151 | impl->unlock(); | |
152 | } |
|
152 | } | |
153 |
|
153 | |||
154 |
|
|
154 | DateTimeRange Variable::cacheRange() const noexcept | |
155 | { |
|
155 | { | |
156 | impl->lockRead(); |
|
156 | impl->lockRead(); | |
157 | auto cacheRange = impl->m_CacheRange; |
|
157 | auto cacheRange = impl->m_CacheRange; | |
@@ -159,7 +159,7 SqpRange Variable::cacheRange() const noexcept | |||||
159 | return cacheRange; |
|
159 | return cacheRange; | |
160 | } |
|
160 | } | |
161 |
|
161 | |||
162 |
void Variable::setCacheRange(const |
|
162 | void Variable::setCacheRange(const DateTimeRange &cacheRange) noexcept | |
163 | { |
|
163 | { | |
164 | impl->lockWrite(); |
|
164 | impl->lockWrite(); | |
165 | if (cacheRange != impl->m_CacheRange) { |
|
165 | if (cacheRange != impl->m_CacheRange) { | |
@@ -173,7 +173,7 int Variable::nbPoints() const noexcept | |||||
173 | return impl->m_NbPoints; |
|
173 | return impl->m_NbPoints; | |
174 | } |
|
174 | } | |
175 |
|
175 | |||
176 |
|
|
176 | DateTimeRange Variable::realRange() const noexcept | |
177 | { |
|
177 | { | |
178 | return impl->m_RealRange; |
|
178 | return impl->m_RealRange; | |
179 | } |
|
179 | } | |
@@ -233,7 +233,7 QVariantHash Variable::metadata() const noexcept | |||||
233 | return metadata; |
|
233 | return metadata; | |
234 | } |
|
234 | } | |
235 |
|
235 | |||
236 |
bool Variable::contains(const |
|
236 | bool Variable::contains(const DateTimeRange &range) const noexcept | |
237 | { |
|
237 | { | |
238 | impl->lockRead(); |
|
238 | impl->lockRead(); | |
239 | auto res = impl->m_Range.contains(range); |
|
239 | auto res = impl->m_Range.contains(range); | |
@@ -241,7 +241,7 bool Variable::contains(const SqpRange &range) const noexcept | |||||
241 | return res; |
|
241 | return res; | |
242 | } |
|
242 | } | |
243 |
|
243 | |||
244 |
bool Variable::intersect(const |
|
244 | bool Variable::intersect(const DateTimeRange &range) const noexcept | |
245 | { |
|
245 | { | |
246 |
|
246 | |||
247 | impl->lockRead(); |
|
247 | impl->lockRead(); | |
@@ -250,15 +250,15 bool Variable::intersect(const SqpRange &range) const noexcept | |||||
250 | return res; |
|
250 | return res; | |
251 | } |
|
251 | } | |
252 |
|
252 | |||
253 |
bool Variable::isInside(const |
|
253 | bool Variable::isInside(const DateTimeRange &range) const noexcept | |
254 | { |
|
254 | { | |
255 | impl->lockRead(); |
|
255 | impl->lockRead(); | |
256 |
auto res = range.contains( |
|
256 | auto res = range.contains(DateTimeRange{impl->m_Range.m_TStart, impl->m_Range.m_TEnd}); | |
257 | impl->unlock(); |
|
257 | impl->unlock(); | |
258 | return res; |
|
258 | return res; | |
259 | } |
|
259 | } | |
260 |
|
260 | |||
261 |
bool Variable::cacheContains(const |
|
261 | bool Variable::cacheContains(const DateTimeRange &range) const noexcept | |
262 | { |
|
262 | { | |
263 | impl->lockRead(); |
|
263 | impl->lockRead(); | |
264 | auto res = impl->m_CacheRange.contains(range); |
|
264 | auto res = impl->m_CacheRange.contains(range); | |
@@ -266,7 +266,7 bool Variable::cacheContains(const SqpRange &range) const noexcept | |||||
266 | return res; |
|
266 | return res; | |
267 | } |
|
267 | } | |
268 |
|
268 | |||
269 |
bool Variable::cacheIntersect(const |
|
269 | bool Variable::cacheIntersect(const DateTimeRange &range) const noexcept | |
270 | { |
|
270 | { | |
271 | impl->lockRead(); |
|
271 | impl->lockRead(); | |
272 | auto res = impl->m_CacheRange.intersect(range); |
|
272 | auto res = impl->m_CacheRange.intersect(range); | |
@@ -274,19 +274,19 bool Variable::cacheIntersect(const SqpRange &range) const noexcept | |||||
274 | return res; |
|
274 | return res; | |
275 | } |
|
275 | } | |
276 |
|
276 | |||
277 |
bool Variable::cacheIsInside(const |
|
277 | bool Variable::cacheIsInside(const DateTimeRange &range) const noexcept | |
278 | { |
|
278 | { | |
279 | impl->lockRead(); |
|
279 | impl->lockRead(); | |
280 |
auto res = range.contains( |
|
280 | auto res = range.contains(DateTimeRange{impl->m_CacheRange.m_TStart, impl->m_CacheRange.m_TEnd}); | |
281 | impl->unlock(); |
|
281 | impl->unlock(); | |
282 | return res; |
|
282 | return res; | |
283 | } |
|
283 | } | |
284 |
|
284 | |||
285 |
|
285 | |||
286 |
QVector< |
|
286 | QVector<DateTimeRange> Variable::provideNotInCacheRangeList(const DateTimeRange &range) const noexcept | |
287 | { |
|
287 | { | |
288 | // This code assume that cach in contigue. Can return 0, 1 or 2 SqpRange |
|
288 | // This code assume that cach in contigue. Can return 0, 1 or 2 SqpRange | |
289 |
auto notInCache = QVector< |
|
289 | auto notInCache = QVector<DateTimeRange>{}; | |
290 | if (impl->m_CacheRange != INVALID_RANGE) { |
|
290 | if (impl->m_CacheRange != INVALID_RANGE) { | |
291 |
|
291 | |||
292 | if (!this->cacheContains(range)) { |
|
292 | if (!this->cacheContains(range)) { | |
@@ -296,15 +296,15 QVector<SqpRange> Variable::provideNotInCacheRangeList(const SqpRange &range) co | |||||
296 | } |
|
296 | } | |
297 | else if (range.m_TStart < impl->m_CacheRange.m_TStart |
|
297 | else if (range.m_TStart < impl->m_CacheRange.m_TStart | |
298 | && range.m_TEnd <= impl->m_CacheRange.m_TEnd) { |
|
298 | && range.m_TEnd <= impl->m_CacheRange.m_TEnd) { | |
299 |
notInCache << |
|
299 | notInCache << DateTimeRange{range.m_TStart, impl->m_CacheRange.m_TStart}; | |
300 | } |
|
300 | } | |
301 | else if (range.m_TStart < impl->m_CacheRange.m_TStart |
|
301 | else if (range.m_TStart < impl->m_CacheRange.m_TStart | |
302 | && range.m_TEnd > impl->m_CacheRange.m_TEnd) { |
|
302 | && range.m_TEnd > impl->m_CacheRange.m_TEnd) { | |
303 |
notInCache << |
|
303 | notInCache << DateTimeRange{range.m_TStart, impl->m_CacheRange.m_TStart} | |
304 |
<< |
|
304 | << DateTimeRange{impl->m_CacheRange.m_TEnd, range.m_TEnd}; | |
305 | } |
|
305 | } | |
306 | else if (range.m_TStart < impl->m_CacheRange.m_TEnd) { |
|
306 | else if (range.m_TStart < impl->m_CacheRange.m_TEnd) { | |
307 |
notInCache << |
|
307 | notInCache << DateTimeRange{impl->m_CacheRange.m_TEnd, range.m_TEnd}; | |
308 | } |
|
308 | } | |
309 | else { |
|
309 | else { | |
310 | qCCritical(LOG_Variable()) << tr("Detection of unknown case.") |
|
310 | qCCritical(LOG_Variable()) << tr("Detection of unknown case.") | |
@@ -319,11 +319,11 QVector<SqpRange> Variable::provideNotInCacheRangeList(const SqpRange &range) co | |||||
319 | return notInCache; |
|
319 | return notInCache; | |
320 | } |
|
320 | } | |
321 |
|
321 | |||
322 |
QVector< |
|
322 | QVector<DateTimeRange> Variable::provideInCacheRangeList(const DateTimeRange &range) const noexcept | |
323 | { |
|
323 | { | |
324 | // This code assume that cach in contigue. Can return 0 or 1 SqpRange |
|
324 | // This code assume that cach in contigue. Can return 0 or 1 SqpRange | |
325 |
|
325 | |||
326 |
auto inCache = QVector< |
|
326 | auto inCache = QVector<DateTimeRange>{}; | |
327 |
|
327 | |||
328 | if (impl->m_CacheRange != INVALID_RANGE) { |
|
328 | if (impl->m_CacheRange != INVALID_RANGE) { | |
329 |
|
329 | |||
@@ -331,7 +331,7 QVector<SqpRange> Variable::provideInCacheRangeList(const SqpRange &range) const | |||||
331 | if (range.m_TStart <= impl->m_CacheRange.m_TStart |
|
331 | if (range.m_TStart <= impl->m_CacheRange.m_TStart | |
332 | && range.m_TEnd >= impl->m_CacheRange.m_TStart |
|
332 | && range.m_TEnd >= impl->m_CacheRange.m_TStart | |
333 | && range.m_TEnd < impl->m_CacheRange.m_TEnd) { |
|
333 | && range.m_TEnd < impl->m_CacheRange.m_TEnd) { | |
334 |
inCache << |
|
334 | inCache << DateTimeRange{impl->m_CacheRange.m_TStart, range.m_TEnd}; | |
335 | } |
|
335 | } | |
336 |
|
336 | |||
337 | else if (range.m_TStart >= impl->m_CacheRange.m_TStart |
|
337 | else if (range.m_TStart >= impl->m_CacheRange.m_TStart | |
@@ -340,7 +340,7 QVector<SqpRange> Variable::provideInCacheRangeList(const SqpRange &range) const | |||||
340 | } |
|
340 | } | |
341 | else if (range.m_TStart > impl->m_CacheRange.m_TStart |
|
341 | else if (range.m_TStart > impl->m_CacheRange.m_TStart | |
342 | && range.m_TEnd > impl->m_CacheRange.m_TEnd) { |
|
342 | && range.m_TEnd > impl->m_CacheRange.m_TEnd) { | |
343 |
inCache << |
|
343 | inCache << DateTimeRange{range.m_TStart, impl->m_CacheRange.m_TEnd}; | |
344 | } |
|
344 | } | |
345 | else if (range.m_TStart <= impl->m_CacheRange.m_TStart |
|
345 | else if (range.m_TStart <= impl->m_CacheRange.m_TStart | |
346 | && range.m_TEnd >= impl->m_CacheRange.m_TEnd) { |
|
346 | && range.m_TEnd >= impl->m_CacheRange.m_TEnd) { | |
@@ -357,12 +357,12 QVector<SqpRange> Variable::provideInCacheRangeList(const SqpRange &range) const | |||||
357 | } |
|
357 | } | |
358 |
|
358 | |||
359 |
|
359 | |||
360 |
QVector< |
|
360 | QVector<DateTimeRange> Variable::provideNotInCacheRangeList(const DateTimeRange &oldRange, | |
361 |
const |
|
361 | const DateTimeRange &nextRange) | |
362 | { |
|
362 | { | |
363 |
|
363 | |||
364 | // This code assume that cach in contigue. Can return 0, 1 or 2 SqpRange |
|
364 | // This code assume that cach in contigue. Can return 0, 1 or 2 SqpRange | |
365 |
auto notInCache = QVector< |
|
365 | auto notInCache = QVector<DateTimeRange>{}; | |
366 | if (oldRange != INVALID_RANGE) { |
|
366 | if (oldRange != INVALID_RANGE) { | |
367 |
|
367 | |||
368 | if (!oldRange.contains(nextRange)) { |
|
368 | if (!oldRange.contains(nextRange)) { | |
@@ -371,14 +371,14 QVector<SqpRange> Variable::provideNotInCacheRangeList(const SqpRange &oldRange, | |||||
371 | } |
|
371 | } | |
372 | else if (nextRange.m_TStart < oldRange.m_TStart |
|
372 | else if (nextRange.m_TStart < oldRange.m_TStart | |
373 | && nextRange.m_TEnd <= oldRange.m_TEnd) { |
|
373 | && nextRange.m_TEnd <= oldRange.m_TEnd) { | |
374 |
notInCache << |
|
374 | notInCache << DateTimeRange{nextRange.m_TStart, oldRange.m_TStart}; | |
375 | } |
|
375 | } | |
376 | else if (nextRange.m_TStart < oldRange.m_TStart && nextRange.m_TEnd > oldRange.m_TEnd) { |
|
376 | else if (nextRange.m_TStart < oldRange.m_TStart && nextRange.m_TEnd > oldRange.m_TEnd) { | |
377 |
notInCache << |
|
377 | notInCache << DateTimeRange{nextRange.m_TStart, oldRange.m_TStart} | |
378 |
<< |
|
378 | << DateTimeRange{oldRange.m_TEnd, nextRange.m_TEnd}; | |
379 | } |
|
379 | } | |
380 | else if (nextRange.m_TStart < oldRange.m_TEnd) { |
|
380 | else if (nextRange.m_TStart < oldRange.m_TEnd) { | |
381 |
notInCache << |
|
381 | notInCache << DateTimeRange{oldRange.m_TEnd, nextRange.m_TEnd}; | |
382 | } |
|
382 | } | |
383 | else { |
|
383 | else { | |
384 | qCCritical(LOG_Variable()) << tr("Detection of unknown case.") |
|
384 | qCCritical(LOG_Variable()) << tr("Detection of unknown case.") | |
@@ -393,19 +393,19 QVector<SqpRange> Variable::provideNotInCacheRangeList(const SqpRange &oldRange, | |||||
393 | return notInCache; |
|
393 | return notInCache; | |
394 | } |
|
394 | } | |
395 |
|
395 | |||
396 |
QVector< |
|
396 | QVector<DateTimeRange> Variable::provideInCacheRangeList(const DateTimeRange &oldRange, | |
397 |
const |
|
397 | const DateTimeRange &nextRange) | |
398 | { |
|
398 | { | |
399 | // This code assume that cach is contigue. Can return 0 or 1 SqpRange |
|
399 | // This code assume that cach is contigue. Can return 0 or 1 SqpRange | |
400 |
|
400 | |||
401 |
auto inCache = QVector< |
|
401 | auto inCache = QVector<DateTimeRange>{}; | |
402 |
|
402 | |||
403 | if (oldRange != INVALID_RANGE) { |
|
403 | if (oldRange != INVALID_RANGE) { | |
404 |
|
404 | |||
405 | if (oldRange.intersect(nextRange)) { |
|
405 | if (oldRange.intersect(nextRange)) { | |
406 | if (nextRange.m_TStart <= oldRange.m_TStart && nextRange.m_TEnd >= oldRange.m_TStart |
|
406 | if (nextRange.m_TStart <= oldRange.m_TStart && nextRange.m_TEnd >= oldRange.m_TStart | |
407 | && nextRange.m_TEnd < oldRange.m_TEnd) { |
|
407 | && nextRange.m_TEnd < oldRange.m_TEnd) { | |
408 |
inCache << |
|
408 | inCache << DateTimeRange{oldRange.m_TStart, nextRange.m_TEnd}; | |
409 | } |
|
409 | } | |
410 |
|
410 | |||
411 | else if (nextRange.m_TStart >= oldRange.m_TStart |
|
411 | else if (nextRange.m_TStart >= oldRange.m_TStart | |
@@ -413,7 +413,7 QVector<SqpRange> Variable::provideInCacheRangeList(const SqpRange &oldRange, | |||||
413 | inCache << nextRange; |
|
413 | inCache << nextRange; | |
414 | } |
|
414 | } | |
415 | else if (nextRange.m_TStart > oldRange.m_TStart && nextRange.m_TEnd > oldRange.m_TEnd) { |
|
415 | else if (nextRange.m_TStart > oldRange.m_TStart && nextRange.m_TEnd > oldRange.m_TEnd) { | |
416 |
inCache << |
|
416 | inCache << DateTimeRange{nextRange.m_TStart, oldRange.m_TEnd}; | |
417 | } |
|
417 | } | |
418 | else if (nextRange.m_TStart <= oldRange.m_TStart |
|
418 | else if (nextRange.m_TStart <= oldRange.m_TStart | |
419 | && nextRange.m_TEnd >= oldRange.m_TEnd) { |
|
419 | && nextRange.m_TEnd >= oldRange.m_TEnd) { |
@@ -60,8 +60,8 VariableAcquisitionWorker::~VariableAcquisitionWorker() | |||||
60 |
|
60 | |||
61 |
|
61 | |||
62 | QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid vIdentifier, |
|
62 | QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid vIdentifier, | |
63 |
|
|
63 | DateTimeRange rangeRequested, | |
64 |
|
|
64 | DateTimeRange cacheRangeRequested, | |
65 | DataProviderParameters parameters, |
|
65 | DataProviderParameters parameters, | |
66 | std::shared_ptr<IDataProvider> provider) |
|
66 | std::shared_ptr<IDataProvider> provider) | |
67 | { |
|
67 | { | |
@@ -196,7 +196,7 void VariableAcquisitionWorker::onVariableAcquisitionFailed(QUuid acqIdentifier) | |||||
196 |
|
196 | |||
197 | void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, |
|
197 | void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, | |
198 | std::shared_ptr<IDataSeries> dataSeries, |
|
198 | std::shared_ptr<IDataSeries> dataSeries, | |
199 |
|
|
199 | DateTimeRange dataRangeAcquired) | |
200 | { |
|
200 | { | |
201 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableDataAcquired on range ") |
|
201 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableDataAcquired on range ") | |
202 | << acqIdentifier << dataRangeAcquired; |
|
202 | << acqIdentifier << dataRangeAcquired; |
@@ -8,16 +8,16 Q_LOGGING_CATEGORY(LOG_VariableCacheController, "VariableCacheController") | |||||
8 |
|
8 | |||
9 | struct VariableCacheController::VariableCacheControllerPrivate { |
|
9 | struct VariableCacheController::VariableCacheControllerPrivate { | |
10 |
|
10 | |||
11 |
std::unordered_map<std::shared_ptr<Variable>, QVector< |
|
11 | std::unordered_map<std::shared_ptr<Variable>, QVector<DateTimeRange> > m_VariableToSqpRangeListMap; | |
12 |
|
12 | |||
13 |
void addInCacheDataByEnd(const |
|
13 | void addInCacheDataByEnd(const DateTimeRange &dateTime, QVector<DateTimeRange> &dateTimeList, | |
14 |
QVector< |
|
14 | QVector<DateTimeRange> ¬InCache, int cacheIndex, double currentTStart); | |
15 |
|
15 | |||
16 |
void addInCacheDataByStart(const |
|
16 | void addInCacheDataByStart(const DateTimeRange &dateTime, QVector<DateTimeRange> &dateTimeList, | |
17 |
QVector< |
|
17 | QVector<DateTimeRange> ¬InCache, int cacheIndex, double currentTStart); | |
18 |
|
18 | |||
19 |
|
19 | |||
20 |
void addDateTimeRecurse(const |
|
20 | void addDateTimeRecurse(const DateTimeRange &dateTime, QVector<DateTimeRange> &dateTimeList, | |
21 | int cacheIndex); |
|
21 | int cacheIndex); | |
22 | }; |
|
22 | }; | |
23 |
|
23 | |||
@@ -28,7 +28,7 VariableCacheController::VariableCacheController(QObject *parent) | |||||
28 | } |
|
28 | } | |
29 |
|
29 | |||
30 | void VariableCacheController::addDateTime(std::shared_ptr<Variable> variable, |
|
30 | void VariableCacheController::addDateTime(std::shared_ptr<Variable> variable, | |
31 |
const |
|
31 | const DateTimeRange &dateTime) | |
32 | { |
|
32 | { | |
33 | qCDebug(LOG_VariableCacheController()) << "VariableCacheController::addDateTime" |
|
33 | qCDebug(LOG_VariableCacheController()) << "VariableCacheController::addDateTime" | |
34 | << QThread::currentThread()->objectName(); |
|
34 | << QThread::currentThread()->objectName(); | |
@@ -77,14 +77,14 void VariableCacheController::clear(std::shared_ptr<Variable> variable) noexcept | |||||
77 | qCDebug(LOG_VariableCacheController()) << clearCacheMessage; |
|
77 | qCDebug(LOG_VariableCacheController()) << clearCacheMessage; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 |
QVector< |
|
80 | QVector<DateTimeRange> | |
81 | VariableCacheController::provideNotInCacheDateTimeList(std::shared_ptr<Variable> variable, |
|
81 | VariableCacheController::provideNotInCacheDateTimeList(std::shared_ptr<Variable> variable, | |
82 |
const |
|
82 | const DateTimeRange &dateTime) | |
83 | { |
|
83 | { | |
84 | qCDebug(LOG_VariableCacheController()) |
|
84 | qCDebug(LOG_VariableCacheController()) | |
85 | << "VariableCacheController::provideNotInCacheDateTimeList" |
|
85 | << "VariableCacheController::provideNotInCacheDateTimeList" | |
86 | << QThread::currentThread()->objectName(); |
|
86 | << QThread::currentThread()->objectName(); | |
87 |
auto notInCache = QVector< |
|
87 | auto notInCache = QVector<DateTimeRange>{}; | |
88 |
|
88 | |||
89 | // This algorithm is recursif. The idea is to localise the start time then the end time in the |
|
89 | // This algorithm is recursif. The idea is to localise the start time then the end time in the | |
90 | // list of date time request associated to the variable |
|
90 | // list of date time request associated to the variable | |
@@ -101,7 +101,7 VariableCacheController::provideNotInCacheDateTimeList(std::shared_ptr<Variable> | |||||
101 | return notInCache; |
|
101 | return notInCache; | |
102 | } |
|
102 | } | |
103 |
|
103 | |||
104 |
QVector< |
|
104 | QVector<DateTimeRange> | |
105 | VariableCacheController::dateCacheList(std::shared_ptr<Variable> variable) const noexcept |
|
105 | VariableCacheController::dateCacheList(std::shared_ptr<Variable> variable) const noexcept | |
106 | { |
|
106 | { | |
107 | qCDebug(LOG_VariableCacheController()) << "VariableCacheController::dateCacheList" |
|
107 | qCDebug(LOG_VariableCacheController()) << "VariableCacheController::dateCacheList" | |
@@ -111,12 +111,12 VariableCacheController::dateCacheList(std::shared_ptr<Variable> variable) const | |||||
111 | } |
|
111 | } | |
112 | catch (const std::out_of_range &e) { |
|
112 | catch (const std::out_of_range &e) { | |
113 | qCWarning(LOG_VariableCacheController()) << e.what(); |
|
113 | qCWarning(LOG_VariableCacheController()) << e.what(); | |
114 |
return QVector< |
|
114 | return QVector<DateTimeRange>{}; | |
115 | } |
|
115 | } | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void VariableCacheController::VariableCacheControllerPrivate::addDateTimeRecurse( |
|
118 | void VariableCacheController::VariableCacheControllerPrivate::addDateTimeRecurse( | |
119 |
const |
|
119 | const DateTimeRange &dateTime, QVector<DateTimeRange> &dateTimeList, int cacheIndex) | |
120 | { |
|
120 | { | |
121 | const auto dateTimeListSize = dateTimeList.count(); |
|
121 | const auto dateTimeListSize = dateTimeList.count(); | |
122 | if (cacheIndex >= dateTimeListSize) { |
|
122 | if (cacheIndex >= dateTimeListSize) { | |
@@ -140,7 +140,7 void VariableCacheController::VariableCacheControllerPrivate::addDateTimeRecurse | |||||
140 | // rerun the algo from this index with the merged interval |
|
140 | // rerun the algo from this index with the merged interval | |
141 | auto mTStart = std::min(dateTime.m_TStart, currentDateTime.m_TStart); |
|
141 | auto mTStart = std::min(dateTime.m_TStart, currentDateTime.m_TStart); | |
142 | auto mTEnd = std::max(dateTime.m_TEnd, currentDateTime.m_TEnd); |
|
142 | auto mTEnd = std::max(dateTime.m_TEnd, currentDateTime.m_TEnd); | |
143 |
auto mergeDateTime = |
|
143 | auto mergeDateTime = DateTimeRange{mTStart, mTEnd}; | |
144 |
|
144 | |||
145 | dateTimeList.remove(cacheIndex); |
|
145 | dateTimeList.remove(cacheIndex); | |
146 | addDateTimeRecurse(mergeDateTime, dateTimeList, cacheIndex); |
|
146 | addDateTimeRecurse(mergeDateTime, dateTimeList, cacheIndex); | |
@@ -149,7 +149,7 void VariableCacheController::VariableCacheControllerPrivate::addDateTimeRecurse | |||||
149 |
|
149 | |||
150 |
|
150 | |||
151 | void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataByEnd( |
|
151 | void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataByEnd( | |
152 |
const |
|
152 | const DateTimeRange &dateTime, QVector<DateTimeRange> &dateTimeList, QVector<DateTimeRange> ¬InCache, | |
153 | int cacheIndex, double currentTStart) |
|
153 | int cacheIndex, double currentTStart) | |
154 | { |
|
154 | { | |
155 | const auto dateTimeListSize = dateTimeList.count(); |
|
155 | const auto dateTimeListSize = dateTimeList.count(); | |
@@ -157,7 +157,7 void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataByEn | |||||
157 | if (currentTStart < dateTime.m_TEnd) { |
|
157 | if (currentTStart < dateTime.m_TEnd) { | |
158 |
|
158 | |||
159 | // te localised after all other interval: The last interval is [currentTsart, te] |
|
159 | // te localised after all other interval: The last interval is [currentTsart, te] | |
160 |
notInCache.push_back( |
|
160 | notInCache.push_back(DateTimeRange{currentTStart, dateTime.m_TEnd}); | |
161 | } |
|
161 | } | |
162 | return; |
|
162 | return; | |
163 | } |
|
163 | } | |
@@ -165,10 +165,10 void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataByEn | |||||
165 | auto currentDateTimeJ = dateTimeList[cacheIndex]; |
|
165 | auto currentDateTimeJ = dateTimeList[cacheIndex]; | |
166 | if (dateTime.m_TEnd <= currentDateTimeJ.m_TStart) { |
|
166 | if (dateTime.m_TEnd <= currentDateTimeJ.m_TStart) { | |
167 | // te localised between to interval: The last interval is [currentTsart, te] |
|
167 | // te localised between to interval: The last interval is [currentTsart, te] | |
168 |
notInCache.push_back( |
|
168 | notInCache.push_back(DateTimeRange{currentTStart, dateTime.m_TEnd}); | |
169 | } |
|
169 | } | |
170 | else { |
|
170 | else { | |
171 |
notInCache.push_back( |
|
171 | notInCache.push_back(DateTimeRange{currentTStart, currentDateTimeJ.m_TStart}); | |
172 | if (dateTime.m_TEnd > currentDateTimeJ.m_TEnd) { |
|
172 | if (dateTime.m_TEnd > currentDateTimeJ.m_TEnd) { | |
173 | // te not localised before the current interval: we need to look at the next interval |
|
173 | // te not localised before the current interval: we need to look at the next interval | |
174 | addInCacheDataByEnd(dateTime, dateTimeList, notInCache, ++cacheIndex, |
|
174 | addInCacheDataByEnd(dateTime, dateTimeList, notInCache, ++cacheIndex, | |
@@ -178,13 +178,13 void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataByEn | |||||
178 | } |
|
178 | } | |
179 |
|
179 | |||
180 | void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataByStart( |
|
180 | void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataByStart( | |
181 |
const |
|
181 | const DateTimeRange &dateTime, QVector<DateTimeRange> &dateTimeList, QVector<DateTimeRange> ¬InCache, | |
182 | int cacheIndex, double currentTStart) |
|
182 | int cacheIndex, double currentTStart) | |
183 | { |
|
183 | { | |
184 | const auto dateTimeListSize = dateTimeList.count(); |
|
184 | const auto dateTimeListSize = dateTimeList.count(); | |
185 | if (cacheIndex >= dateTimeListSize) { |
|
185 | if (cacheIndex >= dateTimeListSize) { | |
186 | // ts localised after all other interval: The last interval is [ts, te] |
|
186 | // ts localised after all other interval: The last interval is [ts, te] | |
187 |
notInCache.push_back( |
|
187 | notInCache.push_back(DateTimeRange{currentTStart, dateTime.m_TEnd}); | |
188 | return; |
|
188 | return; | |
189 | } |
|
189 | } | |
190 |
|
190 |
@@ -12,6 +12,8 | |||||
12 | #include <Data/VariableRequest.h> |
|
12 | #include <Data/VariableRequest.h> | |
13 | #include <Time/TimeController.h> |
|
13 | #include <Time/TimeController.h> | |
14 |
|
14 | |||
|
15 | #include <Common/Numeric.h> | |||
|
16 | ||||
15 | #include <QDataStream> |
|
17 | #include <QDataStream> | |
16 | #include <QMutex> |
|
18 | #include <QMutex> | |
17 | #include <QThread> |
|
19 | #include <QThread> | |
@@ -26,8 +28,8 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController") | |||||
26 |
|
28 | |||
27 | namespace { |
|
29 | namespace { | |
28 |
|
30 | |||
29 |
|
|
31 | DateTimeRange computeSynchroRangeRequested(const DateTimeRange &varRange, const DateTimeRange &graphRange, | |
30 |
const |
|
32 | const DateTimeRange &oldGraphRange) | |
31 | { |
|
33 | { | |
32 | auto zoomType = VariableController::getZoomType(graphRange, oldGraphRange); |
|
34 | auto zoomType = VariableController::getZoomType(graphRange, oldGraphRange); | |
33 |
|
35 | |||
@@ -120,7 +122,7 struct VariableController::VariableControllerPrivate { | |||||
120 | } |
|
122 | } | |
121 |
|
123 | |||
122 |
|
124 | |||
123 |
void processRequest(std::shared_ptr<Variable> var, const |
|
125 | void processRequest(std::shared_ptr<Variable> var, const DateTimeRange &rangeRequested, | |
124 | QUuid varRequestId); |
|
126 | QUuid varRequestId); | |
125 |
|
127 | |||
126 | std::shared_ptr<Variable> findVariable(QUuid vIdentifier); |
|
128 | std::shared_ptr<Variable> findVariable(QUuid vIdentifier); | |
@@ -333,7 +335,7 VariableController::variablesForMimeData(const QByteArray &mimeData) const | |||||
333 |
|
335 | |||
334 | std::shared_ptr<Variable> |
|
336 | std::shared_ptr<Variable> | |
335 | VariableController::createVariable(const QString &name, const QVariantHash &metadata, |
|
337 | VariableController::createVariable(const QString &name, const QVariantHash &metadata, | |
336 |
std::shared_ptr<IDataProvider> provider, const |
|
338 | std::shared_ptr<IDataProvider> provider, const DateTimeRange& range) noexcept | |
337 | { |
|
339 | { | |
338 | // if (!impl->m_TimeController) { |
|
340 | // if (!impl->m_TimeController) { | |
339 | // qCCritical(LOG_VariableController()) |
|
341 | // qCCritical(LOG_VariableController()) | |
@@ -376,7 +378,7 VariableController::createVariable(const QString &name, const QVariantHash &meta | |||||
376 | return nullptr; |
|
378 | return nullptr; | |
377 | } |
|
379 | } | |
378 |
|
380 | |||
379 |
void VariableController::onDateTimeOnSelection(const |
|
381 | void VariableController::onDateTimeOnSelection(const DateTimeRange &dateTime) | |
380 | { |
|
382 | { | |
381 | // NOTE: Even if acquisition request is aborting, the graphe range will be changed |
|
383 | // NOTE: Even if acquisition request is aborting, the graphe range will be changed | |
382 | qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection" |
|
384 | qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection" | |
@@ -417,7 +419,7 void VariableController::onDateTimeOnSelection(const SqpRange &dateTime) | |||||
417 | } |
|
419 | } | |
418 |
|
420 | |||
419 | void VariableController::onUpdateDateTime(std::shared_ptr<Variable> variable, |
|
421 | void VariableController::onUpdateDateTime(std::shared_ptr<Variable> variable, | |
420 |
const |
|
422 | const DateTimeRange &dateTime) | |
421 | { |
|
423 | { | |
422 | auto itVar = impl->m_VariableToIdentifierMap.find(variable); |
|
424 | auto itVar = impl->m_VariableToIdentifierMap.find(variable); | |
423 | if (itVar == impl->m_VariableToIdentifierMap.cend()) { |
|
425 | if (itVar == impl->m_VariableToIdentifierMap.cend()) { | |
@@ -435,8 +437,8 void VariableController::onUpdateDateTime(std::shared_ptr<Variable> variable, | |||||
435 | this->onRequestDataLoading(QVector<std::shared_ptr<Variable> >{variable}, dateTime, synchro); |
|
437 | this->onRequestDataLoading(QVector<std::shared_ptr<Variable> >{variable}, dateTime, synchro); | |
436 | } |
|
438 | } | |
437 |
|
439 | |||
438 |
void VariableController::onDataProvided(QUuid vIdentifier, const |
|
440 | void VariableController::onDataProvided(QUuid vIdentifier, const DateTimeRange &rangeRequested, | |
439 |
const |
|
441 | const DateTimeRange &cacheRangeRequested, | |
440 | QVector<AcquisitionDataPacket> dataAcquired) |
|
442 | QVector<AcquisitionDataPacket> dataAcquired) | |
441 | { |
|
443 | { | |
442 | qCDebug(LOG_VariableController()) << tr("onDataProvided") << QThread::currentThread(); |
|
444 | qCDebug(LOG_VariableController()) << tr("onDataProvided") << QThread::currentThread(); | |
@@ -532,7 +534,7 void VariableController::onAddSynchronized(std::shared_ptr<Variable> variable, | |||||
532 | if (groupIdToVSGIt != impl->m_GroupIdToVariableSynchronizationGroupMap.cend()) { |
|
534 | if (groupIdToVSGIt != impl->m_GroupIdToVariableSynchronizationGroupMap.cend()) { | |
533 | impl->m_VariableIdGroupIdMap.insert( |
|
535 | impl->m_VariableIdGroupIdMap.insert( | |
534 | std::make_pair(varToVarIdIt->second, synchronizationGroupId)); |
|
536 | std::make_pair(varToVarIdIt->second, synchronizationGroupId)); | |
535 |
groupIdToVSGIt->second->addVariable |
|
537 | groupIdToVSGIt->second->addVariable(varToVarIdIt->second); | |
536 | } |
|
538 | } | |
537 | else { |
|
539 | else { | |
538 | qCCritical(LOG_VariableController()) |
|
540 | qCCritical(LOG_VariableController()) | |
@@ -562,7 +564,7 void VariableController::desynchronize(std::shared_ptr<Variable> variable, | |||||
562 | } |
|
564 | } | |
563 |
|
565 | |||
564 | void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, |
|
566 | void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, | |
565 |
const |
|
567 | const DateTimeRange &range, bool synchronise) | |
566 | { |
|
568 | { | |
567 | // variables is assumed synchronized |
|
569 | // variables is assumed synchronized | |
568 | // TODO: Asser variables synchronization |
|
570 | // TODO: Asser variables synchronization | |
@@ -655,34 +657,27 bool VariableController::hasPendingDownloads() | |||||
655 | return impl->hasPendingDownloads(); |
|
657 | return impl->hasPendingDownloads(); | |
656 | } |
|
658 | } | |
657 |
|
659 | |||
658 |
AcquisitionZoomType VariableController::getZoomType(const |
|
660 | AcquisitionZoomType VariableController::getZoomType(const DateTimeRange &range, const DateTimeRange &oldRange) | |
659 | { |
|
661 | { | |
660 | // t1.m_TStart <= t2.m_TStart && t2.m_TEnd <= t1.m_TEnd |
|
662 | if (almost_equal(range.delta(), oldRange.delta(), 1)) // same delta -> must be a pan or nothing | |
661 | auto zoomType = AcquisitionZoomType::Unknown; |
|
663 | { | |
662 |
if |
|
664 | if(range.m_TStart > oldRange.m_TStart) | |
663 | qCDebug(LOG_VariableController()) << "zoomtype: ZoomOut"; |
|
665 | return AcquisitionZoomType::PanRight; | |
664 | zoomType = AcquisitionZoomType::ZoomOut; |
|
666 | if(range.m_TStart < oldRange.m_TStart) | |
665 | } |
|
667 | return AcquisitionZoomType::PanLeft; | |
666 | else if (range.m_TStart > oldRange.m_TStart && range.m_TEnd > oldRange.m_TEnd) { |
|
|||
667 | qCDebug(LOG_VariableController()) << "zoomtype: PanRight"; |
|
|||
668 | zoomType = AcquisitionZoomType::PanRight; |
|
|||
669 | } |
|
|||
670 | else if (range.m_TStart < oldRange.m_TStart && range.m_TEnd < oldRange.m_TEnd) { |
|
|||
671 | qCDebug(LOG_VariableController()) << "zoomtype: PanLeft"; |
|
|||
672 | zoomType = AcquisitionZoomType::PanLeft; |
|
|||
673 | } |
|
|||
674 | else if (range.m_TStart >= oldRange.m_TStart && oldRange.m_TEnd >= range.m_TEnd) { |
|
|||
675 | qCDebug(LOG_VariableController()) << "zoomtype: ZoomIn"; |
|
|||
676 | zoomType = AcquisitionZoomType::ZoomIn; |
|
|||
677 | } |
|
668 | } | |
678 | else { |
|
669 | else // different delta -> must be a zoom | |
679 | qCDebug(LOG_VariableController()) << "getZoomType: Unknown type detected"; |
|
670 | { | |
|
671 | if(range.m_TStart > oldRange.m_TStart) | |||
|
672 | return AcquisitionZoomType::ZoomIn; | |||
|
673 | if(range.m_TStart < oldRange.m_TStart) | |||
|
674 | return AcquisitionZoomType::ZoomOut; | |||
680 | } |
|
675 | } | |
681 |
return |
|
676 | return AcquisitionZoomType::Unknown; | |
682 | } |
|
677 | } | |
683 |
|
678 | |||
684 | void VariableController::VariableControllerPrivate::processRequest(std::shared_ptr<Variable> var, |
|
679 | void VariableController::VariableControllerPrivate::processRequest(std::shared_ptr<Variable> var, | |
685 |
const |
|
680 | const DateTimeRange &rangeRequested, | |
686 | QUuid varRequestId) |
|
681 | QUuid varRequestId) | |
687 | { |
|
682 | { | |
688 | auto itVar = m_VariableToIdentifierMap.find(var); |
|
683 | auto itVar = m_VariableToIdentifierMap.find(var); | |
@@ -1101,7 +1096,7 void VariableController::VariableControllerPrivate::desynchronize(VariableIterat | |||||
1101 |
|
1096 | |||
1102 | // Removes variable from synchronization group |
|
1097 | // Removes variable from synchronization group | |
1103 | auto synchronizationGroup = groupIt->second; |
|
1098 | auto synchronizationGroup = groupIt->second; | |
1104 |
synchronizationGroup->removeVariable |
|
1099 | synchronizationGroup->removeVariable(variableId); | |
1105 |
|
1100 | |||
1106 | // Removes link between variable and synchronization group |
|
1101 | // Removes link between variable and synchronization group | |
1107 | m_VariableIdGroupIdMap.erase(variableId); |
|
1102 | m_VariableIdGroupIdMap.erase(variableId); |
@@ -290,7 +290,7 QMimeData *VariableModel::mimeData(const QModelIndexList &indexes) const | |||||
290 | QList<std::shared_ptr<Variable> > variableList; |
|
290 | QList<std::shared_ptr<Variable> > variableList; | |
291 |
|
291 | |||
292 |
|
292 | |||
293 |
|
|
293 | DateTimeRange firstTimeRange; | |
294 | for (const auto &index : indexes) { |
|
294 | for (const auto &index : indexes) { | |
295 | if (index.column() == 0) { // only the first column |
|
295 | if (index.column() == 0) { // only the first column | |
296 | auto variable = impl->m_Variables.at(index.row()); |
|
296 | auto variable = impl->m_Variables.at(index.row()); |
@@ -16,12 +16,18 VariableSynchronizationGroup::VariableSynchronizationGroup(QObject *parent) | |||||
16 | { |
|
16 | { | |
17 | } |
|
17 | } | |
18 |
|
18 | |||
19 |
|
|
19 | VariableSynchronizationGroup::VariableSynchronizationGroup(QUuid variable, QObject *parent) | |
|
20 | :QObject{parent}, impl{spimpl::make_unique_impl<VariableSynchronizationGroupPrivate>()} | |||
|
21 | { | |||
|
22 | this->addVariable(variable); | |||
|
23 | } | |||
|
24 | ||||
|
25 | void VariableSynchronizationGroup::addVariable(QUuid vIdentifier) | |||
20 | { |
|
26 | { | |
21 | impl->m_VariableIdSet.insert(vIdentifier); |
|
27 | impl->m_VariableIdSet.insert(vIdentifier); | |
22 | } |
|
28 | } | |
23 |
|
29 | |||
24 |
void VariableSynchronizationGroup::removeVariable |
|
30 | void VariableSynchronizationGroup::removeVariable(QUuid vIdentifier) | |
25 | { |
|
31 | { | |
26 | impl->m_VariableIdSet.erase(vIdentifier); |
|
32 | impl->m_VariableIdSet.erase(vIdentifier); | |
27 | } |
|
33 | } |
@@ -3,6 +3,7 | |||||
3 | #include <pybind11/embed.h> |
|
3 | #include <pybind11/embed.h> | |
4 | #include <pybind11/numpy.h> |
|
4 | #include <pybind11/numpy.h> | |
5 | #include <pybind11/chrono.h> |
|
5 | #include <pybind11/chrono.h> | |
|
6 | #include <pybind11/functional.h> | |||
6 |
|
7 | |||
7 | #include <string> |
|
8 | #include <string> | |
8 | #include <sstream> |
|
9 | #include <sstream> | |
@@ -20,6 +21,8 | |||||
20 |
|
21 | |||
21 | #include <Time/TimeController.h> |
|
22 | #include <Time/TimeController.h> | |
22 |
|
23 | |||
|
24 | #include <Network/Downloader.h> | |||
|
25 | ||||
23 |
|
26 | |||
24 |
|
27 | |||
25 | namespace py = pybind11; |
|
28 | namespace py = pybind11; | |
@@ -40,6 +43,14 PYBIND11_MODULE(pysciqlopcore,m){ | |||||
40 | .def(py::self != py::self) |
|
43 | .def(py::self != py::self) | |
41 | .def("__repr__",__repr__<Unit>); |
|
44 | .def("__repr__",__repr__<Unit>); | |
42 |
|
45 | |||
|
46 | py::class_<Response>(m,"Response") | |||
|
47 | .def("status_code", &Response::status_code); | |||
|
48 | ||||
|
49 | py::class_<Downloader>(m,"Downloader") | |||
|
50 | .def_static("get", Downloader::get) | |||
|
51 | .def_static("getAsync", Downloader::getAsync) | |||
|
52 | .def_static("downloadFinished", Downloader::downloadFinished); | |||
|
53 | ||||
43 | py::class_<DataSeriesIteratorValue>(m,"DataSeriesIteratorValue") |
|
54 | py::class_<DataSeriesIteratorValue>(m,"DataSeriesIteratorValue") | |
44 | .def_property_readonly("x", &DataSeriesIteratorValue::x) |
|
55 | .def_property_readonly("x", &DataSeriesIteratorValue::x) | |
45 | .def("value", py::overload_cast<>(&DataSeriesIteratorValue::value, py::const_)) |
|
56 | .def("value", py::overload_cast<>(&DataSeriesIteratorValue::value, py::const_)) | |
@@ -95,21 +106,21 PYBIND11_MODULE(pysciqlopcore,m){ | |||||
95 | .def("__repr__",__repr__<Variable>); |
|
106 | .def("__repr__",__repr__<Variable>); | |
96 |
|
107 | |||
97 |
|
108 | |||
98 |
py::class_< |
|
109 | py::class_<DateTimeRange>(m,"SqpRange") | |
99 |
.def("fromDateTime", & |
|
110 | .def("fromDateTime", &DateTimeRange::fromDateTime, py::return_value_policy::move) | |
100 |
.def(py::init([](double start, double stop){return |
|
111 | .def(py::init([](double start, double stop){return DateTimeRange{start, stop};})) | |
101 | .def(py::init([](system_clock::time_point start, system_clock::time_point stop) |
|
112 | .def(py::init([](system_clock::time_point start, system_clock::time_point stop) | |
102 | { |
|
113 | { | |
103 | double start_ = 0.001 * duration_cast<milliseconds>(start.time_since_epoch()).count(); |
|
114 | double start_ = 0.001 * duration_cast<milliseconds>(start.time_since_epoch()).count(); | |
104 | double stop_ = 0.001 * duration_cast<milliseconds>(stop.time_since_epoch()).count(); |
|
115 | double stop_ = 0.001 * duration_cast<milliseconds>(stop.time_since_epoch()).count(); | |
105 |
return |
|
116 | return DateTimeRange{start_, stop_}; | |
106 | })) |
|
117 | })) | |
107 |
.def_property_readonly("start", [](const |
|
118 | .def_property_readonly("start", [](const DateTimeRange& range){ | |
108 | return system_clock::from_time_t(range.m_TStart); |
|
119 | return system_clock::from_time_t(range.m_TStart); | |
109 | }) |
|
120 | }) | |
110 |
.def_property_readonly("stop", [](const |
|
121 | .def_property_readonly("stop", [](const DateTimeRange& range){ | |
111 | return system_clock::from_time_t(range.m_TEnd); |
|
122 | return system_clock::from_time_t(range.m_TEnd); | |
112 | }) |
|
123 | }) | |
113 |
.def("__repr__", __repr__< |
|
124 | .def("__repr__", __repr__<DateTimeRange>); | |
114 |
|
125 | |||
115 | } |
|
126 | } |
@@ -34,7 +34,7 std::ostream &operator <<(std::ostream& os, const IDataSeries& ds) | |||||
34 | return os; |
|
34 | return os; | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 |
std::ostream &operator <<(std::ostream& os, const |
|
37 | std::ostream &operator <<(std::ostream& os, const DateTimeRange& range) | |
38 | { |
|
38 | { | |
39 | os << "=========================" << std::endl |
|
39 | os << "=========================" << std::endl | |
40 | << "SqpRange:" << std::endl |
|
40 | << "SqpRange:" << std::endl |
@@ -32,3 +32,6 declare_test(TestVariableController TestVariableController Variable/TestVariable | |||||
32 | declare_test(TestVariableSync TestVariableSync Variable/TestVariableSync.cpp "sciqlopcore;Qt5::Test") |
|
32 | declare_test(TestVariableSync TestVariableSync Variable/TestVariableSync.cpp "sciqlopcore;Qt5::Test") | |
33 |
|
33 | |||
34 | declare_test(TestDownloader TestDownloader Network/TestDownloader.cpp "sciqlopcore;Qt5::Test") |
|
34 | declare_test(TestDownloader TestDownloader Network/TestDownloader.cpp "sciqlopcore;Qt5::Test") | |
|
35 | ||||
|
36 | ||||
|
37 | declare_test(TestVariableController2 TestVariableController2 Variable/TestVariableController2.cpp "sciqlopcore;Qt5::Test") |
@@ -254,7 +254,7 void testSubDataSeries_struct() { | |||||
254 | // Data series from which extract the subdata series |
|
254 | // Data series from which extract the subdata series | |
255 | QTest::addColumn<std::shared_ptr<DataSeriesType> >("dataSeries"); |
|
255 | QTest::addColumn<std::shared_ptr<DataSeriesType> >("dataSeries"); | |
256 | // Range to extract |
|
256 | // Range to extract | |
257 |
QTest::addColumn< |
|
257 | QTest::addColumn<DateTimeRange>("range"); | |
258 |
|
258 | |||
259 | // Expected values for the subdata series |
|
259 | // Expected values for the subdata series | |
260 | QTest::addColumn<DataContainer>("expectedXAxisData"); |
|
260 | QTest::addColumn<DataContainer>("expectedXAxisData"); | |
@@ -268,7 +268,7 void testSubDataSeries_struct() { | |||||
268 | template <typename DataSeriesType, typename ExpectedValuesType> |
|
268 | template <typename DataSeriesType, typename ExpectedValuesType> | |
269 | void testSubDataSeries_t(){ |
|
269 | void testSubDataSeries_t(){ | |
270 | QFETCH(std::shared_ptr<DataSeriesType>, dataSeries); |
|
270 | QFETCH(std::shared_ptr<DataSeriesType>, dataSeries); | |
271 |
QFETCH( |
|
271 | QFETCH(DateTimeRange, range); | |
272 |
|
272 | |||
273 | // Makes the operation |
|
273 | // Makes the operation | |
274 | auto subDataSeries = std::dynamic_pointer_cast<DataSeriesType>(dataSeries->subDataSeries(range)); |
|
274 | auto subDataSeries = std::dynamic_pointer_cast<DataSeriesType>(dataSeries->subDataSeries(range)); |
@@ -169,7 +169,7 void TestSpectrogramSeries::testSubDataSeries_data() | |||||
169 | .setY({1., 2.}) |
|
169 | .setY({1., 2.}) | |
170 | .setValues({10., 11., 20., 21., 30., 31}) |
|
170 | .setValues({10., 11., 20., 21., 30., 31}) | |
171 | .build() |
|
171 | .build() | |
172 |
<< |
|
172 | << DateTimeRange{0., 5.} << DataContainer{1., 2., 3.} | |
173 | << Components{{10., 20., 30.}, {11., 21., 31.}}; |
|
173 | << Components{{10., 20., 30.}, {11., 21., 31.}}; | |
174 |
|
174 | |||
175 | QTest::newRow("subDataSeries (the range includes no data)") |
|
175 | QTest::newRow("subDataSeries (the range includes no data)") | |
@@ -178,7 +178,7 void TestSpectrogramSeries::testSubDataSeries_data() | |||||
178 | .setY({1., 2.}) |
|
178 | .setY({1., 2.}) | |
179 | .setValues({10., 11., 20., 21., 30., 31}) |
|
179 | .setValues({10., 11., 20., 21., 30., 31}) | |
180 | .build() |
|
180 | .build() | |
181 |
<< |
|
181 | << DateTimeRange{4., 5.} << DataContainer{} << Components{{}, {}}; | |
182 |
|
182 | |||
183 | QTest::newRow("subDataSeries (the range includes some data)") |
|
183 | QTest::newRow("subDataSeries (the range includes some data)") | |
184 | << SpectrogramBuilder{} |
|
184 | << SpectrogramBuilder{} | |
@@ -186,7 +186,7 void TestSpectrogramSeries::testSubDataSeries_data() | |||||
186 | .setY({1., 2.}) |
|
186 | .setY({1., 2.}) | |
187 | .setValues({10., 11., 20., 21., 30., 31}) |
|
187 | .setValues({10., 11., 20., 21., 30., 31}) | |
188 | .build() |
|
188 | .build() | |
189 |
<< |
|
189 | << DateTimeRange{1.1, 3} << DataContainer{2., 3.} << Components{{20., 30.}, {21., 31.}}; | |
190 | } |
|
190 | } | |
191 |
|
191 | |||
192 | void TestSpectrogramSeries::testSubDataSeries() |
|
192 | void TestSpectrogramSeries::testSubDataSeries() |
@@ -16,7 +16,7 auto date = [](int year, int month, int day, int hours, int minutes, int seconds | |||||
16 | }; |
|
16 | }; | |
17 |
|
17 | |||
18 | /// Generates a series of test data for a range |
|
18 | /// Generates a series of test data for a range | |
19 |
std::shared_ptr<ScalarSeries> dataSeries(const |
|
19 | std::shared_ptr<ScalarSeries> dataSeries(const DateTimeRange &range) | |
20 | { |
|
20 | { | |
21 | auto xAxisData = std::vector<double>{}; |
|
21 | auto xAxisData = std::vector<double>{}; | |
22 | auto valuesData = std::vector<double>{}; |
|
22 | auto valuesData = std::vector<double>{}; | |
@@ -60,18 +60,18 void TestVariable::testClone_data() | |||||
60 |
|
60 | |||
61 | QTest::addColumn<QString>("name"); |
|
61 | QTest::addColumn<QString>("name"); | |
62 | QTest::addColumn<QVariantHash>("metadata"); |
|
62 | QTest::addColumn<QVariantHash>("metadata"); | |
63 |
QTest::addColumn< |
|
63 | QTest::addColumn<DateTimeRange>("range"); | |
64 |
QTest::addColumn< |
|
64 | QTest::addColumn<DateTimeRange>("cacheRange"); | |
65 | QTest::addColumn<std::shared_ptr<ScalarSeries> >("dataSeries"); |
|
65 | QTest::addColumn<std::shared_ptr<ScalarSeries> >("dataSeries"); | |
66 |
|
66 | |||
67 | // ////////// // |
|
67 | // ////////// // | |
68 | // Test cases // |
|
68 | // Test cases // | |
69 | // ////////// // |
|
69 | // ////////// // | |
70 |
|
70 | |||
71 |
auto cacheRange = |
|
71 | auto cacheRange = DateTimeRange{date(2017, 1, 1, 12, 0, 0), date(2017, 1, 1, 13, 0, 0)}; | |
72 | QTest::newRow("clone1") << QStringLiteral("var1") |
|
72 | QTest::newRow("clone1") << QStringLiteral("var1") | |
73 | << QVariantHash{{"data1", 1}, {"data2", "abc"}} |
|
73 | << QVariantHash{{"data1", 1}, {"data2", "abc"}} | |
74 |
<< |
|
74 | << DateTimeRange{date(2017, 1, 1, 12, 30, 0), (date(2017, 1, 1, 12, 45, 0))} | |
75 | << cacheRange << dataSeries(cacheRange); |
|
75 | << cacheRange << dataSeries(cacheRange); | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
@@ -80,8 +80,8 void TestVariable::testClone() | |||||
80 | // Creates variable |
|
80 | // Creates variable | |
81 | QFETCH(QString, name); |
|
81 | QFETCH(QString, name); | |
82 | QFETCH(QVariantHash, metadata); |
|
82 | QFETCH(QVariantHash, metadata); | |
83 |
QFETCH( |
|
83 | QFETCH(DateTimeRange, range); | |
84 |
QFETCH( |
|
84 | QFETCH(DateTimeRange, cacheRange); | |
85 | QFETCH(std::shared_ptr<ScalarSeries>, dataSeries); |
|
85 | QFETCH(std::shared_ptr<ScalarSeries>, dataSeries); | |
86 |
|
86 | |||
87 | Variable variable{name, metadata}; |
|
87 | Variable variable{name, metadata}; | |
@@ -116,13 +116,13 void TestVariable::testNotInCacheRangeList() | |||||
116 | auto varRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; |
|
116 | auto varRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; | |
117 | auto varRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 40, 0}}; |
|
117 | auto varRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 40, 0}}; | |
118 |
|
118 | |||
119 |
auto sqpR = |
|
119 | auto sqpR = DateTimeRange{DateUtils::secondsSinceEpoch(varRS), DateUtils::secondsSinceEpoch(varRE)}; | |
120 |
|
120 | |||
121 | auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; |
|
121 | auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; | |
122 | auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
122 | auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; | |
123 |
|
123 | |||
124 | auto sqpCR |
|
124 | auto sqpCR | |
125 |
= |
|
125 | = DateTimeRange{DateUtils::secondsSinceEpoch(varCRS), DateUtils::secondsSinceEpoch(varCRE)}; | |
126 |
|
126 | |||
127 | Variable var{"Var test"}; |
|
127 | Variable var{"Var test"}; | |
128 | var.setRange(sqpR); |
|
128 | var.setRange(sqpR); | |
@@ -131,7 +131,7 void TestVariable::testNotInCacheRangeList() | |||||
131 | // 1: [ts,te] < varTS |
|
131 | // 1: [ts,te] < varTS | |
132 | auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
132 | auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; | |
133 | auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; |
|
133 | auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; | |
134 |
auto sqp = |
|
134 | auto sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
135 |
|
135 | |||
136 | auto notInCach = var.provideNotInCacheRangeList(sqp); |
|
136 | auto notInCach = var.provideNotInCacheRangeList(sqp); | |
137 |
|
137 | |||
@@ -145,7 +145,7 void TestVariable::testNotInCacheRangeList() | |||||
145 | // 2: ts < varTS < te < varTE |
|
145 | // 2: ts < varTS < te < varTE | |
146 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
146 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; | |
147 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
147 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; | |
148 |
sqp = |
|
148 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
149 | notInCach = var.provideNotInCacheRangeList(sqp); |
|
149 | notInCach = var.provideNotInCacheRangeList(sqp); | |
150 | QCOMPARE(notInCach.size(), 1); |
|
150 | QCOMPARE(notInCach.size(), 1); | |
151 | notInCachRange = notInCach.first(); |
|
151 | notInCachRange = notInCach.first(); | |
@@ -155,7 +155,7 void TestVariable::testNotInCacheRangeList() | |||||
155 | // 3: varTS < ts < te < varTE |
|
155 | // 3: varTS < ts < te < varTE | |
156 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; |
|
156 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; | |
157 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
157 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; | |
158 |
sqp = |
|
158 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
159 | notInCach = var.provideNotInCacheRangeList(sqp); |
|
159 | notInCach = var.provideNotInCacheRangeList(sqp); | |
160 | QCOMPARE(notInCach.size(), 0); |
|
160 | QCOMPARE(notInCach.size(), 0); | |
161 |
|
161 | |||
@@ -163,7 +163,7 void TestVariable::testNotInCacheRangeList() | |||||
163 | // 4: varTS < ts < varTE < te |
|
163 | // 4: varTS < ts < varTE < te | |
164 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; |
|
164 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; | |
165 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
165 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; | |
166 |
sqp = |
|
166 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
167 | notInCach = var.provideNotInCacheRangeList(sqp); |
|
167 | notInCach = var.provideNotInCacheRangeList(sqp); | |
168 | QCOMPARE(notInCach.size(), 1); |
|
168 | QCOMPARE(notInCach.size(), 1); | |
169 | notInCachRange = notInCach.first(); |
|
169 | notInCachRange = notInCach.first(); | |
@@ -173,7 +173,7 void TestVariable::testNotInCacheRangeList() | |||||
173 | // 5: varTS < varTE < ts < te |
|
173 | // 5: varTS < varTE < ts < te | |
174 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 20, 0}}; |
|
174 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 20, 0}}; | |
175 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
175 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; | |
176 |
sqp = |
|
176 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
177 | notInCach = var.provideNotInCacheRangeList(sqp); |
|
177 | notInCach = var.provideNotInCacheRangeList(sqp); | |
178 | QCOMPARE(notInCach.size(), 1); |
|
178 | QCOMPARE(notInCach.size(), 1); | |
179 | notInCachRange = notInCach.first(); |
|
179 | notInCachRange = notInCach.first(); | |
@@ -183,7 +183,7 void TestVariable::testNotInCacheRangeList() | |||||
183 | // 6: ts <varTS < varTE < te |
|
183 | // 6: ts <varTS < varTE < te | |
184 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; |
|
184 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; | |
185 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
185 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; | |
186 |
sqp = |
|
186 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
187 | notInCach = var.provideNotInCacheRangeList(sqp); |
|
187 | notInCach = var.provideNotInCacheRangeList(sqp); | |
188 | QCOMPARE(notInCach.size(), 2); |
|
188 | QCOMPARE(notInCach.size(), 2); | |
189 | notInCachRange = notInCach.first(); |
|
189 | notInCachRange = notInCach.first(); | |
@@ -200,12 +200,12 void TestVariable::testInCacheRangeList() | |||||
200 | auto varRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; |
|
200 | auto varRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; | |
201 | auto varRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 40, 0}}; |
|
201 | auto varRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 40, 0}}; | |
202 |
|
202 | |||
203 |
auto sqpR = |
|
203 | auto sqpR = DateTimeRange{DateUtils::secondsSinceEpoch(varRS), DateUtils::secondsSinceEpoch(varRE)}; | |
204 |
|
204 | |||
205 | auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; |
|
205 | auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; | |
206 | auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
206 | auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; | |
207 | auto sqpCR |
|
207 | auto sqpCR | |
208 |
= |
|
208 | = DateTimeRange{DateUtils::secondsSinceEpoch(varCRS), DateUtils::secondsSinceEpoch(varCRE)}; | |
209 |
|
209 | |||
210 | Variable var{"Var test"}; |
|
210 | Variable var{"Var test"}; | |
211 | var.setRange(sqpR); |
|
211 | var.setRange(sqpR); | |
@@ -214,7 +214,7 void TestVariable::testInCacheRangeList() | |||||
214 | // 1: [ts,te] < varTS |
|
214 | // 1: [ts,te] < varTS | |
215 | auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
215 | auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; | |
216 | auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; |
|
216 | auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; | |
217 |
auto sqp = |
|
217 | auto sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
218 |
|
218 | |||
219 | auto notInCach = var.provideInCacheRangeList(sqp); |
|
219 | auto notInCach = var.provideInCacheRangeList(sqp); | |
220 |
|
220 | |||
@@ -223,7 +223,7 void TestVariable::testInCacheRangeList() | |||||
223 | // 2: ts < varTS < te < varTE |
|
223 | // 2: ts < varTS < te < varTE | |
224 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
224 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; | |
225 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
225 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; | |
226 |
sqp = |
|
226 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
227 | notInCach = var.provideInCacheRangeList(sqp); |
|
227 | notInCach = var.provideInCacheRangeList(sqp); | |
228 | QCOMPARE(notInCach.size(), 1); |
|
228 | QCOMPARE(notInCach.size(), 1); | |
229 | auto notInCachRange = notInCach.first(); |
|
229 | auto notInCachRange = notInCach.first(); | |
@@ -233,7 +233,7 void TestVariable::testInCacheRangeList() | |||||
233 | // 3: varTS < ts < te < varTE |
|
233 | // 3: varTS < ts < te < varTE | |
234 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; |
|
234 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; | |
235 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
235 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; | |
236 |
sqp = |
|
236 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
237 | notInCach = var.provideInCacheRangeList(sqp); |
|
237 | notInCach = var.provideInCacheRangeList(sqp); | |
238 | QCOMPARE(notInCach.size(), 1); |
|
238 | QCOMPARE(notInCach.size(), 1); | |
239 | notInCachRange = notInCach.first(); |
|
239 | notInCachRange = notInCach.first(); | |
@@ -243,7 +243,7 void TestVariable::testInCacheRangeList() | |||||
243 | // 4: varTS < ts < varTE < te |
|
243 | // 4: varTS < ts < varTE < te | |
244 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; |
|
244 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; | |
245 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
245 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; | |
246 |
sqp = |
|
246 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
247 | notInCach = var.provideInCacheRangeList(sqp); |
|
247 | notInCach = var.provideInCacheRangeList(sqp); | |
248 | QCOMPARE(notInCach.size(), 1); |
|
248 | QCOMPARE(notInCach.size(), 1); | |
249 | notInCachRange = notInCach.first(); |
|
249 | notInCachRange = notInCach.first(); | |
@@ -253,14 +253,14 void TestVariable::testInCacheRangeList() | |||||
253 | // 5: varTS < varTE < ts < te |
|
253 | // 5: varTS < varTE < ts < te | |
254 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 20, 0}}; |
|
254 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 20, 0}}; | |
255 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
255 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; | |
256 |
sqp = |
|
256 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
257 | notInCach = var.provideInCacheRangeList(sqp); |
|
257 | notInCach = var.provideInCacheRangeList(sqp); | |
258 | QCOMPARE(notInCach.size(), 0); |
|
258 | QCOMPARE(notInCach.size(), 0); | |
259 |
|
259 | |||
260 | // 6: ts <varTS < varTE < te |
|
260 | // 6: ts <varTS < varTE < te | |
261 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; |
|
261 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; | |
262 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
262 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; | |
263 |
sqp = |
|
263 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
264 | notInCach = var.provideInCacheRangeList(sqp); |
|
264 | notInCach = var.provideInCacheRangeList(sqp); | |
265 | QCOMPARE(notInCach.size(), 1); |
|
265 | QCOMPARE(notInCach.size(), 1); | |
266 | notInCachRange = notInCach.first(); |
|
266 | notInCachRange = notInCach.first(); | |
@@ -272,7 +272,7 namespace { | |||||
272 |
|
272 | |||
273 | /// Struct used to represent an operation for @sa TestVariable::testNbPoints() |
|
273 | /// Struct used to represent an operation for @sa TestVariable::testNbPoints() | |
274 | struct NbPointsOperation { |
|
274 | struct NbPointsOperation { | |
275 |
|
|
275 | DateTimeRange m_CacheRange; /// Range to set for the variable | |
276 | std::shared_ptr<ScalarSeries> m_DataSeries; /// Series to merge in the variable |
|
276 | std::shared_ptr<ScalarSeries> m_DataSeries; /// Series to merge in the variable | |
277 | int m_ExpectedNbPoints; /// Number of points in the variable expected after operation |
|
277 | int m_ExpectedNbPoints; /// Number of points in the variable expected after operation | |
278 | }; |
|
278 | }; | |
@@ -297,19 +297,19 void TestVariable::testNbPoints_data() | |||||
297 | NbPointsOperations operations{}; |
|
297 | NbPointsOperations operations{}; | |
298 |
|
298 | |||
299 | // Sets cache range (expected nb points = values data) |
|
299 | // Sets cache range (expected nb points = values data) | |
300 |
auto cacheRange = |
|
300 | auto cacheRange = DateTimeRange{date(2017, 1, 1, 12, 0, 0), date(2017, 1, 1, 12, 0, 9)}; | |
301 | operations.push_back({cacheRange, dataSeries(cacheRange), 10}); |
|
301 | operations.push_back({cacheRange, dataSeries(cacheRange), 10}); | |
302 |
|
302 | |||
303 | // Doubles cache but don't add data series (expected nb points don't change) |
|
303 | // Doubles cache but don't add data series (expected nb points don't change) | |
304 |
cacheRange = |
|
304 | cacheRange = DateTimeRange{date(2017, 1, 1, 12, 0, 0), date(2017, 1, 1, 12, 0, 19)}; | |
305 | operations.push_back({cacheRange, dataSeries(INVALID_RANGE), 10}); |
|
305 | operations.push_back({cacheRange, dataSeries(INVALID_RANGE), 10}); | |
306 |
|
306 | |||
307 | // Doubles cache and data series (expected nb points change) |
|
307 | // Doubles cache and data series (expected nb points change) | |
308 |
cacheRange = |
|
308 | cacheRange = DateTimeRange{date(2017, 1, 1, 12, 0, 0), date(2017, 1, 1, 12, 0, 19)}; | |
309 | operations.push_back({cacheRange, dataSeries(cacheRange), 20}); |
|
309 | operations.push_back({cacheRange, dataSeries(cacheRange), 20}); | |
310 |
|
310 | |||
311 | // Decreases cache (expected nb points decreases as the series is purged) |
|
311 | // Decreases cache (expected nb points decreases as the series is purged) | |
312 |
cacheRange = |
|
312 | cacheRange = DateTimeRange{date(2017, 1, 1, 12, 0, 5), date(2017, 1, 1, 12, 0, 9)}; | |
313 | operations.push_back({cacheRange, dataSeries(INVALID_RANGE), 5}); |
|
313 | operations.push_back({cacheRange, dataSeries(INVALID_RANGE), 5}); | |
314 |
|
314 | |||
315 | QTest::newRow("nbPoints1") << operations; |
|
315 | QTest::newRow("nbPoints1") << operations; | |
@@ -339,9 +339,9 namespace { | |||||
339 | /// Struct used to represent a range operation on a variable |
|
339 | /// Struct used to represent a range operation on a variable | |
340 | /// @sa TestVariable::testRealRange() |
|
340 | /// @sa TestVariable::testRealRange() | |
341 | struct RangeOperation { |
|
341 | struct RangeOperation { | |
342 |
|
|
342 | DateTimeRange m_CacheRange; /// Range to set for the variable | |
343 | std::shared_ptr<ScalarSeries> m_DataSeries; /// Series to merge in the variable |
|
343 | std::shared_ptr<ScalarSeries> m_DataSeries; /// Series to merge in the variable | |
344 |
|
|
344 | DateTimeRange m_ExpectedRealRange; /// Real Range expected after operation on the variable | |
345 | }; |
|
345 | }; | |
346 |
|
346 | |||
347 | using RangeOperations = std::vector<RangeOperation>; |
|
347 | using RangeOperations = std::vector<RangeOperation>; | |
@@ -364,22 +364,22 void TestVariable::testRealRange_data() | |||||
364 | RangeOperations operations{}; |
|
364 | RangeOperations operations{}; | |
365 |
|
365 | |||
366 | // Inits cache range and data series (expected real range = cache range) |
|
366 | // Inits cache range and data series (expected real range = cache range) | |
367 |
auto cacheRange = |
|
367 | auto cacheRange = DateTimeRange{date(2017, 1, 1, 12, 0, 0), date(2017, 1, 1, 13, 0, 0)}; | |
368 | operations.push_back({cacheRange, dataSeries(cacheRange), cacheRange}); |
|
368 | operations.push_back({cacheRange, dataSeries(cacheRange), cacheRange}); | |
369 |
|
369 | |||
370 | // Changes cache range and updates data series (expected real range = cache range) |
|
370 | // Changes cache range and updates data series (expected real range = cache range) | |
371 |
cacheRange = |
|
371 | cacheRange = DateTimeRange{date(2017, 1, 1, 14, 0, 0), date(2017, 1, 1, 15, 0, 0)}; | |
372 | operations.push_back({cacheRange, dataSeries(cacheRange), cacheRange}); |
|
372 | operations.push_back({cacheRange, dataSeries(cacheRange), cacheRange}); | |
373 |
|
373 | |||
374 | // Changes cache range and update data series but with a lower range (expected real range = |
|
374 | // Changes cache range and update data series but with a lower range (expected real range = | |
375 | // data series range) |
|
375 | // data series range) | |
376 |
cacheRange = |
|
376 | cacheRange = DateTimeRange{date(2017, 1, 1, 12, 0, 0), date(2017, 1, 1, 16, 0, 0)}; | |
377 |
auto dataSeriesRange = |
|
377 | auto dataSeriesRange = DateTimeRange{date(2017, 1, 1, 14, 0, 0), date(2017, 1, 1, 15, 0, 0)}; | |
378 | operations.push_back({cacheRange, dataSeries(dataSeriesRange), dataSeriesRange}); |
|
378 | operations.push_back({cacheRange, dataSeries(dataSeriesRange), dataSeriesRange}); | |
379 |
|
379 | |||
380 | // Changes cache range but DON'T update data series (expected real range = cache range |
|
380 | // Changes cache range but DON'T update data series (expected real range = cache range | |
381 | // before operation) |
|
381 | // before operation) | |
382 |
cacheRange = |
|
382 | cacheRange = DateTimeRange{date(2017, 1, 1, 10, 0, 0), date(2017, 1, 1, 17, 0, 0)}; | |
383 | operations.push_back({cacheRange, nullptr, dataSeriesRange}); |
|
383 | operations.push_back({cacheRange, nullptr, dataSeriesRange}); | |
384 |
|
384 | |||
385 | QTest::newRow("realRange1") << operations; |
|
385 | QTest::newRow("realRange1") << operations; |
@@ -22,15 +22,15 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
22 |
|
22 | |||
23 | auto ts0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; |
|
23 | auto ts0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; | |
24 | auto te0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
24 | auto te0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; | |
25 |
auto sqp0 = |
|
25 | auto sqp0 = DateTimeRange{DateUtils::secondsSinceEpoch(ts0), DateUtils::secondsSinceEpoch(te0)}; | |
26 |
|
26 | |||
27 | auto ts1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}}; |
|
27 | auto ts1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}}; | |
28 | auto te1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 8, 0, 0}}; |
|
28 | auto te1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 8, 0, 0}}; | |
29 |
auto sqp1 = |
|
29 | auto sqp1 = DateTimeRange{DateUtils::secondsSinceEpoch(ts1), DateUtils::secondsSinceEpoch(te1)}; | |
30 |
|
30 | |||
31 | auto ts2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 18, 0, 0}}; |
|
31 | auto ts2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 18, 0, 0}}; | |
32 | auto te2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 20, 0, 0}}; |
|
32 | auto te2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 20, 0, 0}}; | |
33 |
auto sqp2 = |
|
33 | auto sqp2 = DateTimeRange{DateUtils::secondsSinceEpoch(ts2), DateUtils::secondsSinceEpoch(te2)}; | |
34 |
|
34 | |||
35 | auto var0 = std::make_shared<Variable>(""); |
|
35 | auto var0 = std::make_shared<Variable>(""); | |
36 | var0->setRange(sqp0); |
|
36 | var0->setRange(sqp0); | |
@@ -42,7 +42,7 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
42 | // first case [ts,te] < ts0 |
|
42 | // first case [ts,te] < ts0 | |
43 | auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
43 | auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; | |
44 | auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; |
|
44 | auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; | |
45 |
auto sqp = |
|
45 | auto sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
46 |
|
46 | |||
47 |
|
47 | |||
48 | auto notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
48 | auto notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
@@ -56,7 +56,7 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
56 | // second case ts < ts0 && ts0 < te <= te0 |
|
56 | // second case ts < ts0 && ts0 < te <= te0 | |
57 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
57 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; | |
58 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
58 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; | |
59 |
sqp = |
|
59 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
60 |
|
60 | |||
61 |
|
61 | |||
62 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
62 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
@@ -69,7 +69,7 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
69 | // 3th case ts < ts0 && te0 < te <= ts1 |
|
69 | // 3th case ts < ts0 && te0 < te <= ts1 | |
70 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
70 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; | |
71 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
71 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; | |
72 |
sqp = |
|
72 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
73 |
|
73 | |||
74 |
|
74 | |||
75 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
75 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
@@ -86,7 +86,7 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
86 | // 4th case ts < ts0 && ts1 < te <= te1 |
|
86 | // 4th case ts < ts0 && ts1 < te <= te1 | |
87 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
87 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; | |
88 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 7, 0, 0}}; |
|
88 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 7, 0, 0}}; | |
89 |
sqp = |
|
89 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
90 |
|
90 | |||
91 |
|
91 | |||
92 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
92 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
@@ -103,7 +103,7 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
103 | // 5th case ts < ts0 && te3 < te |
|
103 | // 5th case ts < ts0 && te3 < te | |
104 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
104 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; | |
105 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 22, 0, 0}}; |
|
105 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 22, 0, 0}}; | |
106 |
sqp = |
|
106 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
107 |
|
107 | |||
108 |
|
108 | |||
109 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
109 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
@@ -129,7 +129,7 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
129 | // 6th case ts2 < ts |
|
129 | // 6th case ts2 < ts | |
130 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 45, 0, 0}}; |
|
130 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 45, 0, 0}}; | |
131 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 47, 0, 0}}; |
|
131 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 47, 0, 0}}; | |
132 |
sqp = |
|
132 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
133 |
|
133 | |||
134 |
|
134 | |||
135 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
135 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
@@ -142,7 +142,7 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
142 | // 7th case ts = te0 && te < ts1 |
|
142 | // 7th case ts = te0 && te < ts1 | |
143 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
143 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; | |
144 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
144 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; | |
145 |
sqp = |
|
145 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
146 |
|
146 | |||
147 |
|
147 | |||
148 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
148 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
@@ -155,7 +155,7 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
155 | // 8th case ts0 < ts < te0 && te < ts1 |
|
155 | // 8th case ts0 < ts < te0 && te < ts1 | |
156 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
156 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; | |
157 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
157 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; | |
158 |
sqp = |
|
158 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
159 |
|
159 | |||
160 |
|
160 | |||
161 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
161 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
@@ -168,7 +168,7 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
168 | // 9th case ts0 < ts < te0 && ts1 < te < te1 |
|
168 | // 9th case ts0 < ts < te0 && ts1 < te < te1 | |
169 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
169 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; | |
170 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 7, 0, 0}}; |
|
170 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 7, 0, 0}}; | |
171 |
sqp = |
|
171 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
172 |
|
172 | |||
173 |
|
173 | |||
174 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
174 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
@@ -181,7 +181,7 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
181 | // 10th case te1 < ts < te < ts2 |
|
181 | // 10th case te1 < ts < te < ts2 | |
182 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 9, 0, 0}}; |
|
182 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 9, 0, 0}}; | |
183 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 10, 0, 0}}; |
|
183 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 10, 0, 0}}; | |
184 |
sqp = |
|
184 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
185 |
|
185 | |||
186 |
|
186 | |||
187 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
187 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
@@ -194,7 +194,7 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
194 | // 11th case te0 < ts < ts1 && te3 < te |
|
194 | // 11th case te0 < ts < ts1 && te3 < te | |
195 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
195 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; | |
196 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 47, 0, 0}}; |
|
196 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 47, 0, 0}}; | |
197 |
sqp = |
|
197 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
198 |
|
198 | |||
199 |
|
199 | |||
200 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
200 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
@@ -215,7 +215,7 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
215 | // 12th case te0 < ts < ts1 && te3 < te |
|
215 | // 12th case te0 < ts < ts1 && te3 < te | |
216 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
216 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; | |
217 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 10, 0, 0}}; |
|
217 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 10, 0, 0}}; | |
218 |
sqp = |
|
218 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
219 |
|
219 | |||
220 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
220 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
221 |
|
221 | |||
@@ -232,7 +232,7 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
232 | // 12th case ts0 < ts < te0 |
|
232 | // 12th case ts0 < ts < te0 | |
233 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 10, 0}}; |
|
233 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 10, 0}}; | |
234 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 50, 0}}; |
|
234 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 50, 0}}; | |
235 |
sqp = |
|
235 | sqp = DateTimeRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
236 |
|
236 | |||
237 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
237 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
238 | QCOMPARE(notInCach.size(), 0); |
|
238 | QCOMPARE(notInCach.size(), 0); | |
@@ -245,27 +245,27 void TestVariableCacheController::testAddDateTime() | |||||
245 |
|
245 | |||
246 | auto ts0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; |
|
246 | auto ts0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; | |
247 | auto te0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
247 | auto te0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; | |
248 |
auto sqp0 = |
|
248 | auto sqp0 = DateTimeRange{DateUtils::secondsSinceEpoch(ts0), DateUtils::secondsSinceEpoch(te0)}; | |
249 |
|
249 | |||
250 | auto ts1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}}; |
|
250 | auto ts1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}}; | |
251 | auto te1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 8, 0, 0}}; |
|
251 | auto te1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 8, 0, 0}}; | |
252 |
auto sqp1 = |
|
252 | auto sqp1 = DateTimeRange{DateUtils::secondsSinceEpoch(ts1), DateUtils::secondsSinceEpoch(te1)}; | |
253 |
|
253 | |||
254 | auto ts2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 18, 0, 0}}; |
|
254 | auto ts2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 18, 0, 0}}; | |
255 | auto te2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 20, 0, 0}}; |
|
255 | auto te2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 20, 0, 0}}; | |
256 |
auto sqp2 = |
|
256 | auto sqp2 = DateTimeRange{DateUtils::secondsSinceEpoch(ts2), DateUtils::secondsSinceEpoch(te2)}; | |
257 |
|
257 | |||
258 | auto ts01 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
258 | auto ts01 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; | |
259 | auto te01 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}}; |
|
259 | auto te01 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}}; | |
260 |
auto sqp01 = |
|
260 | auto sqp01 = DateTimeRange{DateUtils::secondsSinceEpoch(ts01), DateUtils::secondsSinceEpoch(te01)}; | |
261 |
|
261 | |||
262 | auto ts3 = QDateTime{QDate{2017, 01, 01}, QTime{2, 14, 0, 0}}; |
|
262 | auto ts3 = QDateTime{QDate{2017, 01, 01}, QTime{2, 14, 0, 0}}; | |
263 | auto te3 = QDateTime{QDate{2017, 01, 01}, QTime{2, 16, 0, 0}}; |
|
263 | auto te3 = QDateTime{QDate{2017, 01, 01}, QTime{2, 16, 0, 0}}; | |
264 |
auto sqp3 = |
|
264 | auto sqp3 = DateTimeRange{DateUtils::secondsSinceEpoch(ts3), DateUtils::secondsSinceEpoch(te3)}; | |
265 |
|
265 | |||
266 | auto ts03 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
266 | auto ts03 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; | |
267 | auto te03 = QDateTime{QDate{2017, 01, 01}, QTime{2, 22, 0, 0}}; |
|
267 | auto te03 = QDateTime{QDate{2017, 01, 01}, QTime{2, 22, 0, 0}}; | |
268 |
auto sqp03 = |
|
268 | auto sqp03 = DateTimeRange{DateUtils::secondsSinceEpoch(ts03), DateUtils::secondsSinceEpoch(te03)}; | |
269 |
|
269 | |||
270 |
|
270 | |||
271 | auto var0 = std::make_shared<Variable>(""); |
|
271 | auto var0 = std::make_shared<Variable>(""); |
@@ -33,7 +33,7 std::unique_ptr<TimeController> defaultTimeController() | |||||
33 | QDateTime start{QDate{2017, 01, 01}, QTime{0, 0, 0, 0}}; |
|
33 | QDateTime start{QDate{2017, 01, 01}, QTime{0, 0, 0, 0}}; | |
34 | QDateTime end{QDate{2017, 01, 02}, QTime{0, 0, 0, 0}}; |
|
34 | QDateTime end{QDate{2017, 01, 02}, QTime{0, 0, 0, 0}}; | |
35 | timeController->setDateTimeRange( |
|
35 | timeController->setDateTimeRange( | |
36 |
|
|
36 | DateTimeRange{DateUtils::secondsSinceEpoch(start), DateUtils::secondsSinceEpoch(end)}); | |
37 |
|
37 | |||
38 | return timeController; |
|
38 | return timeController; | |
39 | } |
|
39 | } |
@@ -23,7 +23,7 const auto OPERATION_DELAY = 100; | |||||
23 | * Example: For a range between 00:00:10 and 00:00:20, the generated values are |
|
23 | * Example: For a range between 00:00:10 and 00:00:20, the generated values are | |
24 | * {10,11,12,13,14,15,16,17,18,19,20} |
|
24 | * {10,11,12,13,14,15,16,17,18,19,20} | |
25 | */ |
|
25 | */ | |
26 |
std::vector<double> values(const |
|
26 | std::vector<double> values(const DateTimeRange &range) | |
27 | { |
|
27 | { | |
28 | QTime referenceTime{0, 0}; |
|
28 | QTime referenceTime{0, 0}; | |
29 |
|
29 | |||
@@ -38,7 +38,7 std::vector<double> values(const SqpRange &range) | |||||
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 | void validateRanges(VariableController &variableController, |
|
40 | void validateRanges(VariableController &variableController, | |
41 |
const std::map<int, |
|
41 | const std::map<int, DateTimeRange> &expectedRanges) | |
42 | { |
|
42 | { | |
43 | for (const auto &expectedRangeEntry : expectedRanges) { |
|
43 | for (const auto &expectedRangeEntry : expectedRanges) { | |
44 | auto variableIndex = expectedRangeEntry.first; |
|
44 | auto variableIndex = expectedRangeEntry.first; | |
@@ -112,7 +112,7 struct IOperation { | |||||
112 | *Variable creation operation in the controller |
|
112 | *Variable creation operation in the controller | |
113 | */ |
|
113 | */ | |
114 | struct Create : public IOperation { |
|
114 | struct Create : public IOperation { | |
115 |
explicit Create(int index, const |
|
115 | explicit Create(int index, const DateTimeRange &range) : m_Index{index},m_range(range) {} | |
116 |
|
116 | |||
117 | void exec(VariableController &variableController) const override |
|
117 | void exec(VariableController &variableController) const override | |
118 | { |
|
118 | { | |
@@ -120,14 +120,14 struct Create : public IOperation { | |||||
120 | std::make_unique<TestProvider>(), m_range); |
|
120 | std::make_unique<TestProvider>(), m_range); | |
121 | } |
|
121 | } | |
122 | int m_Index; ///< The index of the variable to create in the controller |
|
122 | int m_Index; ///< The index of the variable to create in the controller | |
123 |
|
|
123 | DateTimeRange m_range; | |
124 | }; |
|
124 | }; | |
125 |
|
125 | |||
126 | /** |
|
126 | /** | |
127 | * Variable move/shift operation in the controller |
|
127 | * Variable move/shift operation in the controller | |
128 | */ |
|
128 | */ | |
129 | struct Move : public IOperation { |
|
129 | struct Move : public IOperation { | |
130 |
explicit Move(int index, const |
|
130 | explicit Move(int index, const DateTimeRange &newRange, bool shift = false, int delayMS = 10) | |
131 | : m_Index{index}, m_NewRange{newRange}, m_Shift{shift}, m_DelayMs{delayMS} |
|
131 | : m_Index{index}, m_NewRange{newRange}, m_Shift{shift}, m_DelayMs{delayMS} | |
132 | { |
|
132 | { | |
133 | } |
|
133 | } | |
@@ -141,7 +141,7 struct Move : public IOperation { | |||||
141 | } |
|
141 | } | |
142 |
|
142 | |||
143 | int m_Index; ///< The index of the variable to move |
|
143 | int m_Index; ///< The index of the variable to move | |
144 |
|
|
144 | DateTimeRange m_NewRange; ///< The new range of the variable | |
145 | bool m_Shift; ///< Performs a shift ( |
|
145 | bool m_Shift; ///< Performs a shift ( | |
146 | int m_DelayMs; ///< wait the delay after running the request ( |
|
146 | int m_DelayMs; ///< wait the delay after running the request ( | |
147 | }; |
|
147 | }; | |
@@ -182,7 +182,7 struct Synchronize : public IOperation { | |||||
182 | */ |
|
182 | */ | |
183 | struct Iteration { |
|
183 | struct Iteration { | |
184 | std::shared_ptr<IOperation> m_Operation; ///< Operation to perform |
|
184 | std::shared_ptr<IOperation> m_Operation; ///< Operation to perform | |
185 |
std::map<int, |
|
185 | std::map<int, DateTimeRange> m_ExpectedRanges; ///< Expected ranges (by variable index) | |
186 | }; |
|
186 | }; | |
187 |
|
187 | |||
188 | using Iterations = std::vector<Iteration>; |
|
188 | using Iterations = std::vector<Iteration>; | |
@@ -219,7 +219,7 void testSyncCase1() | |||||
219 |
|
219 | |||
220 | /// Generates a range according to a start time and a end time (the date is the same) |
|
220 | /// Generates a range according to a start time and a end time (the date is the same) | |
221 | auto range = [](const QTime &startTime, const QTime &endTime) { |
|
221 | auto range = [](const QTime &startTime, const QTime &endTime) { | |
222 |
return |
|
222 | return DateTimeRange{DateUtils::secondsSinceEpoch(QDateTime{{2017, 1, 1}, startTime, Qt::UTC}), | |
223 | DateUtils::secondsSinceEpoch(QDateTime{{2017, 1, 1}, endTime, Qt::UTC})}; |
|
223 | DateUtils::secondsSinceEpoch(QDateTime{{2017, 1, 1}, endTime, Qt::UTC})}; | |
224 | }; |
|
224 | }; | |
225 |
|
225 | |||
@@ -298,7 +298,7 void testSyncCase2() | |||||
298 | QDateTime{{year, month, day}, QTime{hours, minutes, seconds}, Qt::UTC}); |
|
298 | QDateTime{{year, month, day}, QTime{hours, minutes, seconds}, Qt::UTC}); | |
299 | }; |
|
299 | }; | |
300 |
|
300 | |||
301 |
auto initialRange = |
|
301 | auto initialRange = DateTimeRange{dateTime(2017, 1, 1, 12, 0, 0), dateTime(2017, 1, 1, 13, 0, 0)}; | |
302 |
|
302 | |||
303 | Iterations iterations{}; |
|
303 | Iterations iterations{}; | |
304 | // Creates variables var0 and var1 |
|
304 | // Creates variables var0 and var1 | |
@@ -317,29 +317,29 void testSyncCase2() | |||||
317 | iterations.push_back( |
|
317 | iterations.push_back( | |
318 | {std::make_shared<Move>(0, var0NewRange), {{0, var0NewRange}, {1, var0NewRange}}}); |
|
318 | {std::make_shared<Move>(0, var0NewRange), {{0, var0NewRange}, {1, var0NewRange}}}); | |
319 | }; |
|
319 | }; | |
320 |
moveVar0( |
|
320 | moveVar0(DateTimeRange{dateTime(2017, 1, 1, 12, 0, 0), dateTime(2017, 1, 1, 13, 0, 0)}); | |
321 |
moveVar0( |
|
321 | moveVar0(DateTimeRange{dateTime(2017, 1, 1, 14, 0, 0), dateTime(2017, 1, 1, 15, 0, 0)}); | |
322 |
moveVar0( |
|
322 | moveVar0(DateTimeRange{dateTime(2017, 1, 1, 8, 0, 0), dateTime(2017, 1, 1, 9, 0, 0)}); | |
323 | // moveVar0(SqpRange{dateTime(2017, 1, 1, 7, 30, 0), dateTime(2017, 1, 1, 9, 30, 0)}); |
|
323 | // moveVar0(SqpRange{dateTime(2017, 1, 1, 7, 30, 0), dateTime(2017, 1, 1, 9, 30, 0)}); | |
324 |
moveVar0( |
|
324 | moveVar0(DateTimeRange{dateTime(2017, 1, 1, 2, 0, 0), dateTime(2017, 1, 1, 4, 0, 0)}); | |
325 |
moveVar0( |
|
325 | moveVar0(DateTimeRange{dateTime(2017, 1, 1, 6, 0, 0), dateTime(2017, 1, 1, 8, 0, 0)}); | |
326 |
|
326 | |||
327 |
moveVar0( |
|
327 | moveVar0(DateTimeRange{dateTime(2017, 1, 10, 6, 0, 0), dateTime(2017, 1, 15, 8, 0, 0)}); | |
328 |
moveVar0( |
|
328 | moveVar0(DateTimeRange{dateTime(2017, 1, 17, 6, 0, 0), dateTime(2017, 1, 25, 8, 0, 0)}); | |
329 |
moveVar0( |
|
329 | moveVar0(DateTimeRange{dateTime(2017, 1, 2, 6, 0, 0), dateTime(2017, 1, 8, 8, 0, 0)}); | |
330 |
|
330 | |||
331 |
moveVar0( |
|
331 | moveVar0(DateTimeRange{dateTime(2017, 4, 10, 6, 0, 0), dateTime(2017, 6, 15, 8, 0, 0)}); | |
332 |
moveVar0( |
|
332 | moveVar0(DateTimeRange{dateTime(2017, 1, 17, 6, 0, 0), dateTime(2017, 2, 25, 8, 0, 0)}); | |
333 |
moveVar0( |
|
333 | moveVar0(DateTimeRange{dateTime(2017, 7, 2, 6, 0, 0), dateTime(2017, 10, 8, 8, 0, 0)}); | |
334 |
moveVar0( |
|
334 | moveVar0(DateTimeRange{dateTime(2017, 4, 10, 6, 0, 0), dateTime(2017, 6, 15, 8, 0, 0)}); | |
335 |
moveVar0( |
|
335 | moveVar0(DateTimeRange{dateTime(2017, 1, 17, 6, 0, 0), dateTime(2017, 2, 25, 8, 0, 0)}); | |
336 |
moveVar0( |
|
336 | moveVar0(DateTimeRange{dateTime(2017, 7, 2, 6, 0, 0), dateTime(2017, 10, 8, 8, 0, 0)}); | |
337 |
moveVar0( |
|
337 | moveVar0(DateTimeRange{dateTime(2017, 4, 10, 6, 0, 0), dateTime(2017, 6, 15, 8, 0, 0)}); | |
338 |
moveVar0( |
|
338 | moveVar0(DateTimeRange{dateTime(2017, 1, 17, 6, 0, 0), dateTime(2017, 2, 25, 8, 0, 0)}); | |
339 |
moveVar0( |
|
339 | moveVar0(DateTimeRange{dateTime(2017, 7, 2, 6, 0, 0), dateTime(2017, 10, 8, 8, 0, 0)}); | |
340 |
moveVar0( |
|
340 | moveVar0(DateTimeRange{dateTime(2017, 4, 10, 6, 0, 0), dateTime(2017, 6, 15, 8, 0, 0)}); | |
341 |
moveVar0( |
|
341 | moveVar0(DateTimeRange{dateTime(2017, 1, 17, 6, 0, 0), dateTime(2017, 2, 25, 8, 0, 0)}); | |
342 |
moveVar0( |
|
342 | moveVar0(DateTimeRange{dateTime(2017, 7, 2, 6, 0, 0), dateTime(2017, 10, 8, 8, 0, 0)}); | |
343 |
|
343 | |||
344 |
|
344 | |||
345 | QTest::newRow("sync2") << syncId << initialRange << iterations << 4000; |
|
345 | QTest::newRow("sync2") << syncId << initialRange << iterations << 4000; | |
@@ -353,7 +353,7 void testSyncOnVarCase1() | |||||
353 |
|
353 | |||
354 | /// Generates a range according to a start time and a end time (the date is the same) |
|
354 | /// Generates a range according to a start time and a end time (the date is the same) | |
355 | auto range = [](const QTime &startTime, const QTime &endTime) { |
|
355 | auto range = [](const QTime &startTime, const QTime &endTime) { | |
356 |
return |
|
356 | return DateTimeRange{DateUtils::secondsSinceEpoch(QDateTime{{2017, 1, 1}, startTime, Qt::UTC}), | |
357 | DateUtils::secondsSinceEpoch(QDateTime{{2017, 1, 1}, endTime, Qt::UTC})}; |
|
357 | DateUtils::secondsSinceEpoch(QDateTime{{2017, 1, 1}, endTime, Qt::UTC})}; | |
358 | }; |
|
358 | }; | |
359 |
|
359 | |||
@@ -412,7 +412,7 void TestVariableSync::testSync_data() | |||||
412 | // ////////////// // |
|
412 | // ////////////// // | |
413 |
|
413 | |||
414 | QTest::addColumn<QUuid>("syncId"); |
|
414 | QTest::addColumn<QUuid>("syncId"); | |
415 |
QTest::addColumn< |
|
415 | QTest::addColumn<DateTimeRange>("initialRange"); | |
416 | QTest::addColumn<Iterations>("iterations"); |
|
416 | QTest::addColumn<Iterations>("iterations"); | |
417 | QTest::addColumn<int>("operationDelay"); |
|
417 | QTest::addColumn<int>("operationDelay"); | |
418 |
|
418 | |||
@@ -431,7 +431,7 void TestVariableSync::testSyncOneVar_data() | |||||
431 | // ////////////// // |
|
431 | // ////////////// // | |
432 |
|
432 | |||
433 | QTest::addColumn<QUuid>("syncId"); |
|
433 | QTest::addColumn<QUuid>("syncId"); | |
434 |
QTest::addColumn< |
|
434 | QTest::addColumn<DateTimeRange>("initialRange"); | |
435 | QTest::addColumn<Iterations>("creations"); |
|
435 | QTest::addColumn<Iterations>("creations"); | |
436 | QTest::addColumn<Iterations>("iterations"); |
|
436 | QTest::addColumn<Iterations>("iterations"); | |
437 |
|
437 | |||
@@ -450,7 +450,7 void TestVariableSync::testSync() | |||||
450 | //variableController.setTimeController(&timeController); |
|
450 | //variableController.setTimeController(&timeController); | |
451 |
|
451 | |||
452 | QFETCH(QUuid, syncId); |
|
452 | QFETCH(QUuid, syncId); | |
453 |
QFETCH( |
|
453 | QFETCH(DateTimeRange, initialRange); | |
454 | timeController.setDateTimeRange(initialRange); |
|
454 | timeController.setDateTimeRange(initialRange); | |
455 |
|
455 | |||
456 | // Synchronization group used |
|
456 | // Synchronization group used | |
@@ -477,7 +477,7 void TestVariableSync::testSyncOneVar() | |||||
477 | //variableController.setTimeController(&timeController); |
|
477 | //variableController.setTimeController(&timeController); | |
478 |
|
478 | |||
479 | QFETCH(QUuid, syncId); |
|
479 | QFETCH(QUuid, syncId); | |
480 |
QFETCH( |
|
480 | QFETCH(DateTimeRange, initialRange); | |
481 | timeController.setDateTimeRange(initialRange); |
|
481 | timeController.setDateTimeRange(initialRange); | |
482 |
|
482 | |||
483 | // Synchronization group used |
|
483 | // Synchronization group used |
@@ -18,12 +18,12 public: | |||||
18 | explicit TimeWidget(QWidget *parent = 0); |
|
18 | explicit TimeWidget(QWidget *parent = 0); | |
19 | virtual ~TimeWidget(); |
|
19 | virtual ~TimeWidget(); | |
20 |
|
20 | |||
21 |
void setTimeRange( |
|
21 | void setTimeRange(DateTimeRange time); | |
22 |
|
|
22 | DateTimeRange timeRange() const; | |
23 |
|
23 | |||
24 | signals: |
|
24 | signals: | |
25 | /// Signal emitted when the time parameters has beed updated |
|
25 | /// Signal emitted when the time parameters has beed updated | |
26 |
void timeUpdated( |
|
26 | void timeUpdated(DateTimeRange time); | |
27 |
|
27 | |||
28 | public slots: |
|
28 | public slots: | |
29 | /// slot called when time parameters update has ben requested |
|
29 | /// slot called when time parameters update has ben requested |
@@ -33,7 +33,7 struct VisualizationGraphHelper { | |||||
33 | static PlottablesMap create(std::shared_ptr<Variable> variable, QCustomPlot &plot) noexcept; |
|
33 | static PlottablesMap create(std::shared_ptr<Variable> variable, QCustomPlot &plot) noexcept; | |
34 |
|
34 | |||
35 | static void updateData(PlottablesMap &plottables, std::shared_ptr<Variable> variable, |
|
35 | static void updateData(PlottablesMap &plottables, std::shared_ptr<Variable> variable, | |
36 |
const |
|
36 | const DateTimeRange &dateTime); | |
37 |
|
37 | |||
38 | static void setYAxisRange(std::shared_ptr<Variable> variable, QCustomPlot &plot) noexcept; |
|
38 | static void setYAxisRange(std::shared_ptr<Variable> variable, QCustomPlot &plot) noexcept; | |
39 | }; |
|
39 | }; |
@@ -15,7 +15,7 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationGraphWidget) | |||||
15 |
|
15 | |||
16 | class QCPRange; |
|
16 | class QCPRange; | |
17 | class QCustomPlot; |
|
17 | class QCustomPlot; | |
18 |
class |
|
18 | class DateTimeRange; | |
19 | class Variable; |
|
19 | class Variable; | |
20 | class VisualizationWidget; |
|
20 | class VisualizationWidget; | |
21 | class VisualizationZoneWidget; |
|
21 | class VisualizationZoneWidget; | |
@@ -58,7 +58,7 public: | |||||
58 | /// Sets graph options |
|
58 | /// Sets graph options | |
59 | void setFlags(GraphFlags flags); |
|
59 | void setFlags(GraphFlags flags); | |
60 |
|
60 | |||
61 |
void addVariable(std::shared_ptr<Variable> variable, |
|
61 | void addVariable(std::shared_ptr<Variable> variable, DateTimeRange range); | |
62 |
|
62 | |||
63 | /// Removes a variable from the graph |
|
63 | /// Removes a variable from the graph | |
64 | void removeVariable(std::shared_ptr<Variable> variable) noexcept; |
|
64 | void removeVariable(std::shared_ptr<Variable> variable) noexcept; | |
@@ -68,17 +68,17 public: | |||||
68 |
|
68 | |||
69 | /// Sets the y-axis range based on the data of a variable |
|
69 | /// Sets the y-axis range based on the data of a variable | |
70 | void setYRange(std::shared_ptr<Variable> variable); |
|
70 | void setYRange(std::shared_ptr<Variable> variable); | |
71 |
|
|
71 | DateTimeRange graphRange() const noexcept; | |
72 |
void setGraphRange(const |
|
72 | void setGraphRange(const DateTimeRange &range, bool calibration = false); | |
73 | void setAutoRangeOnVariableInitialization(bool value); |
|
73 | void setAutoRangeOnVariableInitialization(bool value); | |
74 |
|
74 | |||
75 | // Zones |
|
75 | // Zones | |
76 | /// Returns the ranges of all the selection zones on the graph |
|
76 | /// Returns the ranges of all the selection zones on the graph | |
77 |
QVector< |
|
77 | QVector<DateTimeRange> selectionZoneRanges() const; | |
78 | /// Adds new selection zones in the graph |
|
78 | /// Adds new selection zones in the graph | |
79 |
void addSelectionZones(const QVector< |
|
79 | void addSelectionZones(const QVector<DateTimeRange> &ranges); | |
80 | /// Adds a new selection zone in the graph |
|
80 | /// Adds a new selection zone in the graph | |
81 |
VisualizationSelectionZoneItem *addSelectionZone(const QString &name, const |
|
81 | VisualizationSelectionZoneItem *addSelectionZone(const QString &name, const DateTimeRange &range); | |
82 | /// Removes the specified selection zone |
|
82 | /// Removes the specified selection zone | |
83 | void removeSelectionZone(VisualizationSelectionZoneItem *selectionZone); |
|
83 | void removeSelectionZone(VisualizationSelectionZoneItem *selectionZone); | |
84 |
|
84 | |||
@@ -110,8 +110,8 public: | |||||
110 | void removeHorizontalCursor(); |
|
110 | void removeHorizontalCursor(); | |
111 |
|
111 | |||
112 | signals: |
|
112 | signals: | |
113 |
void synchronize(const |
|
113 | void synchronize(const DateTimeRange &range, const DateTimeRange &oldRange); | |
114 |
void requestDataLoading(QVector<std::shared_ptr<Variable> > variable, const |
|
114 | void requestDataLoading(QVector<std::shared_ptr<Variable> > variable, const DateTimeRange &range, | |
115 | bool synchronise); |
|
115 | bool synchronise); | |
116 |
|
116 | |||
117 | /// Signal emitted when the variable is about to be removed from the graph |
|
117 | /// Signal emitted when the variable is about to be removed from the graph | |
@@ -152,7 +152,7 private slots: | |||||
152 |
|
152 | |||
153 | void onDataCacheVariableUpdated(); |
|
153 | void onDataCacheVariableUpdated(); | |
154 |
|
154 | |||
155 |
void onUpdateVarDisplaying(std::shared_ptr<Variable> variable, const |
|
155 | void onUpdateVarDisplaying(std::shared_ptr<Variable> variable, const DateTimeRange &range); | |
156 | }; |
|
156 | }; | |
157 |
|
157 | |||
158 | #endif // SCIQLOP_VISUALIZATIONGRAPHWIDGET_H |
|
158 | #endif // SCIQLOP_VISUALIZATIONGRAPHWIDGET_H |
@@ -12,7 +12,7 class VisualizationSelectionZoneItem : public QCPItemRect { | |||||
12 |
|
12 | |||
13 | signals: |
|
13 | signals: | |
14 | /// Signal emitted when the zone range is edited manually |
|
14 | /// Signal emitted when the zone range is edited manually | |
15 |
void rangeEdited(const |
|
15 | void rangeEdited(const DateTimeRange &range); | |
16 |
|
16 | |||
17 | public: |
|
17 | public: | |
18 | VisualizationSelectionZoneItem(QCustomPlot *plot); |
|
18 | VisualizationSelectionZoneItem(QCustomPlot *plot); | |
@@ -23,7 +23,7 public: | |||||
23 | void setName(const QString &name); |
|
23 | void setName(const QString &name); | |
24 | QString name() const; |
|
24 | QString name() const; | |
25 |
|
25 | |||
26 |
|
|
26 | DateTimeRange range() const; | |
27 | void setRange(double tstart, double tend); |
|
27 | void setRange(double tstart, double tend); | |
28 | void setStart(double tstart); |
|
28 | void setStart(double tstart); | |
29 | void setEnd(double tend); |
|
29 | void setEnd(double tend); |
@@ -50,7 +50,7 public slots: | |||||
50 | /// Slot called when a variable is about to be deleted from SciQlop |
|
50 | /// Slot called when a variable is about to be deleted from SciQlop | |
51 | void onVariableAboutToBeDeleted(std::shared_ptr<Variable> variable) noexcept; |
|
51 | void onVariableAboutToBeDeleted(std::shared_ptr<Variable> variable) noexcept; | |
52 |
|
52 | |||
53 |
void onRangeChanged(std::shared_ptr<Variable> variable, const |
|
53 | void onRangeChanged(std::shared_ptr<Variable> variable, const DateTimeRange &range) noexcept; | |
54 |
|
54 | |||
55 | protected: |
|
55 | protected: | |
56 | void closeEvent(QCloseEvent *event) override; |
|
56 | void closeEvent(QCloseEvent *event) override; |
@@ -30,7 +30,7 public: | |||||
30 |
|
30 | |||
31 | /// Sets the range of the zone, only works if there is at least one graph in the zone |
|
31 | /// Sets the range of the zone, only works if there is at least one graph in the zone | |
32 | /// Note: calibrations between graphs are lost. |
|
32 | /// Note: calibrations between graphs are lost. | |
33 |
void setZoneRange(const |
|
33 | void setZoneRange(const DateTimeRange &range); | |
34 |
|
34 | |||
35 | /// Adds a graph widget |
|
35 | /// Adds a graph widget | |
36 | void addGraph(VisualizationGraphWidget *graphWidget); |
|
36 | void addGraph(VisualizationGraphWidget *graphWidget); |
@@ -24,7 +24,7 public: | |||||
24 | * Ctor |
|
24 | * Ctor | |
25 | * @param variable the variable to remove from widgets |
|
25 | * @param variable the variable to remove from widgets | |
26 | */ |
|
26 | */ | |
27 |
explicit RescaleAxeOperation(std::shared_ptr<Variable> variable, const |
|
27 | explicit RescaleAxeOperation(std::shared_ptr<Variable> variable, const DateTimeRange &range); | |
28 |
|
28 | |||
29 | void visitEnter(VisualizationWidget *widget) override final; |
|
29 | void visitEnter(VisualizationWidget *widget) override final; | |
30 | void visitLeave(VisualizationWidget *widget) override final; |
|
30 | void visitLeave(VisualizationWidget *widget) override final; |
@@ -424,7 +424,7 QMimeData *CatalogueEventsModel::mimeData(const QModelIndexList &indexes) const | |||||
424 | QVector<std::shared_ptr<DBEvent> > eventList; |
|
424 | QVector<std::shared_ptr<DBEvent> > eventList; | |
425 | QVector<std::shared_ptr<DBEventProduct> > eventProductList; |
|
425 | QVector<std::shared_ptr<DBEventProduct> > eventProductList; | |
426 |
|
426 | |||
427 |
|
|
427 | DateTimeRange firstTimeRange; | |
428 | for (const auto &index : indexes) { |
|
428 | for (const auto &index : indexes) { | |
429 | if (index.column() == 0) { // only the first column |
|
429 | if (index.column() == 0) { // only the first column | |
430 |
|
430 |
@@ -141,7 +141,7 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { | |||||
141 |
|
141 | |||
142 | for (auto zoneName : m_ZonesForTimeMode) { |
|
142 | for (auto zoneName : m_ZonesForTimeMode) { | |
143 | if (auto zone = tab->getZoneWithName(zoneName)) { |
|
143 | if (auto zone = tab->getZoneWithName(zoneName)) { | |
144 |
|
|
144 | DateTimeRange eventRange; | |
145 | eventRange.m_TStart = event->getTStart(); |
|
145 | eventRange.m_TStart = event->getTStart(); | |
146 | eventRange.m_TEnd = event->getTEnd(); |
|
146 | eventRange.m_TEnd = event->getTEnd(); | |
147 | zone->setZoneRange(eventRange); |
|
147 | zone->setZoneRange(eventRange); | |
@@ -165,13 +165,13 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { | |||||
165 | } |
|
165 | } | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 |
QVector< |
|
168 | QVector<DateTimeRange> getGraphRanges(const std::shared_ptr<DBEvent> &event) | |
169 | { |
|
169 | { | |
170 | // Retrieves the range of each product and the maximum size |
|
170 | // Retrieves the range of each product and the maximum size | |
171 |
QVector< |
|
171 | QVector<DateTimeRange> graphRanges; | |
172 | double maxDt = 0; |
|
172 | double maxDt = 0; | |
173 | for (auto eventProduct : event->getEventProducts()) { |
|
173 | for (auto eventProduct : event->getEventProducts()) { | |
174 |
|
|
174 | DateTimeRange eventRange; | |
175 | eventRange.m_TStart = eventProduct.getTStart(); |
|
175 | eventRange.m_TStart = eventProduct.getTStart(); | |
176 | eventRange.m_TEnd = eventProduct.getTEnd(); |
|
176 | eventRange.m_TEnd = eventProduct.getTEnd(); | |
177 | graphRanges << eventRange; |
|
177 | graphRanges << eventRange; | |
@@ -186,12 +186,12 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { | |||||
186 | maxDt *= (100.0 + EVENT_RANGE_MARGE) / 100.0; |
|
186 | maxDt *= (100.0 + EVENT_RANGE_MARGE) / 100.0; | |
187 |
|
187 | |||
188 | // Corrects the graph ranges so that they all have the same size |
|
188 | // Corrects the graph ranges so that they all have the same size | |
189 |
QVector< |
|
189 | QVector<DateTimeRange> correctedGraphRanges; | |
190 | for (auto range : graphRanges) { |
|
190 | for (auto range : graphRanges) { | |
191 | auto dt = range.m_TEnd - range.m_TStart; |
|
191 | auto dt = range.m_TEnd - range.m_TStart; | |
192 | auto diff = qAbs((maxDt - dt) / 2.0); |
|
192 | auto diff = qAbs((maxDt - dt) / 2.0); | |
193 |
|
193 | |||
194 |
|
|
194 | DateTimeRange correctedRange; | |
195 | correctedRange.m_TStart = range.m_TStart - diff; |
|
195 | correctedRange.m_TStart = range.m_TStart - diff; | |
196 | correctedRange.m_TEnd = range.m_TEnd + diff; |
|
196 | correctedRange.m_TEnd = range.m_TEnd + diff; | |
197 |
|
197 | |||
@@ -270,7 +270,7 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { | |||||
270 | auto range = *itRange; |
|
270 | auto range = *itRange; | |
271 | ++itRange; |
|
271 | ++itRange; | |
272 |
|
272 | |||
273 |
|
|
273 | DateTimeRange productRange; | |
274 | productRange.m_TStart = eventProduct.getTStart(); |
|
274 | productRange.m_TStart = eventProduct.getTStart(); | |
275 | productRange.m_TEnd = eventProduct.getTEnd(); |
|
275 | productRange.m_TEnd = eventProduct.getTEnd(); | |
276 |
|
276 |
@@ -118,6 +118,7 bool CatalogueTreeItem::dropMimeData(const QMimeData *data, Qt::DropAction actio | |||||
118 | impl->m_Catalogue->addEvent(event->getUniqId()); |
|
118 | impl->m_Catalogue->addEvent(event->getUniqId()); | |
119 | sqpApp->catalogueController().updateCatalogue(impl->m_Catalogue); |
|
119 | sqpApp->catalogueController().updateCatalogue(impl->m_Catalogue); | |
120 | } |
|
120 | } | |
|
121 | return true; | |||
121 | } |
|
122 | } | |
122 |
|
123 | |||
123 | std::shared_ptr<DBCatalogue> CatalogueTreeItem::catalogue() const |
|
124 | std::shared_ptr<DBCatalogue> CatalogueTreeItem::catalogue() const |
@@ -51,9 +51,9 public: | |||||
51 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection); |
|
51 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection); | |
52 |
|
52 | |||
53 | connect(m_VariableController.get(), |
|
53 | connect(m_VariableController.get(), | |
54 |
SIGNAL(rangeChanged(std::shared_ptr<Variable>, const |
|
54 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const DateTimeRange &)), | |
55 | m_VisualizationController.get(), |
|
55 | m_VisualizationController.get(), | |
56 |
SIGNAL(rangeChanged(std::shared_ptr<Variable>, const |
|
56 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const DateTimeRange &))); | |
57 |
|
57 | |||
58 |
|
58 | |||
59 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); |
|
59 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); |
@@ -48,7 +48,7 TimeWidget::TimeWidget(QWidget *parent) | |||||
48 | ui->startDateTimeEdit->setDateTime(startDateTime); |
|
48 | ui->startDateTimeEdit->setDateTime(startDateTime); | |
49 | ui->endDateTimeEdit->setDateTime(endDateTime); |
|
49 | ui->endDateTimeEdit->setDateTime(endDateTime); | |
50 |
|
50 | |||
51 |
auto dateTime = |
|
51 | auto dateTime = DateTimeRange{DateUtils::secondsSinceEpoch(startDateTime), | |
52 | DateUtils::secondsSinceEpoch(endDateTime)}; |
|
52 | DateUtils::secondsSinceEpoch(endDateTime)}; | |
53 |
|
53 | |||
54 | sqpApp->timeController().setDateTimeRange(dateTime); |
|
54 | sqpApp->timeController().setDateTimeRange(dateTime); | |
@@ -60,7 +60,7 TimeWidget::~TimeWidget() | |||||
60 | delete ui; |
|
60 | delete ui; | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 |
void TimeWidget::setTimeRange( |
|
63 | void TimeWidget::setTimeRange(DateTimeRange time) | |
64 | { |
|
64 | { | |
65 | auto startDateTime = DateUtils::dateTime(time.m_TStart); |
|
65 | auto startDateTime = DateUtils::dateTime(time.m_TStart); | |
66 | auto endDateTime = DateUtils::dateTime(time.m_TEnd); |
|
66 | auto endDateTime = DateUtils::dateTime(time.m_TEnd); | |
@@ -69,9 +69,9 void TimeWidget::setTimeRange(SqpRange time) | |||||
69 | ui->endDateTimeEdit->setDateTime(endDateTime); |
|
69 | ui->endDateTimeEdit->setDateTime(endDateTime); | |
70 | } |
|
70 | } | |
71 |
|
71 | |||
72 |
|
|
72 | DateTimeRange TimeWidget::timeRange() const | |
73 | { |
|
73 | { | |
74 |
return |
|
74 | return DateTimeRange{DateUtils::secondsSinceEpoch(ui->startDateTimeEdit->dateTime()), | |
75 | DateUtils::secondsSinceEpoch(ui->endDateTimeEdit->dateTime())}; |
|
75 | DateUtils::secondsSinceEpoch(ui->endDateTimeEdit->dateTime())}; | |
76 | } |
|
76 | } | |
77 |
|
77 |
@@ -92,13 +92,13 struct PlottablesCreator<T, | |||||
92 | */ |
|
92 | */ | |
93 | template <typename T, typename Enabled = void> |
|
93 | template <typename T, typename Enabled = void> | |
94 | struct PlottablesUpdater { |
|
94 | struct PlottablesUpdater { | |
95 |
static void setPlotYAxisRange(T &, const |
|
95 | static void setPlotYAxisRange(T &, const DateTimeRange &, QCustomPlot &) | |
96 | { |
|
96 | { | |
97 | qCCritical(LOG_VisualizationGraphHelper()) |
|
97 | qCCritical(LOG_VisualizationGraphHelper()) | |
98 | << QObject::tr("Can't set plot y-axis range: unmanaged data series type"); |
|
98 | << QObject::tr("Can't set plot y-axis range: unmanaged data series type"); | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 |
static void updatePlottables(T &, PlottablesMap &, const |
|
101 | static void updatePlottables(T &, PlottablesMap &, const DateTimeRange &, bool) | |
102 | { |
|
102 | { | |
103 | qCCritical(LOG_VisualizationGraphHelper()) |
|
103 | qCCritical(LOG_VisualizationGraphHelper()) | |
104 | << QObject::tr("Can't update plottables: unmanaged data series type"); |
|
104 | << QObject::tr("Can't update plottables: unmanaged data series type"); | |
@@ -114,7 +114,7 template <typename T> | |||||
114 | struct PlottablesUpdater<T, |
|
114 | struct PlottablesUpdater<T, | |
115 | typename std::enable_if_t<std::is_base_of<ScalarSeries, T>::value |
|
115 | typename std::enable_if_t<std::is_base_of<ScalarSeries, T>::value | |
116 | or std::is_base_of<VectorSeries, T>::value> > { |
|
116 | or std::is_base_of<VectorSeries, T>::value> > { | |
117 |
static void setPlotYAxisRange(T &dataSeries, const |
|
117 | static void setPlotYAxisRange(T &dataSeries, const DateTimeRange &xAxisRange, QCustomPlot &plot) | |
118 | { |
|
118 | { | |
119 | auto minValue = 0., maxValue = 0.; |
|
119 | auto minValue = 0., maxValue = 0.; | |
120 |
|
120 | |||
@@ -132,7 +132,7 struct PlottablesUpdater<T, | |||||
132 | plot.yAxis->setRange(QCPRange{minValue, maxValue}); |
|
132 | plot.yAxis->setRange(QCPRange{minValue, maxValue}); | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 |
static void updatePlottables(T &dataSeries, PlottablesMap &plottables, const |
|
135 | static void updatePlottables(T &dataSeries, PlottablesMap &plottables, const DateTimeRange &range, | |
136 | bool rescaleAxes) |
|
136 | bool rescaleAxes) | |
137 | { |
|
137 | { | |
138 |
|
138 | |||
@@ -179,7 +179,7 struct PlottablesUpdater<T, | |||||
179 | template <typename T> |
|
179 | template <typename T> | |
180 | struct PlottablesUpdater<T, |
|
180 | struct PlottablesUpdater<T, | |
181 | typename std::enable_if_t<std::is_base_of<SpectrogramSeries, T>::value> > { |
|
181 | typename std::enable_if_t<std::is_base_of<SpectrogramSeries, T>::value> > { | |
182 |
static void setPlotYAxisRange(T &dataSeries, const |
|
182 | static void setPlotYAxisRange(T &dataSeries, const DateTimeRange &xAxisRange, QCustomPlot &plot) | |
183 | { |
|
183 | { | |
184 | double min, max; |
|
184 | double min, max; | |
185 | std::tie(min, max) = dataSeries.yBounds(); |
|
185 | std::tie(min, max) = dataSeries.yBounds(); | |
@@ -189,7 +189,7 struct PlottablesUpdater<T, | |||||
189 | } |
|
189 | } | |
190 | } |
|
190 | } | |
191 |
|
191 | |||
192 |
static void updatePlottables(T &dataSeries, PlottablesMap &plottables, const |
|
192 | static void updatePlottables(T &dataSeries, PlottablesMap &plottables, const DateTimeRange &range, | |
193 | bool rescaleAxes) |
|
193 | bool rescaleAxes) | |
194 | { |
|
194 | { | |
195 | if (plottables.empty()) { |
|
195 | if (plottables.empty()) { | |
@@ -256,8 +256,8 struct PlottablesUpdater<T, | |||||
256 | struct IPlottablesHelper { |
|
256 | struct IPlottablesHelper { | |
257 | virtual ~IPlottablesHelper() noexcept = default; |
|
257 | virtual ~IPlottablesHelper() noexcept = default; | |
258 | virtual PlottablesMap create(QCustomPlot &plot) const = 0; |
|
258 | virtual PlottablesMap create(QCustomPlot &plot) const = 0; | |
259 |
virtual void setYAxisRange(const |
|
259 | virtual void setYAxisRange(const DateTimeRange &xAxisRange, QCustomPlot &plot) const = 0; | |
260 |
virtual void update(PlottablesMap &plottables, const |
|
260 | virtual void update(PlottablesMap &plottables, const DateTimeRange &range, | |
261 | bool rescaleAxes = false) const = 0; |
|
261 | bool rescaleAxes = false) const = 0; | |
262 | }; |
|
262 | }; | |
263 |
|
263 | |||
@@ -274,7 +274,7 struct PlottablesHelper : public IPlottablesHelper { | |||||
274 | return PlottablesCreator<T>::createPlottables(plot); |
|
274 | return PlottablesCreator<T>::createPlottables(plot); | |
275 | } |
|
275 | } | |
276 |
|
276 | |||
277 |
void update(PlottablesMap &plottables, const |
|
277 | void update(PlottablesMap &plottables, const DateTimeRange &range, bool rescaleAxes) const override | |
278 | { |
|
278 | { | |
279 | if (m_DataSeries) { |
|
279 | if (m_DataSeries) { | |
280 | PlottablesUpdater<T>::updatePlottables(*m_DataSeries, plottables, range, rescaleAxes); |
|
280 | PlottablesUpdater<T>::updatePlottables(*m_DataSeries, plottables, range, rescaleAxes); | |
@@ -286,7 +286,7 struct PlottablesHelper : public IPlottablesHelper { | |||||
286 | } |
|
286 | } | |
287 | } |
|
287 | } | |
288 |
|
288 | |||
289 |
void setYAxisRange(const |
|
289 | void setYAxisRange(const DateTimeRange &xAxisRange, QCustomPlot &plot) const override | |
290 | { |
|
290 | { | |
291 | if (m_DataSeries) { |
|
291 | if (m_DataSeries) { | |
292 | PlottablesUpdater<T>::setPlotYAxisRange(*m_DataSeries, xAxisRange, plot); |
|
292 | PlottablesUpdater<T>::setPlotYAxisRange(*m_DataSeries, xAxisRange, plot); | |
@@ -354,7 +354,7 void VisualizationGraphHelper::setYAxisRange(std::shared_ptr<Variable> variable, | |||||
354 |
|
354 | |||
355 | void VisualizationGraphHelper::updateData(PlottablesMap &plottables, |
|
355 | void VisualizationGraphHelper::updateData(PlottablesMap &plottables, | |
356 | std::shared_ptr<Variable> variable, |
|
356 | std::shared_ptr<Variable> variable, | |
357 |
const |
|
357 | const DateTimeRange &dateTime) | |
358 | { |
|
358 | { | |
359 | auto helper = createHelper(variable); |
|
359 | auto helper = createHelper(variable); | |
360 | helper->update(plottables, dateTime); |
|
360 | helper->update(plottables, dateTime); |
@@ -67,7 +67,7 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate { | |||||
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void updateData(PlottablesMap &plottables, std::shared_ptr<Variable> variable, |
|
69 | void updateData(PlottablesMap &plottables, std::shared_ptr<Variable> variable, | |
70 |
const |
|
70 | const DateTimeRange &range) | |
71 | { |
|
71 | { | |
72 | VisualizationGraphHelper::updateData(plottables, variable, range); |
|
72 | VisualizationGraphHelper::updateData(plottables, variable, range); | |
73 |
|
73 | |||
@@ -294,10 +294,10 void VisualizationGraphWidget::setFlags(GraphFlags flags) | |||||
294 | impl->m_Flags = std::move(flags); |
|
294 | impl->m_Flags = std::move(flags); | |
295 | } |
|
295 | } | |
296 |
|
296 | |||
297 |
void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable, |
|
297 | void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable, DateTimeRange range) | |
298 | { |
|
298 | { | |
299 | /// Lambda used to set graph's units and range according to the variable passed in parameter |
|
299 | /// Lambda used to set graph's units and range according to the variable passed in parameter | |
300 |
auto loadRange = [this](std::shared_ptr<Variable> variable, const |
|
300 | auto loadRange = [this](std::shared_ptr<Variable> variable, const DateTimeRange &range) { | |
301 | impl->m_RenderingDelegate->setAxesUnits(*variable); |
|
301 | impl->m_RenderingDelegate->setAxesUnits(*variable); | |
302 |
|
302 | |||
303 | this->setFlags(GraphFlag::DisableAll); |
|
303 | this->setFlags(GraphFlag::DisableAll); | |
@@ -386,13 +386,13 void VisualizationGraphWidget::setYRange(std::shared_ptr<Variable> variable) | |||||
386 | VisualizationGraphHelper::setYAxisRange(variable, *ui->widget); |
|
386 | VisualizationGraphHelper::setYAxisRange(variable, *ui->widget); | |
387 | } |
|
387 | } | |
388 |
|
388 | |||
389 |
|
|
389 | DateTimeRange VisualizationGraphWidget::graphRange() const noexcept | |
390 | { |
|
390 | { | |
391 | auto graphRange = ui->widget->xAxis->range(); |
|
391 | auto graphRange = ui->widget->xAxis->range(); | |
392 |
return |
|
392 | return DateTimeRange{graphRange.lower, graphRange.upper}; | |
393 | } |
|
393 | } | |
394 |
|
394 | |||
395 |
void VisualizationGraphWidget::setGraphRange(const |
|
395 | void VisualizationGraphWidget::setGraphRange(const DateTimeRange &range, bool calibration) | |
396 | { |
|
396 | { | |
397 | qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::setGraphRange START"); |
|
397 | qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::setGraphRange START"); | |
398 |
|
398 | |||
@@ -415,9 +415,9 void VisualizationGraphWidget::setAutoRangeOnVariableInitialization(bool value) | |||||
415 | impl->m_VariableAutoRangeOnInit = value; |
|
415 | impl->m_VariableAutoRangeOnInit = value; | |
416 | } |
|
416 | } | |
417 |
|
417 | |||
418 |
QVector< |
|
418 | QVector<DateTimeRange> VisualizationGraphWidget::selectionZoneRanges() const | |
419 | { |
|
419 | { | |
420 |
QVector< |
|
420 | QVector<DateTimeRange> ranges; | |
421 | for (auto zone : impl->m_SelectionZones) { |
|
421 | for (auto zone : impl->m_SelectionZones) { | |
422 | ranges << zone->range(); |
|
422 | ranges << zone->range(); | |
423 | } |
|
423 | } | |
@@ -425,7 +425,7 QVector<SqpRange> VisualizationGraphWidget::selectionZoneRanges() const | |||||
425 | return ranges; |
|
425 | return ranges; | |
426 | } |
|
426 | } | |
427 |
|
427 | |||
428 |
void VisualizationGraphWidget::addSelectionZones(const QVector< |
|
428 | void VisualizationGraphWidget::addSelectionZones(const QVector<DateTimeRange> &ranges) | |
429 | { |
|
429 | { | |
430 | for (const auto &range : ranges) { |
|
430 | for (const auto &range : ranges) { | |
431 | // note: ownership is transfered to QCustomPlot |
|
431 | // note: ownership is transfered to QCustomPlot | |
@@ -438,7 +438,7 void VisualizationGraphWidget::addSelectionZones(const QVector<SqpRange> &ranges | |||||
438 | } |
|
438 | } | |
439 |
|
439 | |||
440 | VisualizationSelectionZoneItem *VisualizationGraphWidget::addSelectionZone(const QString &name, |
|
440 | VisualizationSelectionZoneItem *VisualizationGraphWidget::addSelectionZone(const QString &name, | |
441 |
const |
|
441 | const DateTimeRange &range) | |
442 | { |
|
442 | { | |
443 | // note: ownership is transfered to QCustomPlot |
|
443 | // note: ownership is transfered to QCustomPlot | |
444 | auto zone = new VisualizationSelectionZoneItem(&plot()); |
|
444 | auto zone = new VisualizationSelectionZoneItem(&plot()); | |
@@ -771,8 +771,8 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange | |||||
771 | << QThread::currentThread()->objectName() << "DoAcqui" |
|
771 | << QThread::currentThread()->objectName() << "DoAcqui" | |
772 | << impl->m_Flags.testFlag(GraphFlag::EnableAcquisition); |
|
772 | << impl->m_Flags.testFlag(GraphFlag::EnableAcquisition); | |
773 |
|
773 | |||
774 |
auto graphRange = |
|
774 | auto graphRange = DateTimeRange{t1.lower, t1.upper}; | |
775 |
auto oldGraphRange = |
|
775 | auto oldGraphRange = DateTimeRange{t2.lower, t2.upper}; | |
776 |
|
776 | |||
777 | if (impl->m_Flags.testFlag(GraphFlag::EnableAcquisition)) { |
|
777 | if (impl->m_Flags.testFlag(GraphFlag::EnableAcquisition)) { | |
778 | QVector<std::shared_ptr<Variable> > variableUnderGraphVector; |
|
778 | QVector<std::shared_ptr<Variable> > variableUnderGraphVector; | |
@@ -1058,7 +1058,7 void VisualizationGraphWidget::onMouseRelease(QMouseEvent *event) noexcept | |||||
1058 | void VisualizationGraphWidget::onDataCacheVariableUpdated() |
|
1058 | void VisualizationGraphWidget::onDataCacheVariableUpdated() | |
1059 | { |
|
1059 | { | |
1060 | auto graphRange = ui->widget->xAxis->range(); |
|
1060 | auto graphRange = ui->widget->xAxis->range(); | |
1061 |
auto dateTime = |
|
1061 | auto dateTime = DateTimeRange{graphRange.lower, graphRange.upper}; | |
1062 |
|
1062 | |||
1063 | for (auto &variableEntry : impl->m_VariableToPlotMultiMap) { |
|
1063 | for (auto &variableEntry : impl->m_VariableToPlotMultiMap) { | |
1064 | auto variable = variableEntry.first; |
|
1064 | auto variable = variableEntry.first; | |
@@ -1073,7 +1073,7 void VisualizationGraphWidget::onDataCacheVariableUpdated() | |||||
1073 | } |
|
1073 | } | |
1074 |
|
1074 | |||
1075 | void VisualizationGraphWidget::onUpdateVarDisplaying(std::shared_ptr<Variable> variable, |
|
1075 | void VisualizationGraphWidget::onUpdateVarDisplaying(std::shared_ptr<Variable> variable, | |
1076 |
const |
|
1076 | const DateTimeRange &range) | |
1077 | { |
|
1077 | { | |
1078 | auto it = impl->m_VariableToPlotMultiMap.find(variable); |
|
1078 | auto it = impl->m_VariableToPlotMultiMap.find(variable); | |
1079 | if (it != impl->m_VariableToPlotMultiMap.end()) { |
|
1079 | if (it != impl->m_VariableToPlotMultiMap.end()) { |
@@ -180,9 +180,9 QString VisualizationSelectionZoneItem::name() const | |||||
180 | return impl->m_NameLabelItem->text(); |
|
180 | return impl->m_NameLabelItem->text(); | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
183 |
|
|
183 | DateTimeRange VisualizationSelectionZoneItem::range() const | |
184 | { |
|
184 | { | |
185 |
|
|
185 | DateTimeRange range; | |
186 | range.m_TStart = impl->m_T1 <= impl->m_T2 ? impl->m_T1 : impl->m_T2; |
|
186 | range.m_TStart = impl->m_T1 <= impl->m_T2 ? impl->m_T1 : impl->m_T2; | |
187 | range.m_TEnd = impl->m_T1 > impl->m_T2 ? impl->m_T1 : impl->m_T2; |
|
187 | range.m_TEnd = impl->m_T1 > impl->m_T2 ? impl->m_T1 : impl->m_T2; | |
188 | return range; |
|
188 | return range; |
@@ -203,7 +203,7 void VisualizationWidget::onVariableAboutToBeDeleted(std::shared_ptr<Variable> v | |||||
203 | } |
|
203 | } | |
204 |
|
204 | |||
205 | void VisualizationWidget::onRangeChanged(std::shared_ptr<Variable> variable, |
|
205 | void VisualizationWidget::onRangeChanged(std::shared_ptr<Variable> variable, | |
206 |
const |
|
206 | const DateTimeRange &range) noexcept | |
207 | { |
|
207 | { | |
208 | // Calls the operation of rescaling all graph that contrains variable in the visualization |
|
208 | // Calls the operation of rescaling all graph that contrains variable in the visualization | |
209 | auto rescaleVariableOperation = RescaleAxeOperation{variable, range}; |
|
209 | auto rescaleVariableOperation = RescaleAxeOperation{variable, range}; |
@@ -153,7 +153,7 VisualizationZoneWidget::~VisualizationZoneWidget() | |||||
153 | delete ui; |
|
153 | delete ui; | |
154 | } |
|
154 | } | |
155 |
|
155 | |||
156 |
void VisualizationZoneWidget::setZoneRange(const |
|
156 | void VisualizationZoneWidget::setZoneRange(const DateTimeRange &range) | |
157 | { |
|
157 | { | |
158 | if (auto graph = firstGraph()) { |
|
158 | if (auto graph = firstGraph()) { | |
159 | graph->setGraphRange(range); |
|
159 | graph->setGraphRange(range); | |
@@ -198,8 +198,8 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V | |||||
198 |
|
198 | |||
199 |
|
199 | |||
200 | // Lambda to synchronize zone widget |
|
200 | // Lambda to synchronize zone widget | |
201 |
auto synchronizeZoneWidget = [this, graphWidget](const |
|
201 | auto synchronizeZoneWidget = [this, graphWidget](const DateTimeRange &graphRange, | |
202 |
const |
|
202 | const DateTimeRange &oldGraphRange) { | |
203 |
|
203 | |||
204 | auto zoomType = VariableController::getZoomType(graphRange, oldGraphRange); |
|
204 | auto zoomType = VariableController::getZoomType(graphRange, oldGraphRange); | |
205 | auto frameLayout = ui->dragDropContainer->layout(); |
|
205 | auto frameLayout = ui->dragDropContainer->layout(); | |
@@ -289,7 +289,7 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V | |||||
289 | connect(graphWidget, &VisualizationGraphWidget::variableAboutToBeRemoved, this, |
|
289 | connect(graphWidget, &VisualizationGraphWidget::variableAboutToBeRemoved, this, | |
290 | &VisualizationZoneWidget::onVariableAboutToBeRemoved); |
|
290 | &VisualizationZoneWidget::onVariableAboutToBeRemoved); | |
291 |
|
291 | |||
292 |
auto range = |
|
292 | auto range = DateTimeRange{}; | |
293 | if (auto firstGraph = this->firstGraph()) { |
|
293 | if (auto firstGraph = this->firstGraph()) { | |
294 | // Case of a new graph in a existant zone |
|
294 | // Case of a new graph in a existant zone | |
295 | range = firstGraph->graphRange(); |
|
295 | range = firstGraph->graphRange(); |
@@ -4,16 +4,16 | |||||
4 | Q_LOGGING_CATEGORY(LOG_RescaleAxeOperation, "RescaleAxeOperation") |
|
4 | Q_LOGGING_CATEGORY(LOG_RescaleAxeOperation, "RescaleAxeOperation") | |
5 |
|
5 | |||
6 | struct RescaleAxeOperation::RescaleAxeOperationPrivate { |
|
6 | struct RescaleAxeOperation::RescaleAxeOperationPrivate { | |
7 |
explicit RescaleAxeOperationPrivate(std::shared_ptr<Variable> variable, const |
|
7 | explicit RescaleAxeOperationPrivate(std::shared_ptr<Variable> variable, const DateTimeRange &range) | |
8 | : m_Variable{variable}, m_Range{range} |
|
8 | : m_Variable{variable}, m_Range{range} | |
9 | { |
|
9 | { | |
10 | } |
|
10 | } | |
11 |
|
11 | |||
12 | std::shared_ptr<Variable> m_Variable; |
|
12 | std::shared_ptr<Variable> m_Variable; | |
13 |
|
|
13 | DateTimeRange m_Range; | |
14 | }; |
|
14 | }; | |
15 |
|
15 | |||
16 |
RescaleAxeOperation::RescaleAxeOperation(std::shared_ptr<Variable> variable, const |
|
16 | RescaleAxeOperation::RescaleAxeOperation(std::shared_ptr<Variable> variable, const DateTimeRange &range) | |
17 | : impl{spimpl::make_unique_impl<RescaleAxeOperationPrivate>(variable, range)} |
|
17 | : impl{spimpl::make_unique_impl<RescaleAxeOperationPrivate>(variable, range)} | |
18 | { |
|
18 | { | |
19 | } |
|
19 | } |
@@ -53,17 +53,17 target_link_libraries(pytestamdalib PUBLIC pysciqlop) | |||||
53 |
|
53 | |||
54 | GET_PROPERTY(CORE_PYTHON_PATH GLOBAL PROPERTY CORE_PYTHON_PATH) |
|
54 | GET_PROPERTY(CORE_PYTHON_PATH GLOBAL PROPERTY CORE_PYTHON_PATH) | |
55 |
|
55 | |||
56 |
declare_test(TestAmdaFileParserEmbed TestAmdaFileParserEmbed "tests/PyTestAmdaWrapperExe.cpp" " |
|
56 | declare_test(TestAmdaFileParserEmbed TestAmdaFileParserEmbed "tests/PyTestAmdaWrapperExe.cpp" "pytestamdalib") | |
57 | target_compile_definitions(TestAmdaFileParserEmbed PRIVATE -DPYTESTAMDA_SCRIPT="${CMAKE_CURRENT_LIST_DIR}/tests/TestAmdaFileParser.py") |
|
57 | target_compile_definitions(TestAmdaFileParserEmbed PRIVATE -DPYTESTAMDA_SCRIPT="${CMAKE_CURRENT_LIST_DIR}/tests/TestAmdaFileParser.py") | |
58 | set_tests_properties(TestAmdaFileParserEmbed PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CORE_PYTHON_PATH}) |
|
58 | set_tests_properties(TestAmdaFileParserEmbed PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CORE_PYTHON_PATH}) | |
59 |
|
59 | |||
60 |
|
60 | |||
61 |
declare_test(TestAmdaDownloadEmbed TestAmdaDownloadEmbed "tests/PyTestAmdaWrapperExe.cpp" " |
|
61 | declare_test(TestAmdaDownloadEmbed TestAmdaDownloadEmbed "tests/PyTestAmdaWrapperExe.cpp" "pytestamdalib") | |
62 | target_compile_definitions(TestAmdaDownloadEmbed PRIVATE -DPYTESTAMDA_SCRIPT="${CMAKE_CURRENT_LIST_DIR}/tests/TestAmdaDownload.py") |
|
62 | target_compile_definitions(TestAmdaDownloadEmbed PRIVATE -DPYTESTAMDA_SCRIPT="${CMAKE_CURRENT_LIST_DIR}/tests/TestAmdaDownload.py") | |
63 | set_tests_properties(TestAmdaDownloadEmbed PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CORE_PYTHON_PATH}) |
|
63 | set_tests_properties(TestAmdaDownloadEmbed PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CORE_PYTHON_PATH}) | |
64 |
|
64 | |||
65 |
|
65 | |||
66 |
declare_test(TestAmdaMiniFuzzEmbed TestAmdaMiniFuzzEmbed "tests/PyTestAmdaWrapperExe.cpp" " |
|
66 | declare_test(TestAmdaMiniFuzzEmbed TestAmdaMiniFuzzEmbed "tests/PyTestAmdaWrapperExe.cpp" "pytestamdalib") | |
67 | target_compile_definitions(TestAmdaMiniFuzzEmbed PRIVATE -DPYTESTAMDA_SCRIPT="${CMAKE_CURRENT_LIST_DIR}/tests/TestAmdaMiniFuzz.py") |
|
67 | target_compile_definitions(TestAmdaMiniFuzzEmbed PRIVATE -DPYTESTAMDA_SCRIPT="${CMAKE_CURRENT_LIST_DIR}/tests/TestAmdaMiniFuzz.py") | |
68 | set_tests_properties(TestAmdaMiniFuzzEmbed PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CORE_PYTHON_PATH}) |
|
68 | set_tests_properties(TestAmdaMiniFuzzEmbed PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CORE_PYTHON_PATH}) | |
69 |
|
69 |
@@ -28,7 +28,7 public: | |||||
28 | void requestDataAborting(QUuid acqIdentifier) override; |
|
28 | void requestDataAborting(QUuid acqIdentifier) override; | |
29 |
|
29 | |||
30 | private: |
|
30 | private: | |
31 |
void retrieveData(QUuid token, const |
|
31 | void retrieveData(QUuid token, const DateTimeRange &dateTime, const QVariantHash &data); | |
32 |
|
32 | |||
33 | void updateRequestProgress(QUuid acqIdentifier, std::shared_ptr<QNetworkRequest> request, |
|
33 | void updateRequestProgress(QUuid acqIdentifier, std::shared_ptr<QNetworkRequest> request, | |
34 | double progress); |
|
34 | double progress); |
@@ -145,7 +145,7 void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier, | |||||
145 | } |
|
145 | } | |
146 | } |
|
146 | } | |
147 |
|
147 | |||
148 |
void AmdaProvider::retrieveData(QUuid token, const |
|
148 | void AmdaProvider::retrieveData(QUuid token, const DateTimeRange &dateTime, const QVariantHash &data) | |
149 | { |
|
149 | { | |
150 | // Retrieves product ID from data: if the value is invalid, no request is made |
|
150 | // Retrieves product ID from data: if the value is invalid, no request is made | |
151 | auto productId = data.value(AMDA_XML_ID_KEY).toString(); |
|
151 | auto productId = data.value(AMDA_XML_ID_KEY).toString(); |
@@ -96,7 +96,7 void FuzzingState::desynchronizeVariable(VariableId variableId, SyncGroupId sync | |||||
96 | } |
|
96 | } | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 |
void FuzzingState::updateRanges(VariableId variableId, const |
|
99 | void FuzzingState::updateRanges(VariableId variableId, const DateTimeRange &newRange) | |
100 | { |
|
100 | { | |
101 | auto syncGroupId = this->syncGroupId(variableId); |
|
101 | auto syncGroupId = this->syncGroupId(variableId); | |
102 |
|
102 |
@@ -69,7 +69,7 extern const QString VALIDATION_FREQUENCY_BOUNDS_PROPERTY; | |||||
69 | class Variable; |
|
69 | class Variable; | |
70 | struct VariableState { |
|
70 | struct VariableState { | |
71 | std::shared_ptr<Variable> m_Variable{nullptr}; |
|
71 | std::shared_ptr<Variable> m_Variable{nullptr}; | |
72 |
|
|
72 | DateTimeRange m_Range{INVALID_RANGE}; | |
73 | }; |
|
73 | }; | |
74 |
|
74 | |||
75 | using VariableId = int; |
|
75 | using VariableId = int; | |
@@ -82,7 +82,7 using VariablesPool = std::map<VariableId, VariableState>; | |||||
82 | */ |
|
82 | */ | |
83 | struct SyncGroup { |
|
83 | struct SyncGroup { | |
84 | std::set<VariableId> m_Variables{}; |
|
84 | std::set<VariableId> m_Variables{}; | |
85 |
|
|
85 | DateTimeRange m_Range{INVALID_RANGE}; | |
86 | }; |
|
86 | }; | |
87 |
|
87 | |||
88 | using SyncGroupId = QUuid; |
|
88 | using SyncGroupId = QUuid; | |
@@ -119,7 +119,7 struct FuzzingState { | |||||
119 | /// Updates the range of a variable and all variables to which it is synchronized |
|
119 | /// Updates the range of a variable and all variables to which it is synchronized | |
120 | /// @param the variable for which to affect the range |
|
120 | /// @param the variable for which to affect the range | |
121 | /// @param the range to affect |
|
121 | /// @param the range to affect | |
122 |
void updateRanges(VariableId variableId, const |
|
122 | void updateRanges(VariableId variableId, const DateTimeRange &newRange); | |
123 |
|
123 | |||
124 | VariablesPool m_VariablesPool; |
|
124 | VariablesPool m_VariablesPool; | |
125 | SyncGroupsPool m_SyncGroupsPool; |
|
125 | SyncGroupsPool m_SyncGroupsPool; |
@@ -39,11 +39,11 struct CreateOperation : public IFuzzingOperation { | |||||
39 | << "(metadata:" << variableMetadata << ")..."; |
|
39 | << "(metadata:" << variableMetadata << ")..."; | |
40 |
|
40 | |||
41 | auto newVariable |
|
41 | auto newVariable | |
42 |
= variableController.createVariable(variableName, variableMetadata, variableProvider, properties.value(INITIAL_RANGE_PROPERTY).value< |
|
42 | = variableController.createVariable(variableName, variableMetadata, variableProvider, properties.value(INITIAL_RANGE_PROPERTY).value<DateTimeRange>()); | |
43 |
|
43 | |||
44 | // Updates variable's state |
|
44 | // Updates variable's state | |
45 | auto &variableState = fuzzingState.variableState(variableId); |
|
45 | auto &variableState = fuzzingState.variableState(variableId); | |
46 |
variableState.m_Range = properties.value(INITIAL_RANGE_PROPERTY).value< |
|
46 | variableState.m_Range = properties.value(INITIAL_RANGE_PROPERTY).value<DateTimeRange>(); | |
47 | std::swap(variableState.m_Variable, newVariable); |
|
47 | std::swap(variableState.m_Variable, newVariable); | |
48 | } |
|
48 | } | |
49 | }; |
|
49 | }; | |
@@ -94,7 +94,7 struct DeleteOperation : public IFuzzingOperation { | |||||
94 | */ |
|
94 | */ | |
95 | struct MoveOperation : public IFuzzingOperation { |
|
95 | struct MoveOperation : public IFuzzingOperation { | |
96 | using MoveFunction = std::function<double(double currentValue, double maxValue)>; |
|
96 | using MoveFunction = std::function<double(double currentValue, double maxValue)>; | |
97 |
using MaxMoveFunction = std::function<double(const |
|
97 | using MaxMoveFunction = std::function<double(const DateTimeRange &range, const DateTimeRange &maxRange)>; | |
98 |
|
98 | |||
99 | explicit MoveOperation(MoveFunction rangeStartMoveFun, MoveFunction rangeEndMoveFun, |
|
99 | explicit MoveOperation(MoveFunction rangeStartMoveFun, MoveFunction rangeEndMoveFun, | |
100 | MaxMoveFunction maxMoveFun, |
|
100 | MaxMoveFunction maxMoveFun, | |
@@ -120,7 +120,7 struct MoveOperation : public IFuzzingOperation { | |||||
120 |
|
120 | |||
121 | // Gets the max range defined |
|
121 | // Gets the max range defined | |
122 | auto maxRange = properties.value(MAX_RANGE_PROPERTY, QVariant::fromValue(INVALID_RANGE)) |
|
122 | auto maxRange = properties.value(MAX_RANGE_PROPERTY, QVariant::fromValue(INVALID_RANGE)) | |
123 |
.value< |
|
123 | .value<DateTimeRange>(); | |
124 | auto variableRange = variableState.m_Range; |
|
124 | auto variableRange = variableState.m_Range; | |
125 |
|
125 | |||
126 | if (maxRange == INVALID_RANGE || variableRange.m_TStart < maxRange.m_TStart |
|
126 | if (maxRange == INVALID_RANGE || variableRange.m_TStart < maxRange.m_TStart | |
@@ -137,7 +137,7 struct MoveOperation : public IFuzzingOperation { | |||||
137 |
|
137 | |||
138 | // Moves variable to its new range |
|
138 | // Moves variable to its new range | |
139 | auto isSynchronized = !fuzzingState.syncGroupId(variableId).isNull(); |
|
139 | auto isSynchronized = !fuzzingState.syncGroupId(variableId).isNull(); | |
140 |
auto newVariableRange = |
|
140 | auto newVariableRange = DateTimeRange{m_RangeStartMoveFun(variableRange.m_TStart, delta), | |
141 | m_RangeEndMoveFun(variableRange.m_TEnd, delta)}; |
|
141 | m_RangeEndMoveFun(variableRange.m_TEnd, delta)}; | |
142 | qCInfo(LOG_FuzzingOperations()).noquote() << "Performing" << m_Label << "on" |
|
142 | qCInfo(LOG_FuzzingOperations()).noquote() << "Performing" << m_Label << "on" | |
143 | << variable->name() << "(from" << variableRange |
|
143 | << variable->name() << "(from" << variableRange | |
@@ -228,21 +228,21 std::unique_ptr<IFuzzingOperation> FuzzingOperationFactory::create(FuzzingOperat | |||||
228 | case FuzzingOperationType::PAN_LEFT: |
|
228 | case FuzzingOperationType::PAN_LEFT: | |
229 | return std::make_unique<MoveOperation>( |
|
229 | return std::make_unique<MoveOperation>( | |
230 | std::minus<double>(), std::minus<double>(), |
|
230 | std::minus<double>(), std::minus<double>(), | |
231 |
[](const |
|
231 | [](const DateTimeRange &range, const DateTimeRange &maxRange) { | |
232 | return range.m_TStart - maxRange.m_TStart; |
|
232 | return range.m_TStart - maxRange.m_TStart; | |
233 | }, |
|
233 | }, | |
234 | QStringLiteral("Pan left operation")); |
|
234 | QStringLiteral("Pan left operation")); | |
235 | case FuzzingOperationType::PAN_RIGHT: |
|
235 | case FuzzingOperationType::PAN_RIGHT: | |
236 | return std::make_unique<MoveOperation>( |
|
236 | return std::make_unique<MoveOperation>( | |
237 | std::plus<double>(), std::plus<double>(), |
|
237 | std::plus<double>(), std::plus<double>(), | |
238 |
[](const |
|
238 | [](const DateTimeRange &range, const DateTimeRange &maxRange) { | |
239 | return maxRange.m_TEnd - range.m_TEnd; |
|
239 | return maxRange.m_TEnd - range.m_TEnd; | |
240 | }, |
|
240 | }, | |
241 | QStringLiteral("Pan right operation")); |
|
241 | QStringLiteral("Pan right operation")); | |
242 | case FuzzingOperationType::ZOOM_IN: |
|
242 | case FuzzingOperationType::ZOOM_IN: | |
243 | return std::make_unique<MoveOperation>( |
|
243 | return std::make_unique<MoveOperation>( | |
244 | std::plus<double>(), std::minus<double>(), |
|
244 | std::plus<double>(), std::minus<double>(), | |
245 |
[](const |
|
245 | [](const DateTimeRange &range, const DateTimeRange &maxRange) { | |
246 | Q_UNUSED(maxRange) |
|
246 | Q_UNUSED(maxRange) | |
247 | return range.m_TEnd - (range.m_TStart + range.m_TEnd) / 2.; |
|
247 | return range.m_TEnd - (range.m_TStart + range.m_TEnd) / 2.; | |
248 | }, |
|
248 | }, | |
@@ -250,7 +250,7 std::unique_ptr<IFuzzingOperation> FuzzingOperationFactory::create(FuzzingOperat | |||||
250 | case FuzzingOperationType::ZOOM_OUT: |
|
250 | case FuzzingOperationType::ZOOM_OUT: | |
251 | return std::make_unique<MoveOperation>( |
|
251 | return std::make_unique<MoveOperation>( | |
252 | std::minus<double>(), std::plus<double>(), |
|
252 | std::minus<double>(), std::plus<double>(), | |
253 |
[](const |
|
253 | [](const DateTimeRange &range, const DateTimeRange &maxRange) { | |
254 | return std::min(range.m_TStart - maxRange.m_TStart, |
|
254 | return std::min(range.m_TStart - maxRange.m_TStart, | |
255 | maxRange.m_TEnd - range.m_TEnd); |
|
255 | maxRange.m_TEnd - range.m_TEnd); | |
256 | }, |
|
256 | }, |
@@ -163,8 +163,8 DataValidatorHelper &DataValidatorHelper::instance() | |||||
163 | * @param getVariableRangeFun the function to retrieve the range from the variable |
|
163 | * @param getVariableRangeFun the function to retrieve the range from the variable | |
164 | * @remarks if the variable is null, checks that the expected range is the invalid range |
|
164 | * @remarks if the variable is null, checks that the expected range is the invalid range | |
165 | */ |
|
165 | */ | |
166 |
void validateRange(std::shared_ptr<Variable> variable, const |
|
166 | void validateRange(std::shared_ptr<Variable> variable, const DateTimeRange &expectedRange, | |
167 |
std::function< |
|
167 | std::function<DateTimeRange(const Variable &)> getVariableRangeFun) | |
168 | { |
|
168 | { | |
169 | auto compare = [](const auto &range, const auto &expectedRange, const auto &message) { |
|
169 | auto compare = [](const auto &range, const auto &expectedRange, const auto &message) { | |
170 | if (range == expectedRange) { |
|
170 | if (range == expectedRange) { |
@@ -51,9 +51,10 | |||||
51 | #include <pywrappers_common.h> |
|
51 | #include <pywrappers_common.h> | |
52 | #include <CoreWrappers.h> |
|
52 | #include <CoreWrappers.h> | |
53 |
|
53 | |||
|
54 | #include "PyTestAmdaWrapper.h" | |||
|
55 | ||||
54 |
|
56 | |||
55 | using namespace std::chrono; |
|
57 | using namespace std::chrono; | |
56 | namespace py = pybind11; |
|
|||
57 |
|
58 | |||
58 |
|
59 | |||
59 |
|
60 | |||
@@ -74,7 +75,7 PYBIND11_MODULE(pytestamda, m){ | |||||
74 |
|
75 | |||
75 | py::class_<VariableController>(m, "VariableController") |
|
76 | py::class_<VariableController>(m, "VariableController") | |
76 | .def_static("createVariable",[](const QString &name, |
|
77 | .def_static("createVariable",[](const QString &name, | |
77 |
std::shared_ptr<IDataProvider> provider, const |
|
78 | std::shared_ptr<IDataProvider> provider, const DateTimeRange& range){ | |
78 | return sqpApp->variableController().createVariable(name, {{"dataType", "vector"}, {"xml:id", "c1_b"}}, provider, range); |
|
79 | return sqpApp->variableController().createVariable(name, {{"dataType", "vector"}, {"xml:id", "c1_b"}}, provider, range); | |
79 | }) |
|
80 | }) | |
80 | .def_static("hasPendingDownloads", |
|
81 | .def_static("hasPendingDownloads", | |
@@ -96,7 +97,7 PYBIND11_MODULE(pytestamda, m){ | |||||
96 | [](std::shared_ptr<Variable> variable){ |
|
97 | [](std::shared_ptr<Variable> variable){ | |
97 | sqpApp->variableController().deleteVariable(variable);} |
|
98 | sqpApp->variableController().deleteVariable(variable);} | |
98 | ) |
|
99 | ) | |
99 |
.def_static("update_range",[](std::shared_ptr<Variable> variable, const |
|
100 | .def_static("update_range",[](std::shared_ptr<Variable> variable, const DateTimeRange &range, bool synchronise){ | |
100 | sqpApp->variableController().onRequestDataLoading({variable}, range, synchronise); |
|
101 | sqpApp->variableController().onRequestDataLoading({variable}, range, synchronise); | |
101 | }) |
|
102 | }) | |
102 | .def_static("wait_for_downloads",[](){ |
|
103 | .def_static("wait_for_downloads",[](){ | |
@@ -106,7 +107,7 PYBIND11_MODULE(pytestamda, m){ | |||||
106 | }); |
|
107 | }); | |
107 |
|
108 | |||
108 | py::class_<TimeController>(m,"TimeController") |
|
109 | py::class_<TimeController>(m,"TimeController") | |
109 |
.def_static("setTime", []( |
|
110 | .def_static("setTime", [](DateTimeRange range){sqpApp->timeController().setDateTimeRange(range);}); | |
110 |
|
111 | |||
111 |
|
112 | |||
112 | auto amda_provider = std::make_shared<AmdaProvider>(); |
|
113 | auto amda_provider = std::make_shared<AmdaProvider>(); | |
@@ -123,13 +124,3 PYBIND11_MODULE(pytestamda, m){ | |||||
123 |
|
124 | |||
124 | } |
|
125 | } | |
125 |
|
126 | |||
126 |
|
||||
127 | int pytestamda_test(const char* testScriptPath ) |
|
|||
128 | { |
|
|||
129 | py::scoped_interpreter guard{}; |
|
|||
130 | py::globals()["__file__"] = py::str(testScriptPath); |
|
|||
131 | py::eval_file(testScriptPath); |
|
|||
132 | return 0; |
|
|||
133 | } |
|
|||
134 |
|
||||
135 |
|
@@ -20,11 +20,11 | |||||
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #include <QString> |
|
22 | #include <QString> | |
23 | extern int pytestamda_test(const char* testScriptPath ); |
|
23 | #include "PyTestAmdaWrapper.h" | |
24 |
|
24 | |||
25 | int main(int argc, char** argv) |
|
25 | int main(int argc, char** argv) | |
26 | { |
|
26 | { | |
27 | pytestamda_test(PYTESTAMDA_SCRIPT); |
|
27 | int r = pytestamda_test(PYTESTAMDA_SCRIPT); | |
28 | return 0; |
|
28 | return 0; | |
29 | } |
|
29 | } | |
30 |
|
30 |
@@ -33,7 +33,7 const auto TESTS_RESOURCES_PATH | |||||
33 | const auto OPERATION_DELAY = 10000; |
|
33 | const auto OPERATION_DELAY = 10000; | |
34 |
|
34 | |||
35 | template <typename T> |
|
35 | template <typename T> | |
36 |
bool compareDataSeries(std::shared_ptr<IDataSeries> candidate, |
|
36 | bool compareDataSeries(std::shared_ptr<IDataSeries> candidate, DateTimeRange candidateCacheRange, | |
37 | std::shared_ptr<IDataSeries> reference) |
|
37 | std::shared_ptr<IDataSeries> reference) | |
38 | { |
|
38 | { | |
39 | auto compareLambda = [](const auto &it1, const auto &it2) { |
|
39 | auto compareLambda = [](const auto &it1, const auto &it2) { | |
@@ -75,8 +75,8 void TestAmdaAcquisition::testAcquisition_data() | |||||
75 | // ////////////// // |
|
75 | // ////////////// // | |
76 |
|
76 | |||
77 | QTest::addColumn<QString>("dataFilename"); // File containing expected data of acquisitions |
|
77 | QTest::addColumn<QString>("dataFilename"); // File containing expected data of acquisitions | |
78 |
QTest::addColumn< |
|
78 | QTest::addColumn<DateTimeRange>("initialRange"); // First acquisition | |
79 |
QTest::addColumn<std::vector< |
|
79 | QTest::addColumn<std::vector<DateTimeRange> >("operations"); // Acquisitions to make | |
80 |
|
80 | |||
81 | // ////////// // |
|
81 | // ////////// // | |
82 | // Test cases // |
|
82 | // Test cases // | |
@@ -90,12 +90,12 void TestAmdaAcquisition::testAcquisition_data() | |||||
90 |
|
90 | |||
91 | QTest::newRow("amda") |
|
91 | QTest::newRow("amda") | |
92 | << "AmdaData-2012-01-01-12-00-00_2012-01-03-12-00-00.txt" |
|
92 | << "AmdaData-2012-01-01-12-00-00_2012-01-03-12-00-00.txt" | |
93 |
<< |
|
93 | << DateTimeRange{dateTime(2012, 1, 2, 2, 3, 0), dateTime(2012, 1, 2, 2, 4, 0)} | |
94 |
<< std::vector< |
|
94 | << std::vector<DateTimeRange>{ | |
95 | // 2 : pan (jump) left for two min |
|
95 | // 2 : pan (jump) left for two min | |
96 |
|
|
96 | DateTimeRange{dateTime(2012, 1, 2, 2, 1, 0), dateTime(2012, 1, 2, 2, 2, 0)}, | |
97 | // 3 : pan (jump) right for four min |
|
97 | // 3 : pan (jump) right for four min | |
98 |
|
|
98 | DateTimeRange{dateTime(2012, 1, 2, 2, 5, 0), dateTime(2012, 1, 2, 2, 6, 0)}, | |
99 | // 4 : pan (overlay) right for 30 sec |
|
99 | // 4 : pan (overlay) right for 30 sec | |
100 | /*SqpRange{dateTime(2012, 1, 2, 2, 5, 30), dateTime(2012, 1, 2, 2, 6, 30)}, |
|
100 | /*SqpRange{dateTime(2012, 1, 2, 2, 5, 30), dateTime(2012, 1, 2, 2, 6, 30)}, | |
101 | // 5 : pan (overlay) left for 30 sec |
|
101 | // 5 : pan (overlay) left for 30 sec | |
@@ -118,7 +118,7 void TestAmdaAcquisition::testAcquisition() | |||||
118 | auto results = AmdaResultParser::readTxt(filePath, DataSeriesType::SCALAR); |
|
118 | auto results = AmdaResultParser::readTxt(filePath, DataSeriesType::SCALAR); | |
119 |
|
119 | |||
120 | /// Lambda used to validate a variable at each step |
|
120 | /// Lambda used to validate a variable at each step | |
121 |
auto validateVariable = [results](std::shared_ptr<Variable> variable, const |
|
121 | auto validateVariable = [results](std::shared_ptr<Variable> variable, const DateTimeRange &range) { | |
122 | // Checks that the variable's range has changed |
|
122 | // Checks that the variable's range has changed | |
123 | qInfo() << tr("Compare var range vs range") << variable->range() << range; |
|
123 | qInfo() << tr("Compare var range vs range") << variable->range() << range; | |
124 | QCOMPARE(variable->range(), range); |
|
124 | QCOMPARE(variable->range(), range); | |
@@ -130,7 +130,7 void TestAmdaAcquisition::testAcquisition() | |||||
130 | }; |
|
130 | }; | |
131 |
|
131 | |||
132 | // Creates variable |
|
132 | // Creates variable | |
133 |
QFETCH( |
|
133 | QFETCH(DateTimeRange, initialRange); | |
134 | sqpApp->timeController().setDateTimeRange(initialRange); |
|
134 | sqpApp->timeController().setDateTimeRange(initialRange); | |
135 | auto provider = std::make_shared<AmdaProvider>(); |
|
135 | auto provider = std::make_shared<AmdaProvider>(); | |
136 | auto variable = sqpApp->variableController().createVariable( |
|
136 | auto variable = sqpApp->variableController().createVariable( | |
@@ -140,7 +140,7 void TestAmdaAcquisition::testAcquisition() | |||||
140 | validateVariable(variable, initialRange); |
|
140 | validateVariable(variable, initialRange); | |
141 |
|
141 | |||
142 | // Makes operations on the variable |
|
142 | // Makes operations on the variable | |
143 |
QFETCH(std::vector< |
|
143 | QFETCH(std::vector<DateTimeRange>, operations); | |
144 | for (const auto &operation : operations) { |
|
144 | for (const auto &operation : operations) { | |
145 | // Asks request on the variable and waits during its execution |
|
145 | // Asks request on the variable and waits during its execution | |
146 | sqpApp->variableController().onRequestDataLoading({variable}, operation, false); |
|
146 | sqpApp->variableController().onRequestDataLoading({variable}, operation, false); |
@@ -4,8 +4,11 if not hasattr(sys, 'argv'): | |||||
4 | sys.argv = [''] |
|
4 | sys.argv = [''] | |
5 | current_script_path = os.path.dirname(os.path.realpath(__file__)) |
|
5 | current_script_path = os.path.dirname(os.path.realpath(__file__)) | |
6 | sys.path.append(current_script_path) |
|
6 | sys.path.append(current_script_path) | |
|
7 | ||||
7 | import pytestamda |
|
8 | import pytestamda | |
8 | import pysciqlopcore |
|
9 | import pysciqlopcore | |
|
10 | ||||
|
11 | import sciqlopqt | |||
9 | import amda |
|
12 | import amda | |
10 |
|
13 | |||
11 | import numpy as np |
|
14 | import numpy as np | |
@@ -28,7 +31,7 class FunctionalTests(unittest.TestCase): | |||||
28 | tstart = case[0] |
|
31 | tstart = case[0] | |
29 | tstop = case[1] |
|
32 | tstop = case[1] | |
30 | pytestamda.TimeController.setTime(pysciqlopcore.SqpRange(tstart, tstop)) |
|
33 | pytestamda.TimeController.setTime(pysciqlopcore.SqpRange(tstart, tstop)) | |
31 | variable = pytestamda.VariableController.createVariable("bx_gse",pytestamda.amda_provider()) |
|
34 | variable = pytestamda.VariableController.createVariable("bx_gse",pytestamda.amda_provider(), pysciqlopcore.SqpRange(tstart, tstop)) | |
32 | pytestamda.VariableController.wait_for_downloads() |
|
35 | pytestamda.VariableController.wait_for_downloads() | |
33 | t_ref, x_ref, y_ref, z_ref = amda.generate_data(np.datetime64(tstart), np.datetime64(tstop), 4) |
|
36 | t_ref, x_ref, y_ref, z_ref = amda.generate_data(np.datetime64(tstart), np.datetime64(tstop), 4) | |
34 | self.assertTrue( amda.compare_with_ref(variable,(t_ref, x_ref, y_ref, z_ref) ) ) |
|
37 | self.assertTrue( amda.compare_with_ref(variable,(t_ref, x_ref, y_ref, z_ref) ) ) |
@@ -318,7 +318,7 void TestAmdaFuzzing::testFuzzing_data() | |||||
318 | // Test cases // |
|
318 | // Test cases // | |
319 | // ////////// // |
|
319 | // ////////// // | |
320 |
|
320 | |||
321 |
auto maxRange = |
|
321 | auto maxRange = DateTimeRange::fromDateTime({2017, 1, 1}, {0, 0}, {2017, 1, 5}, {0, 0}); | |
322 | MetadataPool metadataPool{{{"dataType", "vector"}, {"xml:id", "imf"}}}; |
|
322 | MetadataPool metadataPool{{{"dataType", "vector"}, {"xml:id", "imf"}}}; | |
323 |
|
323 | |||
324 | // Note: we don't use auto here as we want to pass std::shared_ptr<IDataProvider> as is in the |
|
324 | // Note: we don't use auto here as we want to pass std::shared_ptr<IDataProvider> as is in the | |
@@ -346,7 +346,7 void TestAmdaFuzzing::testFuzzing() | |||||
346 |
|
346 | |||
347 | // Generates random initial range (bounded to max range) |
|
347 | // Generates random initial range (bounded to max range) | |
348 | auto maxRange = properties.value(MAX_RANGE_PROPERTY, QVariant::fromValue(INVALID_RANGE)) |
|
348 | auto maxRange = properties.value(MAX_RANGE_PROPERTY, QVariant::fromValue(INVALID_RANGE)) | |
349 |
.value< |
|
349 | .value<DateTimeRange>(); | |
350 |
|
350 | |||
351 | QVERIFY(maxRange != INVALID_RANGE); |
|
351 | QVERIFY(maxRange != INVALID_RANGE); | |
352 |
|
352 | |||
@@ -359,7 +359,7 void TestAmdaFuzzing::testFuzzing() | |||||
359 | } |
|
359 | } | |
360 |
|
360 | |||
361 | // Sets initial range on time controller |
|
361 | // Sets initial range on time controller | |
362 |
|
|
362 | DateTimeRange initialRange{initialRangeStart, initialRangeEnd}; | |
363 | qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Setting initial range to" << initialRange << "..."; |
|
363 | qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Setting initial range to" << initialRange << "..."; | |
364 | timeController.setDateTimeRange(initialRange); |
|
364 | timeController.setDateTimeRange(initialRange); | |
365 | properties.insert(INITIAL_RANGE_PROPERTY, QVariant::fromValue(initialRange)); |
|
365 | properties.insert(INITIAL_RANGE_PROPERTY, QVariant::fromValue(initialRange)); |
@@ -27,13 +27,13 public: | |||||
27 |
|
27 | |||
28 |
|
28 | |||
29 | /// Provide data |
|
29 | /// Provide data | |
30 |
std::shared_ptr<IDataSeries> provideDataSeries(const |
|
30 | std::shared_ptr<IDataSeries> provideDataSeries(const DateTimeRange &dataRangeRequested, | |
31 | const QVariantHash &data); |
|
31 | const QVariantHash &data); | |
32 |
|
32 | |||
33 |
|
33 | |||
34 | private: |
|
34 | private: | |
35 | std::shared_ptr<IDataSeries> |
|
35 | std::shared_ptr<IDataSeries> | |
36 |
retrieveData(QUuid acqIdentifier, const |
|
36 | retrieveData(QUuid acqIdentifier, const DateTimeRange &dataRangeRequested, const QVariantHash &data); | |
37 |
|
37 | |||
38 | QHash<QUuid, bool> m_VariableToEnableProvider; |
|
38 | QHash<QUuid, bool> m_VariableToEnableProvider; | |
39 | }; |
|
39 | }; |
@@ -159,7 +159,7 std::shared_ptr<IDataProvider> CosinusProvider::clone() const | |||||
159 | } |
|
159 | } | |
160 |
|
160 | |||
161 | std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid acqIdentifier, |
|
161 | std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid acqIdentifier, | |
162 |
const |
|
162 | const DateTimeRange &dataRangeRequested, | |
163 | const QVariantHash &data) |
|
163 | const QVariantHash &data) | |
164 | { |
|
164 | { | |
165 | // TODO: Add Mutex |
|
165 | // TODO: Add Mutex | |
@@ -279,7 +279,7 void CosinusProvider::requestDataAborting(QUuid acqIdentifier) | |||||
279 | } |
|
279 | } | |
280 | } |
|
280 | } | |
281 |
|
281 | |||
282 |
std::shared_ptr<IDataSeries> CosinusProvider::provideDataSeries(const |
|
282 | std::shared_ptr<IDataSeries> CosinusProvider::provideDataSeries(const DateTimeRange &dataRangeRequested, | |
283 | const QVariantHash &data) |
|
283 | const QVariantHash &data) | |
284 | { |
|
284 | { | |
285 | auto uid = QUuid::createUuid(); |
|
285 | auto uid = QUuid::createUuid(); |
@@ -33,7 +33,7 const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss:zzz"); | |||||
33 | * @return true if the data of the candidate series and the reference series are identical in the |
|
33 | * @return true if the data of the candidate series and the reference series are identical in the | |
34 | * range, false otherwise |
|
34 | * range, false otherwise | |
35 | */ |
|
35 | */ | |
36 |
bool checkDataSeries(std::shared_ptr<IDataSeries> candidate, const |
|
36 | bool checkDataSeries(std::shared_ptr<IDataSeries> candidate, const DateTimeRange &range, | |
37 | std::shared_ptr<IDataSeries> reference) |
|
37 | std::shared_ptr<IDataSeries> reference) | |
38 | { |
|
38 | { | |
39 | if (candidate == nullptr || reference == nullptr) { |
|
39 | if (candidate == nullptr || reference == nullptr) { | |
@@ -76,10 +76,10 void TestCosinusAcquisition::testAcquisition_data() | |||||
76 | // Test structure // |
|
76 | // Test structure // | |
77 | // ////////////// // |
|
77 | // ////////////// // | |
78 |
|
78 | |||
79 |
QTest::addColumn< |
|
79 | QTest::addColumn<DateTimeRange>("referenceRange"); // Range for generating reference series | |
80 |
QTest::addColumn< |
|
80 | QTest::addColumn<DateTimeRange>("initialRange"); // First acquisition | |
81 | QTest::addColumn<int>("operationDelay"); // Acquisitions to make |
|
81 | QTest::addColumn<int>("operationDelay"); // Acquisitions to make | |
82 |
QTest::addColumn<std::vector< |
|
82 | QTest::addColumn<std::vector<DateTimeRange> >("operations"); // Acquisitions to make | |
83 |
|
83 | |||
84 | // ////////// // |
|
84 | // ////////// // | |
85 | // Test cases // |
|
85 | // Test cases // | |
@@ -91,48 +91,48 void TestCosinusAcquisition::testAcquisition_data() | |||||
91 | }; |
|
91 | }; | |
92 |
|
92 | |||
93 | QTest::newRow("cosinus") |
|
93 | QTest::newRow("cosinus") | |
94 |
<< |
|
94 | << DateTimeRange{dateTime(2017, 1, 1, 12, 0, 0), dateTime(2017, 1, 1, 13, 0, 0)} | |
95 |
<< |
|
95 | << DateTimeRange{dateTime(2017, 1, 1, 12, 30, 0), dateTime(2017, 1, 1, 12, 35, 1)} << 250 | |
96 |
<< std::vector< |
|
96 | << std::vector<DateTimeRange>{ | |
97 | // Pan (jump) left |
|
97 | // Pan (jump) left | |
98 |
|
|
98 | DateTimeRange{dateTime(2017, 1, 1, 12, 45, 0), dateTime(2017, 1, 1, 12, 50, 0)}, | |
99 | // Pan (jump) right |
|
99 | // Pan (jump) right | |
100 |
|
|
100 | DateTimeRange{dateTime(2017, 1, 1, 12, 15, 0), dateTime(2017, 1, 1, 12, 20, 0)}, | |
101 | // Pan (overlay) right |
|
101 | // Pan (overlay) right | |
102 |
|
|
102 | DateTimeRange{dateTime(2017, 1, 1, 12, 14, 0), dateTime(2017, 1, 1, 12, 19, 0)}, | |
103 | // Pan (overlay) left |
|
103 | // Pan (overlay) left | |
104 |
|
|
104 | DateTimeRange{dateTime(2017, 1, 1, 12, 15, 0), dateTime(2017, 1, 1, 12, 20, 0)}, | |
105 | // Pan (overlay) left |
|
105 | // Pan (overlay) left | |
106 |
|
|
106 | DateTimeRange{dateTime(2017, 1, 1, 12, 16, 0), dateTime(2017, 1, 1, 12, 21, 0)}, | |
107 | // Zoom in |
|
107 | // Zoom in | |
108 |
|
|
108 | DateTimeRange{dateTime(2017, 1, 1, 12, 17, 30), dateTime(2017, 1, 1, 12, 19, 30)}, | |
109 | // Zoom out |
|
109 | // Zoom out | |
110 |
|
|
110 | DateTimeRange{dateTime(2017, 1, 1, 12, 12, 30), dateTime(2017, 1, 1, 12, 24, 30)}}; | |
111 |
|
111 | |||
112 | QTest::newRow("cosinus_big") |
|
112 | QTest::newRow("cosinus_big") | |
113 |
<< |
|
113 | << DateTimeRange{dateTime(2017, 1, 1, 1, 0, 0), dateTime(2017, 1, 5, 13, 0, 0)} | |
114 |
<< |
|
114 | << DateTimeRange{dateTime(2017, 1, 2, 6, 30, 0), dateTime(2017, 1, 2, 18, 30, 0)} << 5000 | |
115 |
<< std::vector< |
|
115 | << std::vector<DateTimeRange>{ | |
116 | // Pan (jump) left |
|
116 | // Pan (jump) left | |
117 |
|
|
117 | DateTimeRange{dateTime(2017, 1, 1, 13, 30, 0), dateTime(2017, 1, 1, 18, 30, 0)}, | |
118 | // Pan (jump) right |
|
118 | // Pan (jump) right | |
119 |
|
|
119 | DateTimeRange{dateTime(2017, 1, 3, 4, 30, 0), dateTime(2017, 1, 3, 10, 30, 0)}, | |
120 | // Pan (overlay) right |
|
120 | // Pan (overlay) right | |
121 |
|
|
121 | DateTimeRange{dateTime(2017, 1, 3, 8, 30, 0), dateTime(2017, 1, 3, 12, 30, 0)}, | |
122 | // Pan (overlay) left |
|
122 | // Pan (overlay) left | |
123 |
|
|
123 | DateTimeRange{dateTime(2017, 1, 2, 8, 30, 0), dateTime(2017, 1, 3, 10, 30, 0)}, | |
124 | // Pan (overlay) left |
|
124 | // Pan (overlay) left | |
125 |
|
|
125 | DateTimeRange{dateTime(2017, 1, 1, 12, 30, 0), dateTime(2017, 1, 3, 5, 30, 0)}, | |
126 | // Zoom in |
|
126 | // Zoom in | |
127 |
|
|
127 | DateTimeRange{dateTime(2017, 1, 2, 2, 30, 0), dateTime(2017, 1, 2, 8, 30, 0)}, | |
128 | // Zoom out |
|
128 | // Zoom out | |
129 |
|
|
129 | DateTimeRange{dateTime(2017, 1, 1, 14, 30, 0), dateTime(2017, 1, 3, 12, 30, 0)}}; | |
130 | } |
|
130 | } | |
131 |
|
131 | |||
132 | void TestCosinusAcquisition::testAcquisition() |
|
132 | void TestCosinusAcquisition::testAcquisition() | |
133 | { |
|
133 | { | |
134 | // Retrieves reference range |
|
134 | // Retrieves reference range | |
135 |
QFETCH( |
|
135 | QFETCH(DateTimeRange, referenceRange); | |
136 | CosinusProvider referenceProvider{}; |
|
136 | CosinusProvider referenceProvider{}; | |
137 | auto dataSeries = referenceProvider.provideDataSeries( |
|
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.}}); | |
@@ -142,7 +142,7 void TestCosinusAcquisition::testAcquisition() | |||||
142 |
|
142 | |||
143 | /// Lambda used to validate a variable at each step |
|
143 | /// Lambda used to validate a variable at each step | |
144 | auto validateVariable |
|
144 | auto validateVariable | |
145 |
= [dataSeries](std::shared_ptr<Variable> variable, const |
|
145 | = [dataSeries](std::shared_ptr<Variable> variable, const DateTimeRange &range) { | |
146 | // Checks that the variable's range has changed |
|
146 | // Checks that the variable's range has changed | |
147 | qInfo() << "range vs expected range" << variable->range() << range; |
|
147 | qInfo() << "range vs expected range" << variable->range() << range; | |
148 | QCOMPARE(variable->range(), range); |
|
148 | QCOMPARE(variable->range(), range); | |
@@ -152,7 +152,7 void TestCosinusAcquisition::testAcquisition() | |||||
152 | }; |
|
152 | }; | |
153 |
|
153 | |||
154 | // Creates variable |
|
154 | // Creates variable | |
155 |
QFETCH( |
|
155 | QFETCH(DateTimeRange, initialRange); | |
156 | sqpApp->timeController().setDateTimeRange(initialRange); |
|
156 | sqpApp->timeController().setDateTimeRange(initialRange); | |
157 | auto provider = std::make_shared<CosinusProvider>(); |
|
157 | auto provider = std::make_shared<CosinusProvider>(); | |
158 | auto variable = sqpApp->variableController().createVariable( |
|
158 | auto variable = sqpApp->variableController().createVariable( | |
@@ -165,7 +165,7 void TestCosinusAcquisition::testAcquisition() | |||||
165 |
|
165 | |||
166 | QTest::qWait(operationDelay); |
|
166 | QTest::qWait(operationDelay); | |
167 | // Makes operations on the variable |
|
167 | // Makes operations on the variable | |
168 |
QFETCH(std::vector< |
|
168 | QFETCH(std::vector<DateTimeRange>, operations); | |
169 | for (const auto &operation : operations) { |
|
169 | for (const auto &operation : operations) { | |
170 | // Asks request on the variable and waits during its execution |
|
170 | // Asks request on the variable and waits during its execution | |
171 | sqpApp->variableController().onRequestDataLoading({variable}, operation, false); |
|
171 | sqpApp->variableController().onRequestDataLoading({variable}, operation, false); |
General Comments 0
You need to be logged in to leave comments.
Login now