FET Forum

FET Support (English) => Programming Help => Topic started by: moris on October 06, 2008, 06:14:41 PM

Title: how to control generate function!
Post by: moris on October 06, 2008, 06:14:41 PM
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!
Title: Re: how to control generate function!
Post by: Liviu Lalescu on October 06, 2008, 06:23:30 PM
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).
Title: Re: how to control generate function!
Post by: moris on October 06, 2008, 06:54:44 PM
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!
Title: Re: how to control generate function!
Post by: Liviu Lalescu on October 06, 2008, 07:08:11 PM
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.