#include <ThreadManager.h>
Inheritance diagram for ThreadManager:
Public Slots | |
void | checkQuery (int px_ID, int currentLayerIndex, bool newRequest=true) |
Switch and control the access to pxQueryID and layerQueryPos members. | |
void | computeQuery (int px_ID, int currentLayerIndex) |
Compute the pixel query and return it to the GUI (with a signal). | |
void | retrieveScenarioNameFromGUI (const QString &scenarioName_h) |
Signals | |
void | upgradeLogArea (const QString &logMessage) |
void | upgradeMainSBLabelToGui (const QString &logMessage) |
void | upgradeYearSBLabelToGui (const QString &logMessage) |
void | addLayerToGui (QString layerName, QString layerLabel) |
void | updatePixelToGui (QString layerName_h, int x_h, int y_h, QColor color) |
void | updateImageToGui (QString layerName_h, QImage image_h) |
void | setOutputDirNameToGui (string outputDirname_h) |
void | setGUIUnsavedStatus (bool status_h) |
void | setGUIMapDimension (int x_h, int y_h) |
void | treeViewerItemChangeValueToGui (string itemID, string newValue) |
void | treeViewerItemRemoveToGui (string itemID) |
void | treeViewerAddItemToGui (string text, string itemID, string parentID) |
void | fitInWindowToGui () |
void | queryRequestOnPx (int px_ID, int currentLayerIndex) |
void | publishQueryResults (const QString &results) |
void | activateTab (int pos_h) |
void | resetGUIForNewSimulation () |
void | sendScenarioOptionsToGUI (const QVector< QString > &scenarios_h) |
Public Member Functions | |
ThreadManager () | |
void | setMessage (const QString &message) |
void | stop () |
void | deleteDeadOldPointers () |
Useful for several model running without leaving the GUI. | |
void | pauseOrResume () |
void | pause () |
void | resume () |
void | refreshGUI () |
void | msgOut (const int msgCode_h, const string message_h) |
void | addLayer (string layerName_h, string layerLabel_h) |
void | updatePixel (string layerName_h, int x_h, int y_h, QColor color) |
void | updateImage (string layerName_h, const QImage &image_h) |
void | upgradeMainSBLabel (const string message_h) |
void | upgradeYearSBLabel (int year) |
string | getBaseDirectory () |
string | getInputFileName () |
string | getScenarioName () |
void | setOutputDirName (string outputDirname_h) |
void | setRDPointer (RegData *RD_h) |
the regional data object.. | |
void | setGISPointer (Gis *GIS_h) |
GIS information and methods.. | |
void | setSAMPointer (SuperAgentManager *SAM_h) |
the agent super manager, will deal with all the manager objects.. | |
void | setINITPointer (Init *INIT_h) |
the Init object, it schedule the pre-simulation phase.. | |
void | setSCDPointer (Scheduler *SCD_h) |
the scheduler object. It manage the simulation loops.. | |
void | setDOPointer (Output *DO_h) |
manage the printing of data needed for scenario-analisys. The "message output" (needed to see "what is it happening?" are instead simply printed with msgOut().. | |
void | setInputFileName (QString inputFileName_h) |
void | treeViewerAddManager (string name) |
void | treeViewerAddAgent (int uniqueID) |
void | treeViewerAddManagerProperty (string managerName, string propertyName) |
void | treeViewerAddAgentProperty (int uniqueID, string propertyName) |
void | treeViewerManagerPropertyChangeValue (string managerName, string propertyName, string newValue) |
void | treeViewerAgentPropertyChangeValue (int uniqueID, string propertyName, string newValue) |
void | treeViewerRemoveManager (string name) |
void | treeViewerRemoveAgent (int uniqueID) |
void | treeViewerChangeGeneralPropertyValue (string propertyName, string newValue) |
void | fitInWindow () |
void | runFromConsole (QString inputFileName_h, QString scenarioName_h) |
Re-draw the map making it to fit (with the right proportions) to the widget. | |
bool | usingGUI () |
Public Attributes | |
RegData * | RD |
the regional data object | |
Gis * | GIS |
GIS information and methods. | |
SuperAgentManager * | SAM |
the agent super manager, will deal with all the manager objects | |
Init * | INIT |
the Init object (pre-simulation scheduler) | |
Scheduler * | SCD |
the scheduler object (simulation-loops scheduler) | |
Output * | DO |
data output | |
Protected Member Functions | |
void | run () |
Private Attributes | |
QString | messageStr |
volatile bool | stopped |
volatile bool | running |
QString | inputFileName |
QString | baseDirectory |
QString | scenarioName |
volatile int | pxQueryID |
volatile int | layerQueryPos |
QMutex | mutex |
bool | GUI |
ThreadManager is responsable for the actions on the main thread (run/pause/resume/stop) and to speack with the GUI using the signal/slot tecniques.
Definition at line 54 of file ThreadManager.h.
ThreadManager | ( | ) |
Definition at line 33 of file ThreadManager.cpp.
void setMessage | ( | const QString & | message | ) |
Definition at line 55 of file ThreadManager.cpp.
void stop | ( | ) |
Definition at line 161 of file ThreadManager.cpp.
Referenced by MainWindow::closeEvent(), MainWindow::okToContinue(), and MainWindow::stopModelMainThread().
Here is the caller graph for this function:
void deleteDeadOldPointers | ( | ) |
Useful for several model running without leaving the GUI.
Delete the pointers (e.g. GIS) eventually remained from a previous run.
This function is called at the START of a new simulation, and it will check if model pointers (e.g. GIS) exist , and if so it will delete them.
This is useful when we keep the MainWindow open but we run the model for a second time.
Why we don't delete them at the end of a simulation, instead of deleting them on a new run? That's because we want let the user to interface with the model even when this is ended, w.g. for query the map.
Definition at line 150 of file ThreadManager.cpp.
Referenced by run().
Here is the caller graph for this function:
void pauseOrResume | ( | ) |
Definition at line 167 of file ThreadManager.cpp.
Referenced by MainWindow::pauseOrResumeModelMainThread().
void pause | ( | ) |
Definition at line 183 of file ThreadManager.cpp.
void resume | ( | ) |
void refreshGUI | ( | ) |
Definition at line 210 of file ThreadManager.cpp.
Referenced by BaseRegmas::refreshGUI(), and run().
Here is the caller graph for this function:
void msgOut | ( | const int | msgCode_h, | |
const string | message_h | |||
) |
Definition at line 225 of file ThreadManager.cpp.
Referenced by BaseRegmas::msgOut2(), and retrieveScenarioNameFromGUI().
Here is the caller graph for this function:
void addLayer | ( | string | layerName_h, | |
string | layerLabel_h | |||
) |
Definition at line 239 of file ThreadManager.cpp.
Referenced by Gis::addLayer().
Here is the caller graph for this function:
void updatePixel | ( | string | layerName_h, | |
int | x_h, | |||
int | y_h, | |||
QColor | color | |||
) |
Definition at line 246 of file ThreadManager.cpp.
void updateImage | ( | string | layerName_h, | |
const QImage & | image_h | |||
) |
Definition at line 251 of file ThreadManager.cpp.
Referenced by Gis::loadLayersDataFromFile(), and Gis::updateImage().
Here is the caller graph for this function:
void upgradeMainSBLabel | ( | const string | message_h | ) |
Definition at line 256 of file ThreadManager.cpp.
Referenced by Scheduler::run().
Here is the caller graph for this function:
void upgradeYearSBLabel | ( | int | year | ) |
Definition at line 261 of file ThreadManager.cpp.
Referenced by Scheduler::run().
Here is the caller graph for this function:
string getBaseDirectory | ( | ) | [inline] |
Definition at line 81 of file ThreadManager.h.
Referenced by Gis::initLayers(), RegData::loadInput(), and MainProgram::MainProgram().
Here is the caller graph for this function:
string getInputFileName | ( | ) | [inline] |
Definition at line 82 of file ThreadManager.h.
Referenced by RegData::loadInput().
Here is the caller graph for this function:
string getScenarioName | ( | ) | [inline] |
Definition at line 83 of file ThreadManager.h.
Referenced by RegData::getScenarioIndex(), Output::initOutputAggregatedData(), Output::initOutputDetailedData(), Output::initOutputLeavingAgents(), Output::initOutputMaps(), Layers::print(), Output::printAggregatedData(), Layers::printBinMap(), Output::printDetailedData(), Output::printLeavingAgent(), RegData::setDefaultSettings(), RegData::setScenarioActivities(), and RegData::setScenarioSettings().
Here is the caller graph for this function:
void setOutputDirName | ( | string | outputDirname_h | ) |
Definition at line 234 of file ThreadManager.cpp.
Referenced by RegData::setOutputDirectory().
Here is the caller graph for this function:
void setRDPointer | ( | RegData * | RD_h | ) | [inline] |
the regional data object..
Definition at line 87 of file ThreadManager.h.
Referenced by MainProgram::MainProgram().
Here is the caller graph for this function:
void setGISPointer | ( | Gis * | GIS_h | ) | [inline] |
GIS information and methods..
Definition at line 89 of file ThreadManager.h.
Referenced by MainProgram::run().
Here is the caller graph for this function:
void setSAMPointer | ( | SuperAgentManager * | SAM_h | ) | [inline] |
the agent super manager, will deal with all the manager objects..
Definition at line 91 of file ThreadManager.h.
Referenced by MainProgram::run().
Here is the caller graph for this function:
void setINITPointer | ( | Init * | INIT_h | ) | [inline] |
the Init object, it schedule the pre-simulation phase..
Definition at line 93 of file ThreadManager.h.
Referenced by MainProgram::run().
Here is the caller graph for this function:
void setSCDPointer | ( | Scheduler * | SCD_h | ) | [inline] |
the scheduler object. It manage the simulation loops..
Definition at line 95 of file ThreadManager.h.
Referenced by MainProgram::run().
Here is the caller graph for this function:
void setDOPointer | ( | Output * | DO_h | ) | [inline] |
manage the printing of data needed for scenario-analisys. The "message output" (needed to see "what is it happening?" are instead simply printed with msgOut()..
Definition at line 97 of file ThreadManager.h.
Referenced by MainProgram::run().
Here is the caller graph for this function:
void setInputFileName | ( | QString | inputFileName_h | ) |
Definition at line 136 of file ThreadManager.cpp.
Referenced by MainWindow::MainWindow(), and MainWindow::setCurrentModelFileName().
Here is the caller graph for this function:
void treeViewerAddManager | ( | string | name | ) | [inline] |
Definition at line 104 of file ThreadManager.h.
Referenced by Manager_base::Manager_base().
Here is the caller graph for this function:
void treeViewerAddAgent | ( | int | uniqueID | ) | [inline] |
Definition at line 105 of file ThreadManager.h.
Referenced by Agent_base::Agent_base().
Here is the caller graph for this function:
void treeViewerAddManagerProperty | ( | string | managerName, | |
string | propertyName | |||
) | [inline] |
Definition at line 106 of file ThreadManager.h.
Referenced by Manager_base::Manager_base().
Here is the caller graph for this function:
void treeViewerAddAgentProperty | ( | int | uniqueID, | |
string | propertyName | |||
) | [inline] |
Definition at line 108 of file ThreadManager.h.
Referenced by Agent_base::Agent_base(), and Agent_space::Agent_space().
Here is the caller graph for this function:
void treeViewerManagerPropertyChangeValue | ( | string | managerName, | |
string | propertyName, | |||
string | newValue | |||
) | [inline] |
Definition at line 110 of file ThreadManager.h.
Referenced by Manager_farmers::planNext(), Manager_farmers::riseMyAgents(), and Manager_farmers::update().
Here is the caller graph for this function:
void treeViewerAgentPropertyChangeValue | ( | int | uniqueID, | |
string | propertyName, | |||
string | newValue | |||
) | [inline] |
Definition at line 112 of file ThreadManager.h.
Referenced by Manager_farmers::createBehaviours(), Manager_farmers::landAllocation(), Manager_farmers::locateMyAgents(), and Manager_farmers::update().
Here is the caller graph for this function:
void treeViewerRemoveManager | ( | string | name | ) | [inline] |
Definition at line 114 of file ThreadManager.h.
Referenced by Manager_base::~Manager_base().
Here is the caller graph for this function:
void treeViewerRemoveAgent | ( | int | uniqueID | ) | [inline] |
Definition at line 115 of file ThreadManager.h.
Referenced by Agent_base::~Agent_base().
Here is the caller graph for this function:
void treeViewerChangeGeneralPropertyValue | ( | string | propertyName, | |
string | newValue | |||
) | [inline] |
Definition at line 116 of file ThreadManager.h.
Referenced by Scheduler::run(), Init::setInitLevel5(), and Gis::setSpace().
Here is the caller graph for this function:
void fitInWindow | ( | ) | [inline] |
Definition at line 119 of file ThreadManager.h.
Referenced by Gis::setSpace().
Here is the caller graph for this function:
void runFromConsole | ( | QString | inputFileName_h, | |
QString | scenarioName_h | |||
) |
Re-draw the map making it to fit (with the right proportions) to the widget.
Definition at line 114 of file ThreadManager.cpp.
bool usingGUI | ( | ) | [inline] |
Definition at line 121 of file ThreadManager.h.
Referenced by BaseRegmas::msgOut2(), and BaseRegmas::refreshGUI().
Here is the caller graph for this function:
void upgradeLogArea | ( | const QString & | logMessage | ) | [signal] |
Referenced by msgOut(), pauseOrResume(), refreshGUI(), run(), and stop().
void upgradeMainSBLabelToGui | ( | const QString & | logMessage | ) | [signal] |
Referenced by msgOut(), and upgradeMainSBLabel().
void upgradeYearSBLabelToGui | ( | const QString & | logMessage | ) | [signal] |
Referenced by upgradeYearSBLabel().
void addLayerToGui | ( | QString | layerName, | |
QString | layerLabel | |||
) | [signal] |
Referenced by addLayer().
void updatePixelToGui | ( | QString | layerName_h, | |
int | x_h, | |||
int | y_h, | |||
QColor | color | |||
) | [signal] |
Referenced by updatePixel().
void updateImageToGui | ( | QString | layerName_h, | |
QImage | image_h | |||
) | [signal] |
Referenced by updateImage().
void setOutputDirNameToGui | ( | string | outputDirname_h | ) | [signal] |
Referenced by setOutputDirName().
void setGUIUnsavedStatus | ( | bool | status_h | ) | [signal] |
Referenced by pauseOrResume(), and resume().
void setGUIMapDimension | ( | int | x_h, | |
int | y_h | |||
) | [signal] |
void treeViewerItemChangeValueToGui | ( | string | itemID, | |
string | newValue | |||
) | [signal] |
void treeViewerItemRemoveToGui | ( | string | itemID | ) | [signal] |
Referenced by treeViewerRemoveAgent(), and treeViewerRemoveManager().
void treeViewerAddItemToGui | ( | string | text, | |
string | itemID, | |||
string | parentID | |||
) | [signal] |
Referenced by treeViewerAddAgent(), treeViewerAddAgentProperty(), treeViewerAddManager(), and treeViewerAddManagerProperty().
void fitInWindowToGui | ( | ) | [signal] |
Referenced by fitInWindow().
void queryRequestOnPx | ( | int | px_ID, | |
int | currentLayerIndex | |||
) | [signal] |
void publishQueryResults | ( | const QString & | results | ) | [signal] |
Referenced by checkQuery(), and computeQuery().
void activateTab | ( | int | pos_h | ) | [signal] |
Referenced by computeQuery().
void resetGUIForNewSimulation | ( | ) | [signal] |
Referenced by run().
void sendScenarioOptionsToGUI | ( | const QVector< QString > & | scenarios_h | ) | [signal] |
Referenced by run().
void checkQuery | ( | int | px_ID, | |
int | currentLayerIndex, | |||
bool | newRequest = true | |||
) | [slot] |
Switch and control the access to pxQueryID and layerQueryPos members.
checkQuery() is a function that can be called my the GUI trough a signal or from the running thread under refreshGUI(), and it is protected with a mutex.
It's role is to control the status of pxQueryID and layerQueryPos member variables.
If the call come from the GUI, it is a new request and we set them to the new values, otherwise we gonna see if they are just beed changed and if so (layerQueryPos>=0) we call computeQuery().
Definition at line 273 of file ThreadManager.cpp.
Referenced by refreshGUI().
void computeQuery | ( | int | px_ID, | |
int | currentLayerIndex | |||
) | [slot] |
Compute the pixel query and return it to the GUI (with a signal).
Definition at line 293 of file ThreadManager.cpp.
Referenced by checkQuery().
void retrieveScenarioNameFromGUI | ( | const QString & | scenarioName_h | ) | [slot] |
Definition at line 106 of file ThreadManager.cpp.
void run | ( | ) | [protected] |
Definition at line 59 of file ThreadManager.cpp.
the regional data object
Definition at line 61 of file ThreadManager.h.
Referenced by Opt::addPixel(), Agent_base::Agent_base(), Agent_farmer::Agent_farmer(), Agent_space::Agent_space(), Agent_base::answerStats(), Agent_farmer::applyModulation(), Manager_base::assignObjectsToAgents(), Manager_farmers::calibrateLandValues(), Output::collectData(), Agent_farmer::collectProductionEffects(), Manager_farmers::createBehaviours(), Opt::debug(), deleteDeadOldPointers(), Manager_farmers::endInit(), Agent_farmer::filterActivity(), Gis::filterSubRegion(), Gis::getAgrDistCost(), Agent_farmer::getAgrDistCost(), Manager_farmers::getAverageRightsByAct(), RegData::getBoolSetting(), RegData::getBoolVectorSetting(), Agent_base::getCalculatedResourceByName(), Layers::getCategory(), Layers::getColor(), Agent_farmer::getDecoupledPayments(), RegData::getDoubleSetting(), RegData::getDoubleVectorSetting(), RegData::getIntSetting(), RegData::getIntVectorSetting(), RegActivities::getMatrixCoefficients(), ModelObject::getMatrixCoefficients(), RegData::getModelObjectsBySoilType(), Output::getOutputFieldDelimiter(), Agent_base::getResource(), Pixel::getStartingRentalCosts(), RegData::getStringSetting(), RegData::getStringVectorSetting(), Output::getSurveyActivityByName(), Output::getSurveyUnusedLand(), Scheduler::getYear(), Gis::initLayers(), Pixel::initObjects(), Output::initOutputAggregatedData(), Output::initOutputDetailedData(), Output::initOutputLeavingAgents(), Output::initOutputMaps(), Gis::isAgrCode(), Pixel::isAgricultural(), Manager_farmers::landAllocation(), Agent_farmer::leaveActivity(), Gis::loadLayersDataFromFile(), Manager_farmers::locateMyAgents(), MainProgram::MainProgram(), Agent_farmer::offerRentalPrice(), Manager_farmers::prepare(), Layers::print(), Output::printAggregatedData(), Layers::printBinMap(), Output::printDebugMatrices(), Gis::printDebugValues(), Output::printDetailedData(), Output::printLeavingAgent(), Output::printMaps(), Manager_farmers::quotePlot(), Manager_farmers::removeFromModel(), run(), Scheduler::run(), runFromConsole(), Manager_farmers::setAgentMoulds(), RegData::setDefaultSettings(), Init::setInitLevel1(), Pixel::setRandomRenting(), setRDPointer(), RegData::setScenarioSettings(), Gis::setSpace(), Opt::solveGlpk(), Gis::sub2realID(), ThreadManager(), Manager_farmers::update(), Opt::updateActivities(), Opt::updateResourceNames(), Opt::updateResourceValues(), Agent_base::withdraw(), and Agent_base::~Agent_base().
GIS information and methods.
Definition at line 62 of file ThreadManager.h.
Referenced by Manager_farmers::act(), Manager_space::assignSpatialObjectsToAgents(), Output::collectData(), Agent_farmer::collectProductionEffects(), computeQuery(), Layers::countMyPixels(), deleteDeadOldPointers(), Agent_farmer::filterActivity(), Agent_space::getDistance(), Pixel::getDoubleValue(), Pixel::getPixelsAtDistLevel(), Agent_farmer::getUAA(), Output::initOutputMaps(), Manager_farmers::landAllocation(), Manager_farmers::locateMyAgents(), Layers::print(), Output::printAggregatedData(), Layers::printBinMap(), Output::printDetailedData(), Output::printMaps(), Manager_farmers::quotePlot(), Layers::randomShuffle(), Manager_farmers::removeFromModel(), Scheduler::run(), setGISPointer(), Init::setInitLevel1(), Init::setInitLevel5(), ThreadManager(), and SuperAgentManager::update().
the agent super manager, will deal with all the manager objects
Definition at line 63 of file ThreadManager.h.
Referenced by deleteDeadOldPointers(), Gis::getClosestAgents(), Output::initOutputAggregatedData(), Output::initOutputDetailedData(), Manager_base::Manager_base(), Output::printAggregatedData(), Output::printDebugMatrices(), Manager_farmers::riseMyAgents(), Scheduler::run(), Init::setInitLevel1(), Init::setInitLevel3(), setSAMPointer(), and ThreadManager().
the Init object (pre-simulation scheduler)
Definition at line 64 of file ThreadManager.h.
Referenced by Manager_farmers::assignPlot(), deleteDeadOldPointers(), MainProgram::run(), setINITPointer(), Pixel::setRandomRenting(), and ThreadManager().
the scheduler object (simulation-loops scheduler)
Definition at line 65 of file ThreadManager.h.
Referenced by Pixel::acquireObject(), Agent_base::acquireObject(), Agent_base::answerStats(), Opt::debug(), deleteDeadOldPointers(), ModelObject::getAge(), RegData::getBaseData(), Agent_farmer::getDecoupledPayments(), RegActivities::getDecouplingOption(), RegActivities::getMatrixActRes(), RegActivities::getMatrixCoefficientByName(), RegActivities::getMatrixCoefficients(), RegActivities::getMatrixGrossMargin(), Pixel::getRentingAge(), Pixel::newYear(), Manager_farmers::prepare(), Layers::print(), Output::printAggregatedData(), Layers::printBinMap(), Gis::printBinMaps(), Gis::printLayers(), Output::printLeavingAgent(), Init::setInitLevel5(), ModelObject::setRandomAge(), Pixel::setRemainingRentingTerm(), setSCDPointer(), ThreadManager(), and Agent_farmer::update().
data output
Definition at line 66 of file ThreadManager.h.
Referenced by deleteDeadOldPointers(), Manager_farmers::planNext(), Scheduler::run(), setDOPointer(), Init::setInitLevel3(), and ThreadManager().
QString messageStr [private] |
volatile bool stopped [private] |
Definition at line 156 of file ThreadManager.h.
Referenced by checkQuery(), pause(), pauseOrResume(), refreshGUI(), resume(), run(), stop(), and ThreadManager().
volatile bool running [private] |
Definition at line 157 of file ThreadManager.h.
Referenced by pause(), pauseOrResume(), refreshGUI(), resume(), run(), and ThreadManager().
QString inputFileName [private] |
Definition at line 158 of file ThreadManager.h.
Referenced by getInputFileName(), run(), runFromConsole(), setInputFileName(), and ThreadManager().
QString baseDirectory [private] |
Definition at line 159 of file ThreadManager.h.
Referenced by getBaseDirectory(), run(), runFromConsole(), setInputFileName(), and ThreadManager().
QString scenarioName [private] |
Definition at line 160 of file ThreadManager.h.
Referenced by getScenarioName(), retrieveScenarioNameFromGUI(), runFromConsole(), and ThreadManager().
volatile int pxQueryID [private] |
volatile int layerQueryPos [private] |
QMutex mutex [private] |
bool GUI [private] |
Definition at line 164 of file ThreadManager.h.
Referenced by run(), runFromConsole(), ThreadManager(), and usingGUI().