Subversion Repositories public iLand

Rev

Rev 514 | Rev 575 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 514 Rev 515
Line 130... Line 130...
130
    }
130
    }
131
}
131
}
132
132
133
void ModelController::runloop()
133
void ModelController::runloop()
134
{
134
{
135
-
 
-
 
135
    static QTime sLastTime = QTime::currentTime();
136
    QApplication::processEvents();
136
    QApplication::processEvents();
137
    if (mPaused)
137
    if (mPaused)
138
        return;
138
        return;
139
    bool doStop = false;
139
    bool doStop = false;
140
    bool hasError = false;
140
    bool hasError = false;
-
 
141
    if (GlobalSettings::instance()->currentYear()<=1) {
-
 
142
        sLastTime = QTime::currentTime(); // reset clock at the beginning of the simulation
-
 
143
    }
141
144
142
    if (!mCanceled && GlobalSettings::instance()->currentYear() < mYearsToRun) {
145
    if (!mCanceled && GlobalSettings::instance()->currentYear() < mYearsToRun) {
143
        MainWindow::bufferedLog(true); // start buffering
146
        MainWindow::bufferedLog(true); // start buffering
144
        hasError = runYear(); // do the work
147
        hasError = runYear(); // do the work
145
        mRunning = true;
148
        mRunning = true;
146
        emit year(GlobalSettings::instance()->currentYear());
149
        emit year(GlobalSettings::instance()->currentYear());
147
        if (!hasError) {
150
        if (!hasError) {
-
 
151
            int elapsed = sLastTime.msecsTo(QTime::currentTime());
148
            int time=0;
152
            int time=0;
149
            if (currentYear()%50==0)
-
 
-
 
153
            if (currentYear()%50==0 && elapsed>10000)
150
                time = 100; // a 100ms pause...
154
                time = 100; // a 100ms pause...
151
            if (currentYear()%100==0) {
-
 
-
 
155
            if (currentYear()%100==0 && elapsed>10000) {
152
                time = 500; // a 500ms pause...
156
                time = 500; // a 500ms pause...
-
 
157
            }
-
 
158
            if (time>0) {
-
 
159
                sLastTime = QTime::currentTime(); // reset clock
-
 
160
                qDebug() << "--- little break ---- (after " << elapsed << "ms).";
153
            }
161
            }
154
            QTimer::singleShot(time,this, SLOT(runloop()));
162
            QTimer::singleShot(time,this, SLOT(runloop()));
155
        }
163
        }
156
        else
164
        else
157
           doStop = true; // an error occured
165
           doStop = true; // an error occured