how to control generate function!

Started by moris, October 06, 2008, 06:14:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

moris

i have integrated FET with java application as DLL.

i have succeed to run Generate::generate function, but sometime i want to stop it.

please how can i control the execution of this function!

Liviu Lalescu

That is nice!

You can control it like in timetablegenerateform.cpp, lines 172-174 (basically, behind a mutex, make gen.abortOptimization true, where gen is a Generate variable).

moris

i have add stop function as below:

extern "C" void stop (){

     if(!simulation_running){
                 /*QMessageBox::critical(this, TimetableGenerateForm::tr("FET information"),
                  TimetableGenerateForm::tr("Simulation stopped but the simulation is not running."
                  " This should not happen. Maybe you aborted simulation previously. Please report possible bug to author"));*/

                 return;
           }

           simulation_running=false;

           mutex.lock();
           gen.abortOptimization=true;
           mutex.unlock();

           
}


when i execute solver and i try to stop it i have this message:

ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread.


please, have you response about this!

Liviu Lalescu

Please try to make a global variable, abortOptimizationGlobal (or any other name). Then, in Generate::generate, use this variable in the same way it is used gen.abortOptimization (this->abortOptimization I think it is there). And use it in your new code to stop the generation.

This way, you may be able to surpass this problem.