baseexperiment.cpp
111 void BaseExperiment::Notifee::newDatumAvailable(DataDownloader<__BaseExperiment_internal::OperationControl>* downloader)
146 m_actionSignalsMapper(new QSignalMapper(NULL)), // parent is NULL because we take care of deleting this object by ourself
147 m_workerThread(new WorkerThread(NULL)), // parent is NULL because we take care of deleting this object by ourself
157 m_dataExchange(2, DataUploaderDownloader<__BaseExperiment_internal::OperationStatus, __BaseExperiment_internal::OperationControl>::OverrideOlder, &m_notifee, NULL)
159 // Disabling the check of association before upload because we could never get associated (e.g. when running in batch)
167 connect(m_workerThread.get(), SIGNAL(exceptionDuringOperation(farsa::BaseException*)), this, SLOT(exceptionDuringOperation(farsa::BaseException*)), Qt::BlockingQueuedConnection);
183 // Reading whether we are running in batch mode or not. The parameter is only present if we are running in batch,
214 // This simply gets the list of actions from getActionsForOperations() and then adds them to the menu
222 QList<ParameterSettableUIViewer> BaseExperiment::getViewers(QWidget* parent, Qt::WindowFlags flags)
240 // Executing the next action. The action ID should be a positive number and be in the vector. Moreover
246 // Start operation. Here we also signal that the operation has started/ended. Notice that we are calling a non thread-safe function
247 // from a thread different from the one in which this object lives, but it is OK since when we are here we are not calling this
249 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationStarted, m_runningOperationID);
251 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationEnded, m_runningOperationID);
269 // This is made this way so that m_pause is modified even if nothing is running (to be able to decide how the simulation starts)
277 if ((m_runningOperationID != -1) && m_operationsVector[m_runningOperationID]->steppable && m_pause) {
286 // This is made this way so that m_pause is modified even if nothing is running (to be able to decide how the simulation starts)
290 if ((m_runningOperationID != -1) && m_operationsVector[m_runningOperationID]->steppable && nowPaused) {
310 DataUploaderDownloader<__BaseExperiment_internal::OperationStatus, __BaseExperiment_internal::OperationControl>* BaseExperiment::getUploaderDownloader()
368 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationPaused, m_runningOperationID);
372 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationResumed, m_runningOperationID);
376 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationResumed, m_runningOperationID);
387 Logger::error(QString("Error while executing the current operation, an exception was thrown. Reason: ") + e->what());
390 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationEnded, m_runningOperationID);
405 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationStarted, m_runningOperationID);
407 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationEnded, m_runningOperationID);
409 // Checking if another operation is running. If it is, prints a warning and doesn't do anything. Here there is
410 // a possible race condition: if an operation is scheduled after the condition in the if is cheked but before
411 // addOperation is executed we could end up with two operations in the queue. However this is the only function
412 // that can schedule operations and this is never run concurrently. Moreover having two operations in the
415 Logger::error("Cannot run the requested operation because another action is currently running; please wait until it finish, or stop it before");
434 void BaseExperiment::uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::Status status, unsigned int operationID, unsigned long newDelay)
449 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationStepDelayChanged, m_runningOperationID, m_delay);