baseexperiment.cpp
111 void BaseExperiment::Notifee::newDatumAvailable(DataDownloader<__BaseExperiment_internal::OperationControl>* downloader)
141 BaseExperiment::BaseExperimentFlowController::BaseExperimentFlowController(BaseExperiment* baseExperiment)
163 , m_actionSignalsMapper(new QSignalMapper(NULL)) // parent is NULL because we take care of deleting this object by ourself
164 , m_workerThread(new WorkerThread(NULL)) // parent is NULL because we take care of deleting this object by ourself
174 , m_dataExchange(2, DataUploaderDownloader<__BaseExperiment_internal::OperationStatus, __BaseExperiment_internal::OperationControl>::OverrideOlder, &m_notifee)
180 // Disabling the check of association before upload because we could never get associated (e.g. when running in batch)
188 connect(m_workerThread.get(), SIGNAL(exceptionDuringOperation(farsa::BaseException*)), this, SLOT(exceptionDuringOperation(farsa::BaseException*)), Qt::BlockingQueuedConnection);
204 // Reading whether we are running in batch mode or not. The parameter is only present if we are running in batch,
235 // This simply gets the list of actions from getActionsForOperations() and then adds them to the menu
243 QList<ParameterSettableUIViewer> BaseExperiment::getViewers(QWidget* parent, Qt::WindowFlags flags)
261 // Executing the next action. The action ID should be a positive number and be in the vector. Moreover
267 // Start operation. Here we also signal that the operation has started/ended. Notice that we are calling a non thread-safe function
268 // 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
270 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationStarted, m_runningOperationID);
272 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationEnded, m_runningOperationID);
290 // 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)
298 if ((m_runningOperationID != -1) && m_operationsVector[m_runningOperationID]->steppable && m_pause) {
307 // 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)
311 if ((m_runningOperationID != -1) && m_operationsVector[m_runningOperationID]->steppable && nowPaused) {
331 DataUploaderDownloader<__BaseExperiment_internal::OperationStatus, __BaseExperiment_internal::OperationControl>* BaseExperiment::getUploaderDownloader()
389 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationPaused, m_runningOperationID);
393 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationResumed, m_runningOperationID);
397 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationResumed, m_runningOperationID);
408 Logger::error(QString("Error while executing the current operation, an exception was thrown. Reason: ") + e->what());
411 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationEnded, m_runningOperationID);
426 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationStarted, m_runningOperationID);
428 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationEnded, m_runningOperationID);
430 // Checking if another operation is running. If it is, prints a warning and doesn't do anything. Here there is
431 // a possible race condition: if an operation is scheduled after the condition in the if is cheked but before
432 // addOperation is executed we could end up with two operations in the queue. However this is the only function
433 // that can schedule operations and this is never run concurrently. Moreover having two operations in the
436 Logger::error("Cannot run the requested operation because another action is currently running; please wait until it finish, or stop it before");
455 void BaseExperiment::uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::Status status, unsigned int operationID, unsigned long newDelay)
470 uploadNewOperationStatus(__BaseExperiment_internal::OperationStatus::OperationStepDelayChanged, m_runningOperationID, m_delay);
void changeInterval(unsigned long interval)
Changes the delay between subsequent steps of a steppable operation.
Definition: baseexperiment.cpp:316
The UI manager.
Definition: baseexperiment.cpp:36
virtual ParameterSettableUI * getUIManager()
Returns an instance of the class handling our viewers.
Definition: baseexperiment.cpp:228
virtual QList< ParameterSettableUIViewer > getViewers(QWidget *parent, Qt::WindowFlags flags)
Returns the list of viewers.
Definition: baseexperiment.cpp:77
The base for classes that have a controllable flow of execution.
Definition: flowcontrol.h:170
virtual void addAdditionalMenus(QMenuBar *menuBar)
Adds additional menus to the menu bar of Total99.
Definition: baseexperiment.cpp:254
QString status()
return a text description of the current status of the component
Definition: component.h:53
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves the actual status of parameters into the ConfigurationParameters object passed.
Definition: baseexperiment.cpp:209
virtual void addAdditionalMenus(QMenuBar *menuBar)
Adds additional menus to the menu bar of Total99.
Definition: baseexperiment.cpp:88
void addOperation(QString name, void(T::*func)(), bool useSeparateThread, bool steppable)
The function that adds the given operation to the list of all operations declared by the experiment...
Definition: baseexperiment.h:1035
Definition: baseexperiment.h:111
The GUI to control a BaseExperiment subclass.
Definition: baseexperimentgui.h:47
unsigned long currentInterval() const
Returns the current delay for steppable operations.
Definition: baseexperiment.cpp:321
The base abstract class for operation wrappers.
Definition: baseexperiment.h:370
void checkAssociationBeforeUpload(bool v)
static void describe(QString type)
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
Definition: baseexperiment.cpp:215
virtual void fillActionsMenu(QMenu *actionsMenu)
Fills the menu "Actions" of Total99.
Definition: baseexperiment.cpp:62
static bool getBool(ConfigurationParameters ¶ms, QString paramPath, bool def=false)
static void error(QString msg)
const QVector< AbstractOperationWrapper * > & getOperations() const
Returns the list of operations.
Definition: baseexperiment.cpp:326
DataUploaderDownloader< __BaseExperiment_internal::OperationStatus, __BaseExperiment_internal::OperationControl > * getUploaderDownloader()
Returns the object to exchange data.
Definition: baseexperiment.cpp:331
bool startObjectParameters(QString groupPath, QString typeName, ParameterSettable *object)
virtual void stopCurrentOperation()
Forces the end of the current operation, if threaded.
Definition: baseexperiment.cpp:342
void setStatus(QString newStatus)
used by subclasses to change the status of the experiment
Definition: component.h:61
static Descriptor addTypeDescription(QString type, QString shortHelp, QString longHelp=QString(""))
void setFlowController(FlowController *flowController)
Sets the flow controller object to use.
Definition: flowcontrol.h:206
virtual void postConfigureInitialization()
This function is called after all linked objects have been configured.
Definition: baseexperiment.cpp:220
The Component is the base (abstract) class for any specific project implementation.
Definition: component.h:45
virtual void fillActionsMenu(QMenu *actionsMenu)
Fills the menu "Actions" of Total99.
Definition: baseexperiment.cpp:233
virtual void configure(ConfigurationParameters ¶ms, QString prefix)
Configures the object using a ConfigurationParameters object.
Definition: baseexperiment.cpp:202
bool batchRunning() const
Returns true if we are running in batch.
Definition: baseexperiment.cpp:367
virtual QList< ParameterSettableUIViewer > getViewers(QWidget *parent, Qt::WindowFlags flags)
Returns the list of viewers.
Definition: baseexperiment.cpp:243
void step()
Performs a single step for the current steppable operation.
Definition: baseexperiment.cpp:294
Definition: baseexperiment.h:75
QList< QAction * > getActionsForOperations(QObject *actionsParent) const
Returns a list of actions, one for each operation declared by the experiment.
Definition: baseexperiment.cpp:347