FFSM++  1.1.0
French Forest Sector Model ++
Scheduler.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2015 by Laboratoire d'Economie Forestière *
3  * http://ffsm-project.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version, given the compliance with the *
9  * exceptions listed in the file COPYING that is distribued together *
10  * with this file. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 #include "time.h"
23 
24 #include "Scheduler.h"
25 #include "ThreadManager.h"
26 #include "Output.h"
27 #include "ModelData.h"
28 #include "Gis.h"
29 #include "ModelCore.h"
30 #include "ModelCoreSpatial.h"
31 
33  MTHREAD=MTHREAD_h;
34  iteration=0;
35 }
36 
38 }
39 
40 void
42 
43  int initialYear = MTHREAD->MD->getIntSetting("initialYear");
44  int initialSimulationYear = MTHREAD->MD->getIntSetting("initialOptYear");
45  int preSimulationYears = initialSimulationYear-initialYear;
46  for (int it=preSimulationYears;it<MTHREAD->MD->getIntSetting("simulationYears")+preSimulationYears;it++){
47  iteration = it;
49  MTHREAD->upgradeMainSBLabel("New year started..");
50  msgOut(MSG_INFO, "### "+i2s(getYear())+ " year started.. ####");
51  time_t now;
52  time(&now);
53  struct tm *current = localtime(&now);
54  string timemessage = "("+i2s(current->tm_hour)+":"+i2s(current->tm_min)+":"+ i2s(current->tm_sec)+")";
57  if(MTHREAD->MD->getBoolSetting("usePixelData")){
58  //MTHREAD->GIS->initLayersModelData(); // removed 20120930, not needed, as data in specific pixel values
60  } else {
62  }
63 
64 
65  //MTHREAD->DO->print(); // done within modelcore now
66 
67  for(int i=0;i<MTHREAD->GIS->getXNPixels();i++){
68  MTHREAD->GIS->getPixel(i)->newYear(); //delete objects for the pixels, in the update the agents will do the same for their objects
69  }
70  }
71 }
72 
int getIntSetting(const string &name_h, int position=0, int reg=WORLD) const
Definition: ModelData.cpp:1105
bool getBoolSetting(const string &name_h, int position=0, int reg=WORLD) const
Definition: ModelData.cpp:1117
void run()
Definition: Scheduler.cpp:41
string i2s(const int &int_h) const
integer to string conversion
Definition: BaseClass.cpp:219
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
ModelData * MD
the model data object
Definition: ThreadManager.h:72
void msgOut(const int &msgCode_h, const string &msg_h, const bool &refreshGUI_h=true) const
Overloaded function to print the output log.
Definition: BaseClass.cpp:50
int getCachedInitialYear()
Definition: ModelData.h:187
Gis * GIS
GIS information and methods.
Definition: ThreadManager.h:73
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
Definition: ThreadManager.h:65
void upgradeYearSBLabel(int year)
void newYear()
Definition: Pixel.cpp:385
ModelCore * CORE
Core of the model.
Definition: ThreadManager.h:77
void upgradeMainSBLabel(const string message_h)
ModelCoreSpatial * SCORE
Core of the model (spatial version)
Definition: ThreadManager.h:78
Scheduler(ThreadManager *MTHREAD_h)
Definition: Scheduler.cpp:32
int getYear()
Definition: Scheduler.h:49
int year
Definition: Scheduler.h:55
int iteration
Definition: Scheduler.h:54
Pixel * getPixel(int x_h, int y_h)
Definition: Gis.h:134
void treeViewerChangeGeneralPropertyValue(string propertyName, string newValue)
int getXNPixels() const
Definition: Gis.h:129
Print an INFO message.
Definition: BaseClass.h:59
void runSimulationYear()
Definition: ModelCore.cpp:70