@@ -0,0 +1,23 | |||
|
1 | #ifndef SCIQLOP_MOCKDEFS_H | |
|
2 | #define SCIQLOP_MOCKDEFS_H | |
|
3 | ||
|
4 | #include "MockPluginGlobal.h" | |
|
5 | ||
|
6 | #include <QString> | |
|
7 | #include <QVariant> | |
|
8 | ||
|
9 | // ////////////// // | |
|
10 | // Mock constants // | |
|
11 | // ////////////// // | |
|
12 | ||
|
13 | // Metadata for cosinus provider // | |
|
14 | ||
|
15 | /// Cosinus frequency (Hz) | |
|
16 | extern SCIQLOP_MOCKPLUGIN_EXPORT const QString COSINUS_FREQUENCY_KEY; | |
|
17 | extern SCIQLOP_MOCKPLUGIN_EXPORT const QVariant COSINUS_FREQUENCY_DEFAULT_VALUE; | |
|
18 | ||
|
19 | /// Cosinus type ("scalar" or "vector") | |
|
20 | extern SCIQLOP_MOCKPLUGIN_EXPORT const QString COSINUS_TYPE_KEY; | |
|
21 | extern SCIQLOP_MOCKPLUGIN_EXPORT const QVariant COSINUS_TYPE_DEFAULT_VALUE; | |
|
22 | ||
|
23 | #endif // SCIQLOP_MOCKDEFS_H |
@@ -0,0 +1,7 | |||
|
1 | #include "MockDefs.h" | |
|
2 | ||
|
3 | const QString COSINUS_FREQUENCY_KEY = QStringLiteral("cosinusFrequency"); | |
|
4 | const QVariant COSINUS_FREQUENCY_DEFAULT_VALUE = 60.; | |
|
5 | ||
|
6 | const QString COSINUS_TYPE_KEY = QStringLiteral("cosinusType"); | |
|
7 | const QVariant COSINUS_TYPE_DEFAULT_VALUE = QStringLiteral("scalar"); |
@@ -1,4 +1,5 | |||
|
1 | 1 | #include "CosinusProvider.h" |
|
2 | #include "MockDefs.h" | |
|
2 | 3 | |
|
3 | 4 | #include <Data/DataProviderParameters.h> |
|
4 | 5 | #include <Data/ScalarSeries.h> |
@@ -24,10 +25,17 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid acqIdentifier, | |||
|
24 | 25 | // TODO: Add Mutex |
|
25 | 26 | auto dataIndex = 0; |
|
26 | 27 | |
|
28 | // Retrieves frequency | |
|
29 | auto freqVariant = data.value(COSINUS_FREQUENCY_KEY, COSINUS_FREQUENCY_DEFAULT_VALUE); | |
|
30 | if (!freqVariant.canConvert<double>()) { | |
|
31 | qCCritical(LOG_CosinusProvider()) << tr("Can't retrieve data: invalid frequency"); | |
|
32 | return nullptr; | |
|
33 | } | |
|
34 | ||
|
27 | 35 | // Gets the timerange from the parameters |
|
28 |
double freq = |
|
|
29 |
double start = std::ceil(dataRangeRequested.m_TStart * freq); |
|
|
30 |
double end = std::floor(dataRangeRequested.m_TEnd * freq); |
|
|
36 | double freq = freqVariant.toDouble(); | |
|
37 | double start = std::ceil(dataRangeRequested.m_TStart * freq); | |
|
38 | double end = std::floor(dataRangeRequested.m_TEnd * freq); | |
|
31 | 39 | |
|
32 | 40 | // We assure that timerange is valid |
|
33 | 41 | if (end < start) { |
@@ -1,5 +1,6 | |||
|
1 | 1 | #include "MockPlugin.h" |
|
2 | 2 | #include "CosinusProvider.h" |
|
3 | #include "MockDefs.h" | |
|
3 | 4 | |
|
4 | 5 | #include <DataSource/DataSourceController.h> |
|
5 | 6 | #include <DataSource/DataSourceItem.h> |
@@ -20,10 +21,11 std::unique_ptr<IDataProvider> createDataProvider() noexcept | |||
|
20 | 21 | return std::make_unique<CosinusProvider>(); |
|
21 | 22 | } |
|
22 | 23 | |
|
23 |
std::unique_ptr<DataSourceItem> createProductItem(const Q |
|
|
24 | std::unique_ptr<DataSourceItem> createProductItem(const QVariantHash &data, | |
|
24 | 25 | const QUuid &dataSourceUid) |
|
25 | 26 | { |
|
26 |
auto result = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, |
|
|
27 | auto result = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, data); | |
|
28 | auto productName = data.value(DataSourceItem::NAME_DATA_KEY).toString(); | |
|
27 | 29 | |
|
28 | 30 | // Add action to load product from DataSourceController |
|
29 | 31 | result->addAction(std::make_unique<DataSourceItemAction>( |
General Comments 0
You need to be logged in to leave comments.
Login now