Auto status change to "Under Review"
@@ -1,61 +1,61 | |||||
1 | #ifndef SCIQLOP_VARIABLEACQUISITIONWORKER_H |
|
1 | #ifndef SCIQLOP_VARIABLEACQUISITIONWORKER_H | |
2 | #define SCIQLOP_VARIABLEACQUISITIONWORKER_H |
|
2 | #define SCIQLOP_VARIABLEACQUISITIONWORKER_H | |
3 |
|
3 | |||
4 | #include "CoreGlobal.h" |
|
4 | #include "CoreGlobal.h" | |
5 |
|
5 | |||
6 | #include <Data/DataProviderParameters.h> |
|
6 | #include <Data/DataProviderParameters.h> | |
7 | #include <QLoggingCategory> |
|
7 | #include <QLoggingCategory> | |
8 | #include <QObject> |
|
8 | #include <QObject> | |
9 | #include <QUuid> |
|
9 | #include <QUuid> | |
10 |
|
10 | |||
11 | #include <Data/AcquisitionDataPacket.h> |
|
11 | #include <Data/AcquisitionDataPacket.h> | |
12 | #include <Data/IDataSeries.h> |
|
12 | #include <Data/IDataSeries.h> | |
13 | #include <Data/SqpRange.h> |
|
13 | #include <Data/SqpRange.h> | |
14 |
|
14 | |||
15 | #include <QLoggingCategory> |
|
15 | #include <QLoggingCategory> | |
16 |
|
16 | |||
17 | #include <Common/spimpl.h> |
|
17 | #include <Common/spimpl.h> | |
18 |
|
18 | |||
19 | Q_DECLARE_LOGGING_CATEGORY(LOG_VariableAcquisitionWorker) |
|
19 | Q_DECLARE_LOGGING_CATEGORY(LOG_VariableAcquisitionWorker) | |
20 |
|
20 | |||
21 | class Variable; |
|
21 | class Variable; | |
22 | class IDataProvider; |
|
22 | class IDataProvider; | |
23 |
|
23 | |||
24 | /// This class aims to handle all acquisition request |
|
24 | /// This class aims to handle all acquisition request | |
25 | class SCIQLOP_CORE_EXPORT VariableAcquisitionWorker : public QObject { |
|
25 | class SCIQLOP_CORE_EXPORT VariableAcquisitionWorker : public QObject { | |
26 | Q_OBJECT |
|
26 | Q_OBJECT | |
27 | public: |
|
27 | public: | |
28 | explicit VariableAcquisitionWorker(QObject *parent = 0); |
|
28 | explicit VariableAcquisitionWorker(QObject *parent = 0); | |
29 | virtual ~VariableAcquisitionWorker(); |
|
29 | virtual ~VariableAcquisitionWorker(); | |
30 |
|
30 | |||
31 |
|
|
31 | QUuid pushVariableRequest(QUuid varRequestId, QUuid vIdentifier, SqpRange rangeRequested, | |
32 | SqpRange cacheRangeRequested, DataProviderParameters parameters, |
|
32 | SqpRange 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); | |
36 |
|
36 | |||
37 | void initialize(); |
|
37 | void initialize(); | |
38 | void finalize(); |
|
38 | void finalize(); | |
39 | signals: |
|
39 | signals: | |
40 | void dataProvided(QUuid vIdentifier, const SqpRange &rangeRequested, |
|
40 | void dataProvided(QUuid vIdentifier, const SqpRange &rangeRequested, | |
41 | const SqpRange &cacheRangeRequested, |
|
41 | const SqpRange &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); | |
45 |
|
45 | |||
46 | public slots: |
|
46 | public slots: | |
47 | void onVariableDataAcquired(QUuid acqIdentifier, std::shared_ptr<IDataSeries> dataSeries, |
|
47 | void onVariableDataAcquired(QUuid acqIdentifier, std::shared_ptr<IDataSeries> dataSeries, | |
48 | SqpRange dataRangeAcquired); |
|
48 | SqpRange dataRangeAcquired); | |
49 | void onVariableRetrieveDataInProgress(QUuid acqIdentifier, double progress); |
|
49 | void onVariableRetrieveDataInProgress(QUuid acqIdentifier, double progress); | |
50 |
|
50 | |||
51 | private slots: |
|
51 | private slots: | |
52 | void onExecuteRequest(QUuid acqIdentifier); |
|
52 | void onExecuteRequest(QUuid acqIdentifier); | |
53 |
|
53 | |||
54 | private: |
|
54 | private: | |
55 | void waitForFinish(); |
|
55 | void waitForFinish(); | |
56 |
|
56 | |||
57 | class VariableAcquisitionWorkerPrivate; |
|
57 | class VariableAcquisitionWorkerPrivate; | |
58 | spimpl::unique_impl_ptr<VariableAcquisitionWorkerPrivate> impl; |
|
58 | spimpl::unique_impl_ptr<VariableAcquisitionWorkerPrivate> impl; | |
59 | }; |
|
59 | }; | |
60 |
|
60 | |||
61 | #endif // SCIQLOP_VARIABLEACQUISITIONWORKER_H |
|
61 | #endif // SCIQLOP_VARIABLEACQUISITIONWORKER_H |
@@ -1,225 +1,238 | |||||
1 | #include "Variable/VariableAcquisitionWorker.h" |
|
1 | #include "Variable/VariableAcquisitionWorker.h" | |
2 |
|
2 | |||
3 | #include "Variable/Variable.h" |
|
3 | #include "Variable/Variable.h" | |
4 |
|
4 | |||
5 | #include <Data/AcquisitionRequest.h> |
|
5 | #include <Data/AcquisitionRequest.h> | |
6 | #include <Data/SqpRange.h> |
|
6 | #include <Data/SqpRange.h> | |
7 |
|
7 | |||
8 | #include <unordered_map> |
|
8 | #include <unordered_map> | |
9 | #include <utility> |
|
9 | #include <utility> | |
10 |
|
10 | |||
11 | #include <QMutex> |
|
11 | #include <QMutex> | |
12 | #include <QReadWriteLock> |
|
12 | #include <QReadWriteLock> | |
13 | #include <QThread> |
|
13 | #include <QThread> | |
14 |
|
14 | |||
15 | Q_LOGGING_CATEGORY(LOG_VariableAcquisitionWorker, "VariableAcquisitionWorker") |
|
15 | Q_LOGGING_CATEGORY(LOG_VariableAcquisitionWorker, "VariableAcquisitionWorker") | |
16 |
|
16 | |||
17 | struct VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate { |
|
17 | struct VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate { | |
18 |
|
18 | |||
19 | explicit VariableAcquisitionWorkerPrivate() : m_Lock{QReadWriteLock::Recursive} {} |
|
19 | explicit VariableAcquisitionWorkerPrivate() : m_Lock{QReadWriteLock::Recursive} {} | |
20 |
|
20 | |||
21 | void lockRead() { m_Lock.lockForRead(); } |
|
21 | void lockRead() { m_Lock.lockForRead(); } | |
22 | void lockWrite() { m_Lock.lockForWrite(); } |
|
22 | void lockWrite() { m_Lock.lockForWrite(); } | |
23 | void unlock() { m_Lock.unlock(); } |
|
23 | void unlock() { m_Lock.unlock(); } | |
24 |
|
24 | |||
25 | void removeVariableRequest(QUuid vIdentifier); |
|
25 | void removeVariableRequest(QUuid vIdentifier); | |
26 |
|
26 | |||
27 | QMutex m_WorkingMutex; |
|
27 | QMutex m_WorkingMutex; | |
28 | QReadWriteLock m_Lock; |
|
28 | QReadWriteLock m_Lock; | |
29 |
|
29 | |||
30 | std::map<QUuid, QVector<AcquisitionDataPacket> > m_AcqIdentifierToAcqDataPacketVectorMap; |
|
30 | std::map<QUuid, QVector<AcquisitionDataPacket> > m_AcqIdentifierToAcqDataPacketVectorMap; | |
31 | std::map<QUuid, AcquisitionRequest> m_AcqIdentifierToAcqRequestMap; |
|
31 | std::map<QUuid, AcquisitionRequest> m_AcqIdentifierToAcqRequestMap; | |
32 | std::map<QUuid, std::pair<QUuid, QUuid> > m_VIdentifierToCurrrentAcqIdNextIdPairMap; |
|
32 | std::map<QUuid, std::pair<QUuid, QUuid> > m_VIdentifierToCurrrentAcqIdNextIdPairMap; | |
33 | }; |
|
33 | }; | |
34 |
|
34 | |||
35 |
|
35 | |||
36 | VariableAcquisitionWorker::VariableAcquisitionWorker(QObject *parent) |
|
36 | VariableAcquisitionWorker::VariableAcquisitionWorker(QObject *parent) | |
37 | : QObject{parent}, impl{spimpl::make_unique_impl<VariableAcquisitionWorkerPrivate>()} |
|
37 | : QObject{parent}, impl{spimpl::make_unique_impl<VariableAcquisitionWorkerPrivate>()} | |
38 | { |
|
38 | { | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | VariableAcquisitionWorker::~VariableAcquisitionWorker() |
|
41 | VariableAcquisitionWorker::~VariableAcquisitionWorker() | |
42 | { |
|
42 | { | |
43 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("VariableAcquisitionWorker destruction") |
|
43 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("VariableAcquisitionWorker destruction") | |
44 | << QThread::currentThread(); |
|
44 | << QThread::currentThread(); | |
45 | this->waitForFinish(); |
|
45 | this->waitForFinish(); | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 |
|
48 | |||
49 |
|
|
49 | QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid vIdentifier, | |
50 |
SqpRange |
|
50 | SqpRange rangeRequested, | |
51 |
|
|
51 | SqpRange cacheRangeRequested, | |
52 |
|
|
52 | DataProviderParameters parameters, | |
|
53 | std::shared_ptr<IDataProvider> provider) | |||
53 | { |
|
54 | { | |
54 | qCInfo(LOG_VariableAcquisitionWorker()) |
|
55 | qCInfo(LOG_VariableAcquisitionWorker()) | |
55 | << tr("TORM VariableAcquisitionWorker::pushVariableRequest ") << cacheRangeRequested; |
|
56 | << tr("TORM VariableAcquisitionWorker::pushVariableRequest ") << cacheRangeRequested; | |
|
57 | auto varRequestIdCanceled = QUuid(); | |||
56 |
|
58 | |||
57 | // Request creation |
|
59 | // Request creation | |
58 | auto acqRequest = AcquisitionRequest{}; |
|
60 | auto acqRequest = AcquisitionRequest{}; | |
|
61 | acqRequest.m_VarRequestId = varRequestId; | |||
59 | acqRequest.m_vIdentifier = vIdentifier; |
|
62 | acqRequest.m_vIdentifier = vIdentifier; | |
60 | acqRequest.m_DataProviderParameters = parameters; |
|
63 | acqRequest.m_DataProviderParameters = parameters; | |
61 | acqRequest.m_RangeRequested = rangeRequested; |
|
64 | acqRequest.m_RangeRequested = rangeRequested; | |
62 | acqRequest.m_CacheRangeRequested = cacheRangeRequested; |
|
65 | acqRequest.m_CacheRangeRequested = cacheRangeRequested; | |
63 | acqRequest.m_Size = parameters.m_Times.size(); |
|
66 | acqRequest.m_Size = parameters.m_Times.size(); | |
64 | acqRequest.m_Provider = provider; |
|
67 | acqRequest.m_Provider = provider; | |
65 |
|
68 | |||
|
69 | ||||
66 | // Register request |
|
70 | // Register request | |
67 | impl->lockWrite(); |
|
71 | impl->lockWrite(); | |
68 | impl->m_AcqIdentifierToAcqRequestMap.insert( |
|
72 | impl->m_AcqIdentifierToAcqRequestMap.insert( | |
69 | std::make_pair(acqRequest.m_AcqIdentifier, acqRequest)); |
|
73 | std::make_pair(acqRequest.m_AcqIdentifier, acqRequest)); | |
70 |
|
74 | |||
71 | auto it = impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(vIdentifier); |
|
75 | auto it = impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(vIdentifier); | |
72 | if (it != impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) { |
|
76 | if (it != impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) { | |
73 | // A current request already exists, we can replace the next one |
|
77 | // A current request already exists, we can replace the next one | |
|
78 | auto nextAcqId = it->second.second; | |||
|
79 | auto acqIdentifierToAcqRequestMapIt = impl->m_AcqIdentifierToAcqRequestMap.find(nextAcqId); | |||
|
80 | if (acqIdentifierToAcqRequestMapIt != impl->m_AcqIdentifierToAcqRequestMap.cend()) { | |||
|
81 | auto request = acqIdentifierToAcqRequestMapIt->second; | |||
|
82 | varRequestIdCanceled = request.m_VarRequestId; | |||
|
83 | } | |||
|
84 | ||||
74 | it->second.second = acqRequest.m_AcqIdentifier; |
|
85 | it->second.second = acqRequest.m_AcqIdentifier; | |
75 | impl->unlock(); |
|
86 | impl->unlock(); | |
76 | } |
|
87 | } | |
77 | else { |
|
88 | else { | |
78 | // First request for the variable, it must be stored and executed |
|
89 | // First request for the variable, it must be stored and executed | |
79 | impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.insert( |
|
90 | impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.insert( | |
80 | std::make_pair(vIdentifier, std::make_pair(acqRequest.m_AcqIdentifier, QUuid()))); |
|
91 | std::make_pair(vIdentifier, std::make_pair(acqRequest.m_AcqIdentifier, QUuid()))); | |
81 | impl->unlock(); |
|
92 | impl->unlock(); | |
82 |
|
93 | |||
83 | QMetaObject::invokeMethod(this, "onExecuteRequest", Qt::QueuedConnection, |
|
94 | QMetaObject::invokeMethod(this, "onExecuteRequest", Qt::QueuedConnection, | |
84 | Q_ARG(QUuid, acqRequest.m_AcqIdentifier)); |
|
95 | Q_ARG(QUuid, acqRequest.m_AcqIdentifier)); | |
85 | } |
|
96 | } | |
|
97 | ||||
|
98 | return varRequestIdCanceled; | |||
86 | } |
|
99 | } | |
87 |
|
100 | |||
88 | void VariableAcquisitionWorker::abortProgressRequested(QUuid vIdentifier) |
|
101 | void VariableAcquisitionWorker::abortProgressRequested(QUuid vIdentifier) | |
89 | { |
|
102 | { | |
90 | // TODO |
|
103 | // TODO | |
91 | } |
|
104 | } | |
92 |
|
105 | |||
93 | void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdentifier, |
|
106 | void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdentifier, | |
94 | double progress) |
|
107 | double progress) | |
95 | { |
|
108 | { | |
96 | // TODO |
|
109 | // TODO | |
97 | } |
|
110 | } | |
98 |
|
111 | |||
99 | void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, |
|
112 | void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, | |
100 | std::shared_ptr<IDataSeries> dataSeries, |
|
113 | std::shared_ptr<IDataSeries> dataSeries, | |
101 | SqpRange dataRangeAcquired) |
|
114 | SqpRange dataRangeAcquired) | |
102 | { |
|
115 | { | |
103 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("onVariableDataAcquired on range ") |
|
116 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("onVariableDataAcquired on range ") | |
104 | << acqIdentifier << dataRangeAcquired; |
|
117 | << acqIdentifier << dataRangeAcquired; | |
105 | impl->lockWrite(); |
|
118 | impl->lockWrite(); | |
106 | auto aIdToARit = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); |
|
119 | auto aIdToARit = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); | |
107 | if (aIdToARit != impl->m_AcqIdentifierToAcqRequestMap.cend()) { |
|
120 | if (aIdToARit != impl->m_AcqIdentifierToAcqRequestMap.cend()) { | |
108 | // Store the result |
|
121 | // Store the result | |
109 | auto dataPacket = AcquisitionDataPacket{}; |
|
122 | auto dataPacket = AcquisitionDataPacket{}; | |
110 | dataPacket.m_Range = dataRangeAcquired; |
|
123 | dataPacket.m_Range = dataRangeAcquired; | |
111 | dataPacket.m_DateSeries = dataSeries; |
|
124 | dataPacket.m_DateSeries = dataSeries; | |
112 |
|
125 | |||
113 | auto aIdToADPVit = impl->m_AcqIdentifierToAcqDataPacketVectorMap.find(acqIdentifier); |
|
126 | auto aIdToADPVit = impl->m_AcqIdentifierToAcqDataPacketVectorMap.find(acqIdentifier); | |
114 | if (aIdToADPVit != impl->m_AcqIdentifierToAcqDataPacketVectorMap.cend()) { |
|
127 | if (aIdToADPVit != impl->m_AcqIdentifierToAcqDataPacketVectorMap.cend()) { | |
115 | // A current request result already exists, we can update it |
|
128 | // A current request result already exists, we can update it | |
116 | aIdToADPVit->second.push_back(dataPacket); |
|
129 | aIdToADPVit->second.push_back(dataPacket); | |
117 | } |
|
130 | } | |
118 | else { |
|
131 | else { | |
119 | // First request result for the variable, it must be stored |
|
132 | // First request result for the variable, it must be stored | |
120 | impl->m_AcqIdentifierToAcqDataPacketVectorMap.insert( |
|
133 | impl->m_AcqIdentifierToAcqDataPacketVectorMap.insert( | |
121 | std::make_pair(acqIdentifier, QVector<AcquisitionDataPacket>() << dataPacket)); |
|
134 | std::make_pair(acqIdentifier, QVector<AcquisitionDataPacket>() << dataPacket)); | |
122 | } |
|
135 | } | |
123 |
|
136 | |||
124 |
|
137 | |||
125 | // Decrement the counter of the request |
|
138 | // Decrement the counter of the request | |
126 | auto &acqRequest = aIdToARit->second; |
|
139 | auto &acqRequest = aIdToARit->second; | |
127 | acqRequest.m_Size = acqRequest.m_Size - 1; |
|
140 | acqRequest.m_Size = acqRequest.m_Size - 1; | |
128 |
|
141 | |||
129 | // if the counter is 0, we can return data then run the next request if it exists and |
|
142 | // if the counter is 0, we can return data then run the next request if it exists and | |
130 | // removed the finished request |
|
143 | // removed the finished request | |
131 | if (acqRequest.m_Size == 0) { |
|
144 | if (acqRequest.m_Size == 0) { | |
132 | // Return the data |
|
145 | // Return the data | |
133 | aIdToADPVit = impl->m_AcqIdentifierToAcqDataPacketVectorMap.find(acqIdentifier); |
|
146 | aIdToADPVit = impl->m_AcqIdentifierToAcqDataPacketVectorMap.find(acqIdentifier); | |
134 | if (aIdToADPVit != impl->m_AcqIdentifierToAcqDataPacketVectorMap.cend()) { |
|
147 | if (aIdToADPVit != impl->m_AcqIdentifierToAcqDataPacketVectorMap.cend()) { | |
135 | emit dataProvided(acqRequest.m_vIdentifier, acqRequest.m_RangeRequested, |
|
148 | emit dataProvided(acqRequest.m_vIdentifier, acqRequest.m_RangeRequested, | |
136 | acqRequest.m_CacheRangeRequested, aIdToADPVit->second); |
|
149 | acqRequest.m_CacheRangeRequested, aIdToADPVit->second); | |
137 | } |
|
150 | } | |
138 |
|
151 | |||
139 | // Execute the next one |
|
152 | // Execute the next one | |
140 | auto it |
|
153 | auto it | |
141 | = impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(acqRequest.m_vIdentifier); |
|
154 | = impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(acqRequest.m_vIdentifier); | |
142 |
|
155 | |||
143 | if (it != impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) { |
|
156 | if (it != impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) { | |
144 | if (it->second.second.isNull()) { |
|
157 | if (it->second.second.isNull()) { | |
145 | // There is no next request, we can remove the variable request |
|
158 | // There is no next request, we can remove the variable request | |
146 | impl->removeVariableRequest(acqRequest.m_vIdentifier); |
|
159 | impl->removeVariableRequest(acqRequest.m_vIdentifier); | |
147 | } |
|
160 | } | |
148 | else { |
|
161 | else { | |
149 | auto acqIdentifierToRemove = it->second.first; |
|
162 | auto acqIdentifierToRemove = it->second.first; | |
150 | // Move the next request to the current request |
|
163 | // Move the next request to the current request | |
151 | it->second.first = it->second.second; |
|
164 | it->second.first = it->second.second; | |
152 | it->second.second = QUuid(); |
|
165 | it->second.second = QUuid(); | |
153 | // Remove AcquisitionRequest and results; |
|
166 | // Remove AcquisitionRequest and results; | |
154 | impl->m_AcqIdentifierToAcqRequestMap.erase(acqIdentifierToRemove); |
|
167 | impl->m_AcqIdentifierToAcqRequestMap.erase(acqIdentifierToRemove); | |
155 | impl->m_AcqIdentifierToAcqDataPacketVectorMap.erase(acqIdentifierToRemove); |
|
168 | impl->m_AcqIdentifierToAcqDataPacketVectorMap.erase(acqIdentifierToRemove); | |
156 | // Execute the current request |
|
169 | // Execute the current request | |
157 | QMetaObject::invokeMethod(this, "onExecuteRequest", Qt::QueuedConnection, |
|
170 | QMetaObject::invokeMethod(this, "onExecuteRequest", Qt::QueuedConnection, | |
158 | Q_ARG(QUuid, it->second.first)); |
|
171 | Q_ARG(QUuid, it->second.first)); | |
159 | } |
|
172 | } | |
160 | } |
|
173 | } | |
161 | else { |
|
174 | else { | |
162 | qCCritical(LOG_VariableAcquisitionWorker()) |
|
175 | qCCritical(LOG_VariableAcquisitionWorker()) | |
163 | << tr("Impossible to execute the acquisition on an unfound variable "); |
|
176 | << tr("Impossible to execute the acquisition on an unfound variable "); | |
164 | } |
|
177 | } | |
165 | } |
|
178 | } | |
166 | } |
|
179 | } | |
167 | else { |
|
180 | else { | |
168 | qCCritical(LOG_VariableAcquisitionWorker()) |
|
181 | qCCritical(LOG_VariableAcquisitionWorker()) | |
169 | << tr("Impossible to retrieve AcquisitionRequest for the incoming data"); |
|
182 | << tr("Impossible to retrieve AcquisitionRequest for the incoming data"); | |
170 | } |
|
183 | } | |
171 | impl->unlock(); |
|
184 | impl->unlock(); | |
172 | } |
|
185 | } | |
173 |
|
186 | |||
174 | void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier) |
|
187 | void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier) | |
175 | { |
|
188 | { | |
176 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread(); |
|
189 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread(); | |
177 | impl->lockRead(); |
|
190 | impl->lockRead(); | |
178 | auto it = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); |
|
191 | auto it = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); | |
179 | if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) { |
|
192 | if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) { | |
180 | auto request = it->second; |
|
193 | auto request = it->second; | |
181 | impl->unlock(); |
|
194 | impl->unlock(); | |
182 | request.m_Provider->requestDataLoading(acqIdentifier, request.m_DataProviderParameters); |
|
195 | request.m_Provider->requestDataLoading(acqIdentifier, request.m_DataProviderParameters); | |
183 | } |
|
196 | } | |
184 | else { |
|
197 | else { | |
185 | impl->unlock(); |
|
198 | impl->unlock(); | |
186 | // TODO log no acqIdentifier recognized |
|
199 | // TODO log no acqIdentifier recognized | |
187 | } |
|
200 | } | |
188 | } |
|
201 | } | |
189 |
|
202 | |||
190 | void VariableAcquisitionWorker::initialize() |
|
203 | void VariableAcquisitionWorker::initialize() | |
191 | { |
|
204 | { | |
192 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("VariableAcquisitionWorker init") |
|
205 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("VariableAcquisitionWorker init") | |
193 | << QThread::currentThread(); |
|
206 | << QThread::currentThread(); | |
194 | impl->m_WorkingMutex.lock(); |
|
207 | impl->m_WorkingMutex.lock(); | |
195 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("VariableAcquisitionWorker init END"); |
|
208 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("VariableAcquisitionWorker init END"); | |
196 | } |
|
209 | } | |
197 |
|
210 | |||
198 | void VariableAcquisitionWorker::finalize() |
|
211 | void VariableAcquisitionWorker::finalize() | |
199 | { |
|
212 | { | |
200 | impl->m_WorkingMutex.unlock(); |
|
213 | impl->m_WorkingMutex.unlock(); | |
201 | } |
|
214 | } | |
202 |
|
215 | |||
203 | void VariableAcquisitionWorker::waitForFinish() |
|
216 | void VariableAcquisitionWorker::waitForFinish() | |
204 | { |
|
217 | { | |
205 | QMutexLocker locker{&impl->m_WorkingMutex}; |
|
218 | QMutexLocker locker{&impl->m_WorkingMutex}; | |
206 | } |
|
219 | } | |
207 |
|
220 | |||
208 | void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::removeVariableRequest( |
|
221 | void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::removeVariableRequest( | |
209 | QUuid vIdentifier) |
|
222 | QUuid vIdentifier) | |
210 | { |
|
223 | { | |
211 | lockWrite(); |
|
224 | lockWrite(); | |
212 | auto it = m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(vIdentifier); |
|
225 | auto it = m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(vIdentifier); | |
213 |
|
226 | |||
214 | if (it != m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) { |
|
227 | if (it != m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) { | |
215 | // A current request already exists, we can replace the next one |
|
228 | // A current request already exists, we can replace the next one | |
216 |
|
229 | |||
217 | m_AcqIdentifierToAcqRequestMap.erase(it->second.first); |
|
230 | m_AcqIdentifierToAcqRequestMap.erase(it->second.first); | |
218 | m_AcqIdentifierToAcqDataPacketVectorMap.erase(it->second.first); |
|
231 | m_AcqIdentifierToAcqDataPacketVectorMap.erase(it->second.first); | |
219 |
|
232 | |||
220 | m_AcqIdentifierToAcqRequestMap.erase(it->second.second); |
|
233 | m_AcqIdentifierToAcqRequestMap.erase(it->second.second); | |
221 | m_AcqIdentifierToAcqDataPacketVectorMap.erase(it->second.second); |
|
234 | m_AcqIdentifierToAcqDataPacketVectorMap.erase(it->second.second); | |
222 | } |
|
235 | } | |
223 | m_VIdentifierToCurrrentAcqIdNextIdPairMap.erase(vIdentifier); |
|
236 | m_VIdentifierToCurrrentAcqIdNextIdPairMap.erase(vIdentifier); | |
224 | unlock(); |
|
237 | unlock(); | |
225 | } |
|
238 | } |
General Comments 3
Pull request updated. Auto status change to "Under Review"
Changed commits: * 1 added * 0 removed Changed files: * M core/include/Data/AcquisitionRequest.h * M core/include/Variable/VariableAcquisitionWorker.h * M core/include/Variable/VariableCacheStrategy.h * M core/include/Variable/VariableController.h * M core/src/Variable/VariableAcquisitionWorker.cpp * M core/src/Variable/VariableCacheStrategy.cpp * M core/src/Variable/VariableController.cpp * M gui/src/Visualization/VisualizationZoneWidget.cpp * M plugins/amda/include/AmdaPlugin.h * M plugins/amda/src/AmdaProvider.cpp * M plugins/amda/tests/TestAmdaAcquisition.cpp * M plugins/mockplugin/include/MockPlugin.h * R COPYING * R app/src/MainWindow.cpp * R app/ui/MainWindow.ui * R cmake/sciqlop_package_qt.cmake * R core/include/Common/DateUtils.h * R core/include/Common/MetaTypes.h * R core/include/Common/SortUtils.h * R core/include/CoreGlobal.h * R core/include/Data/AcquisitionDataPacket.h * R core/include/Data/ArrayData.h * R core/include/Data/DataProviderParameters.h * R core/include/Data/DataSeries.h * R core/include/Data/DataSeriesIterator.h * R core/include/Data/IDataProvider.h * R core/include/Data/IDataSeries.h * R core/include/Data/ScalarSeries.h * R core/include/Data/SqpRange.h * R core/include/Data/VectorSeries.h * R core/include/DataSource/DataSourceItemAction.h * R core/include/Network/NetworkController.h * R core/include/Plugin/PluginManager.h * R core/include/Settings/ISqpSettingsBindable.h * R core/include/Settings/SqpSettingsDefs.h * R core/include/Time/TimeController.h * R core/include/Variable/Variable.h * R core/include/Variable/VariableCacheController.h * R core/include/Variable/VariableModel.h * R core/include/Variable/VariableSynchronizationGroup.h * R core/include/Visualization/VisualizationController.h * R core/src/Common/DateUtils.cpp * R core/src/Data/DataSeriesIterator.cpp * R core/src/Data/ScalarSeries.cpp * R core/src/Data/VectorSeries.cpp * R core/src/DataSource/DataSourceItemAction.cpp * R core/src/Network/NetworkController.cpp * R core/src/Plugin/PluginManager.cpp * R core/src/Settings/SqpSettingsDefs.cpp * R core/src/Time/TimeController.cpp * R core/src/Variable/Variable.cpp * R core/src/Variable/VariableCacheController.cpp * R core/src/Variable/VariableModel.cpp * R core/src/Variable/VariableSynchronizationGroup.cpp * R core/src/Visualization/VisualizationController.cpp * R core/tests/Data/TestDataSeries.cpp * R core/tests/Data/TestOneDimArrayData.cpp * R core/tests/Data/TestTwoDimArrayData.cpp * R core/tests/Variable/TestVariable.cpp * R core/tests/Variable/TestVariableCacheController.cpp * R gui/include/Common/ColorUtils.h * R gui/include/DataSource/DataSourceTreeWidgetHelper.h * R gui/include/DataSource/DataSourceTreeWidgetItem.h * R gui/include/DataSource/DataSourceWidget.h * R gui/include/Settings/SqpSettingsDialog.h * R gui/include/Settings/SqpSettingsGeneralWidget.h * R gui/include/SidePane/SqpSidePane.h * R gui/include/TimeWidget/TimeWidget.h * R gui/include/Variable/VariableInspectorWidget.h * R gui/include/Variable/VariableMenuHeaderWidget.h * R gui/include/Visualization/IVariableContainer.h * R gui/include/Visualization/IVisualizationWidget.h * R gui/include/Visualization/IVisualizationWidgetVisitor.h * R gui/include/Visualization/VisualizationDefs.h * R gui/include/Visualization/VisualizationGraphHelper.h * R gui/include/Visualization/VisualizationGraphRenderingDelegate.h * R gui/include/Visualization/VisualizationGraphWidget.h * R gui/include/Visualization/VisualizationTabWidget.h * R gui/include/Visualization/VisualizationWidget.h * R gui/include/Visualization/VisualizationZoneWidget.h * R gui/include/Visualization/operations/GenerateVariableMenuOperation.h * R gui/include/Visualization/operations/MenuBuilder.h * R gui/include/Visualization/operations/RemoveVariableOperation.h * R gui/include/Visualization/operations/RescaleAxeOperation.h * R gui/include/Visualization/qcustomplot.h * R gui/resources/icones/dataSourceComponent.png * R gui/resources/icones/dataSourceNode.png * R gui/resources/icones/dataSourceProduct.png * R gui/resources/icones/dataSourceRoot.png * R gui/resources/icones/delete.png * R gui/resources/icones/next.png * R gui/resources/icones/openInspector.png * R gui/resources/icones/plot.png * R gui/resources/icones/previous.png * R gui/resources/icones/sciqlop2PNG_1024.png * R gui/resources/icones/unplot.png * R gui/resources/sqpguiresources.qrc * R gui/src/Common/ColorUtils.cpp * R gui/src/DataSource/DataSourceTreeWidgetHelper.cpp * R gui/src/DataSource/DataSourceTreeWidgetItem.cpp * R gui/src/DataSource/DataSourceWidget.cpp * R gui/src/Settings/SqpSettingsDialog.cpp * R gui/src/Settings/SqpSettingsGeneralWidget.cpp * R gui/src/SidePane/SqpSidePane.cpp * R gui/src/TimeWidget/TimeWidget.cpp * R gui/src/Variable/VariableInspectorWidget.cpp * R gui/src/Variable/VariableMenuHeaderWidget.cpp * R gui/src/Visualization/VisualizationGraphHelper.cpp * R gui/src/Visualization/VisualizationGraphRenderingDelegate.cpp * R gui/src/Visualization/VisualizationGraphWidget.cpp * R gui/src/Visualization/VisualizationTabWidget.cpp * R gui/src/Visualization/VisualizationWidget.cpp * R gui/src/Visualization/operations/GenerateVariableMenuOperation.cpp * R gui/src/Visualization/operations/MenuBuilder.cpp * R gui/src/Visualization/operations/RemoveVariableOperation.cpp * R gui/src/Visualization/operations/RescaleAxeOperation.cpp * R gui/src/Visualization/qcustomplot.cpp * R gui/ui/DataSource/DataSourceWidget.ui * R gui/ui/Settings/SqpSettingsDialog.ui * R gui/ui/Settings/SqpSettingsGeneralWidget.ui * R gui/ui/SidePane/SqpSidePane.ui * R gui/ui/TimeWidget/TimeWidget.ui * R gui/ui/Variable/VariableInspectorWidget.ui * R gui/ui/Variable/VariableMenuHeaderWidget.ui * R gui/ui/Visualization/VisualizationGraphWidget.ui * R gui/ui/Visualization/VisualizationTabWidget.ui * R gui/ui/Visualization/VisualizationWidget.ui * R gui/ui/Visualization/VisualizationZoneWidget.ui * R gui/vera-exclusions/exclusions.txt * R plugin/CMakeLists.txt * R plugin/cmake/Findsciqlop-plugin.cmake * R plugin/include/Plugin/IPlugin.h * R plugins/amda/CMakeLists.txt * R plugins/amda/cmake/Findsciqlop-amda.cmake * R plugins/amda/include/AmdaDefs.h * R plugins/amda/include/AmdaGlobal.h * R plugins/amda/include/AmdaParser.h * R plugins/amda/include/AmdaProvider.h * R plugins/amda/include/AmdaResultParser.h * R plugins/amda/resources/amda.json * R plugins/amda/resources/amdaresources.qrc * R plugins/amda/resources/samples/AmdaSample.json * R plugins/amda/resources/samples/AmdaSampleV2.json * R plugins/amda/src/AmdaDefs.cpp * R plugins/amda/src/AmdaParser.cpp * R plugins/amda/src/AmdaPlugin.cpp * R plugins/amda/src/AmdaResultParser.cpp * R plugins/amda/tests-resources/TestAmdaAcquisition/AmdaData-2012-01-01-12-00-00_2012-01-03-12-00-00.txt * R plugins/amda/tests-resources/TestAmdaParser/TwoRootsFile.json * R plugins/amda/tests-resources/TestAmdaParser/ValidFile1.json * R plugins/amda/tests-resources/TestAmdaParser/WrongRootKey.json * R plugins/amda/tests-resources/TestAmdaParser/WrongRootType.json * R plugins/amda/tests-resources/TestAmdaResultParser/FileNotFound.txt * R plugins/amda/tests-resources/TestAmdaResultParser/NaNValue.txt * R plugins/amda/tests-resources/TestAmdaResultParser/NaNX.txt * R plugins/amda/tests-resources/TestAmdaResultParser/NoUnit.txt * R plugins/amda/tests-resources/TestAmdaResultParser/TooManyValues.txt * R plugins/amda/tests-resources/TestAmdaResultParser/ValidScalar1.txt * R plugins/amda/tests-resources/TestAmdaResultParser/ValidVector1.txt * R plugins/amda/tests-resources/TestAmdaResultParser/WrongDate.txt * R plugins/amda/tests-resources/TestAmdaResultParser/WrongUnit.txt * R plugins/amda/tests-resources/TestAmdaResultParser/WrongValue.txt * R plugins/amda/tests/TestAmdaParser.cpp * R plugins/amda/tests/TestAmdaResultParser.cpp * R plugins/mockplugin/CMakeLists.txt * R plugins/mockplugin/cmake/Findsciqlop-mockplugin.cmake * R plugins/mockplugin/include/CosinusProvider.h * R plugins/mockplugin/include/MockPluginGlobal.h * R plugins/mockplugin/resources/mockplugin.json * R plugins/mockplugin/src/CosinusProvider.cpp * R plugins/mockplugin/src/MockPlugin.cpp * R README.md * R app/CMakeLists.txt * R app/include/MainWindow.h * R app/src/Main.cpp * R app/vera-exclusions/exclusions.txt * R cmake/sciqlop.cmake * R cmake/sciqlop_applications.cmake * R cmake/sciqlop_package.cmake * R cmake/sciqlop_params.cmake * R core/CMakeLists.txt * R core/include/Common/spimpl.h * R core/include/DataSource/DataSourceController.h * R core/include/DataSource/DataSourceItem.h * R core/src/DataSource/DataSourceController.cpp * R core/src/DataSource/DataSourceItem.cpp * R core/tests/DataSource/TestDataSourceController.cpp * R core/vera-exclusions/exclusions.txt * R formatting/cmake/use_clangformat.cmake * R formatting/vera-exclusions/exclusions.txt * R gui/CMakeLists.txt * R gui/include/SqpApplication.h * R gui/src/SqpApplication.cpp * R LICENSE * R app/src/mainwindow.cpp * R app/src/mainwindow.ui
Status change > Approved
You need to be logged in to leave comments.
Login now