OpenASIP
2.0
|
#include <ProximSimulationThread.hh>
Public Member Functions | |
ProximSimulationThread () | |
virtual | ~ProximSimulationThread () |
virtual ExitCode | Entry () |
virtual void | handleEvent (int event) |
ProximLineReader & | lineReader () |
TracedSimulatorFrontend * | frontend () |
void | initialize (ProximMainFrame *gui) |
SimulatorInterpreter * | interpreter () |
void | requestStop () |
void | killSimulation () |
void | finishSimulation () |
bool | isBusy () |
Public Member Functions inherited from Listener | |
Listener () | |
virtual | ~Listener () |
virtual void | handleEvent () |
Private Attributes | |
SimulatorInterpreterContext * | interpreterContext_ |
SimulatorInterpreterContext. ? More... | |
SimulatorInterpreter * | interpreter_ |
SimulatorInterpreter where the user input is passed to. More... | |
TracedSimulatorFrontend * | simulation_ |
Simulator backend. More... | |
ProximLineReader * | lineReader_ |
Linereader used for reading the user input. More... | |
ProximMainFrame * | gui_ |
Proxim main frame where the simulator events are passed to. More... | |
ProximRuntimeErrorHandler * | runtimeErrorHandler_ |
Runtime error handler. More... | |
ProximSimulationThread class wraps the simulation backend in a separate worker thread.
The worker thread utilizes ProximLinereader to read commands from the user. Simulator events and input requests are passed to the GUI thread as custom wxEvents (see SimulatorEvent class).
Definition at line 55 of file ProximSimulationThread.hh.
ProximSimulationThread::ProximSimulationThread | ( | ) |
|
virtual |
The Destructor.
Definition at line 67 of file ProximSimulationThread.cc.
References interpreter_, interpreterContext_, lineReader_, runtimeErrorHandler_, and simulation_.
|
virtual |
Entry point for the simulation thread execution.
The thread waits commands from the line reader, and executes them using the simulator interpreter. Commands are executed until the thread is terminated.
Definition at line 127 of file ProximSimulationThread.cc.
References assert, ScriptInterpreter::error(), SimulatorEvent::EVT_SIMULATOR_COMMAND, SimulatorEvent::EVT_SIMULATOR_COMMAND_DONE, SimulatorEvent::EVT_SIMULATOR_ERROR, SimulatorEvent::EVT_SIMULATOR_OUTPUT, SimulatorEvent::EVT_SIMULATOR_TERMINATED, gui_, TclInterpreter::interpret(), interpreter_, lineReader_, ProximLineReader::readLine(), ScriptInterpreter::result(), and StringTools::trim().
void ProximSimulationThread::finishSimulation | ( | ) |
Finishes the current simulation.
Definition at line 218 of file ProximSimulationThread.cc.
References SimulatorFrontend::finishSimulation(), SimulatorFrontend::isSimulationRunning(), SimulatorFrontend::prepareToStop(), simulation_, and SRE_USER_REQUESTED.
TracedSimulatorFrontend * ProximSimulationThread::frontend | ( | ) |
Returns pointer to the simulator.
Definition at line 307 of file ProximSimulationThread.cc.
References simulation_.
|
virtual |
Handles events from the simulator backend.
The events are passed to the GUI as SimulatorEvents, which is a class derived from the wxEvent class. This way responsibility of the event handling can be passed to the GUI thread.
Reimplemented from Listener.
Definition at line 258 of file ProximSimulationThread.cc.
References SimulatorEvent::EVT_SIMULATOR_LOADING_MACHINE, SimulatorEvent::EVT_SIMULATOR_LOADING_PROGRAM, SimulatorEvent::EVT_SIMULATOR_MACHINE_LOADED, SimulatorEvent::EVT_SIMULATOR_PROGRAM_LOADED, SimulatorEvent::EVT_SIMULATOR_RUN, SimulatorEvent::EVT_SIMULATOR_START, SimulatorEvent::EVT_SIMULATOR_STOP, gui_, ProximMainFrame::reset(), TracedSimulatorFrontend::SIMULATOR_LOADING_MACHINE, TracedSimulatorFrontend::SIMULATOR_LOADING_PROGRAM, TracedSimulatorFrontend::SIMULATOR_MACHINE_LOADED, TracedSimulatorFrontend::SIMULATOR_PROGRAM_LOADED, TracedSimulatorFrontend::SIMULATOR_RESET, TracedSimulatorFrontend::SIMULATOR_RUN, TracedSimulatorFrontend::SIMULATOR_START, and TracedSimulatorFrontend::SIMULATOR_STOP.
void ProximSimulationThread::initialize | ( | ProximMainFrame * | gui | ) |
Initializes the thread.
Definition at line 87 of file ProximSimulationThread.cc.
References gui_, ProximLineReader::initialize(), interpreter_, interpreterContext_, lineReader_, Informer::registerListener(), runtimeErrorHandler_, simulation_, TracedSimulatorFrontend::SIMULATOR_LOADING_MACHINE, TracedSimulatorFrontend::SIMULATOR_LOADING_PROGRAM, TracedSimulatorFrontend::SIMULATOR_MACHINE_LOADED, TracedSimulatorFrontend::SIMULATOR_PROGRAM_LOADED, TracedSimulatorFrontend::SIMULATOR_RESET, TracedSimulatorFrontend::SIMULATOR_RUN, TracedSimulatorFrontend::SIMULATOR_START, and TracedSimulatorFrontend::SIMULATOR_STOP.
Referenced by Proxim::OnInit().
SimulatorInterpreter * ProximSimulationThread::interpreter | ( | ) |
Returns reference to the script interpreter of the simulator.
Definition at line 244 of file ProximSimulationThread.cc.
References interpreter_.
Referenced by ProximToolbox::interpreter(), and Proxim::OnInit().
bool ProximSimulationThread::isBusy | ( | ) |
Returns true if the thread is busy running the simulation.
Definition at line 318 of file ProximSimulationThread.cc.
References SimulatorFrontend::isSimulationRunning(), and simulation_.
void ProximSimulationThread::killSimulation | ( | ) |
Kills the current simulation.
Definition at line 205 of file ProximSimulationThread.cc.
References SimulatorEvent::EVT_SIMULATOR_STOP, gui_, SimulatorFrontend::isSimulationRunning(), TracedSimulatorFrontend::killSimulation(), SimulatorFrontend::prepareToStop(), simulation_, and SRE_USER_REQUESTED.
ProximLineReader & ProximSimulationThread::lineReader | ( | ) |
Returns reference to the line reader which the thread uses to read user input.
Definition at line 233 of file ProximSimulationThread.cc.
References lineReader_.
void ProximSimulationThread::requestStop | ( | ) |
Requests the simulation backend to stop the simulation.
Definition at line 192 of file ProximSimulationThread.cc.
References SimulatorEvent::EVT_SIMULATOR_STOP, gui_, SimulatorFrontend::isSimulationStopped(), SimulatorFrontend::prepareToStop(), simulation_, and SRE_USER_REQUESTED.
|
private |
Proxim main frame where the simulator events are passed to.
Definition at line 81 of file ProximSimulationThread.hh.
Referenced by Entry(), handleEvent(), initialize(), killSimulation(), and requestStop().
|
private |
SimulatorInterpreter where the user input is passed to.
Definition at line 75 of file ProximSimulationThread.hh.
Referenced by Entry(), initialize(), interpreter(), and ~ProximSimulationThread().
|
private |
SimulatorInterpreterContext. ?
Definition at line 73 of file ProximSimulationThread.hh.
Referenced by initialize(), and ~ProximSimulationThread().
|
private |
Linereader used for reading the user input.
Definition at line 79 of file ProximSimulationThread.hh.
Referenced by Entry(), initialize(), lineReader(), and ~ProximSimulationThread().
|
private |
Runtime error handler.
Definition at line 83 of file ProximSimulationThread.hh.
Referenced by initialize(), and ~ProximSimulationThread().
|
private |
Simulator backend.
Definition at line 77 of file ProximSimulationThread.hh.
Referenced by finishSimulation(), frontend(), initialize(), isBusy(), killSimulation(), requestStop(), and ~ProximSimulationThread().