- Update test-python_loader, do not link to libpyloader anymore
- TODO: sigsegv (due to an hidden vtable?) git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@519 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
3c75e1391d
commit
ef733b37e8
|
@ -358,6 +358,7 @@ src_testsuite_test_history_SOURCES = \
|
||||||
|
|
||||||
src_testsuite_test_python_loader_CPPFLAGS = \
|
src_testsuite_test_python_loader_CPPFLAGS = \
|
||||||
-I@top_srcdir@/src \
|
-I@top_srcdir@/src \
|
||||||
|
-DMODDIR="\"$(pyloaderdir)\"" \
|
||||||
$(PYTHON_CPPFLAGS) \
|
$(PYTHON_CPPFLAGS) \
|
||||||
$(GLIBMM_CFLAGS) \
|
$(GLIBMM_CFLAGS) \
|
||||||
$(GTHREAD_CFLAGS)
|
$(GTHREAD_CFLAGS)
|
||||||
|
@ -365,10 +366,14 @@ src_testsuite_test_python_loader_DEPENDENCIES = \
|
||||||
src/backend/pyloader/libpyloader.la
|
src/backend/pyloader/libpyloader.la
|
||||||
src_testsuite_test_python_loader_LDFLAGS = \
|
src_testsuite_test_python_loader_LDFLAGS = \
|
||||||
src/backend/libbackend.la \
|
src/backend/libbackend.la \
|
||||||
src/backend/pyloader/libpyloader.la \
|
$(GLIBMM_LIBS) $(GTHREAD_LIBS) \
|
||||||
$(GLIBMM_LIBS) $(GTHREAD_LIBS)
|
$(PYTHON_LDFLAGS) \
|
||||||
|
$(PYTHON_EXTRA_LIBS) \
|
||||||
|
$(PYTHON_EXTRA_LDFLAGS)
|
||||||
src_testsuite_test_python_loader_SOURCES = \
|
src_testsuite_test_python_loader_SOURCES = \
|
||||||
src/testsuite/test-python_loader.cc \
|
src/testsuite/test-python_loader.cc \
|
||||||
|
src/backend/pyloader/python_policy.cc \
|
||||||
|
src/backend/pyloader/python_policy_manager.cc \
|
||||||
src/standard_io.cc \
|
src/standard_io.cc \
|
||||||
src/text_simulation.cc \
|
src/text_simulation.cc \
|
||||||
src/observer.cc \
|
src/observer.cc \
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace sgpem
|
||||||
class SG_DLLEXPORT ObservedSubject
|
class SG_DLLEXPORT ObservedSubject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~ObservedSubject() =0;
|
virtual ~ObservedSubject() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This method calls Update() on each attached Observer. It should be called when the internal state
|
This method calls Update() on each attached Observer. It should be called when the internal state
|
||||||
|
|
|
@ -173,6 +173,12 @@ PythonPolicy::wait_unlock() const throw(UserInterruptException)
|
||||||
|
|
||||||
if(i++ > 120)
|
if(i++ > 120)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
PyThreadState_Clear(_save);
|
||||||
|
PyEval_RestoreThread(_save);
|
||||||
|
|
||||||
|
//Py_UNBLOCK_THREADS;
|
||||||
|
|
||||||
throw UserInterruptException("User-defined policy is "
|
throw UserInterruptException("User-defined policy is "
|
||||||
"taking too long to terminate.");
|
"taking too long to terminate.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ Scheduler::get_policy()
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Scheduler::step_forward()
|
Scheduler::step_forward() throw(UserInterruptException)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -196,11 +196,13 @@ Scheduler::step_forward()
|
||||||
}
|
}
|
||||||
catch( UserInterruptException e )
|
catch( UserInterruptException e )
|
||||||
{
|
{
|
||||||
// FIXME : Naive.
|
|
||||||
cerr << "Exception: " << e.what() << endl;
|
|
||||||
|
|
||||||
// Errrrr.... you won't like this:
|
|
||||||
_policy_manager.init();
|
_policy_manager.init();
|
||||||
|
|
||||||
|
throw;
|
||||||
|
|
||||||
|
//TODO Do we need to perform some cleanup operation here?
|
||||||
|
// Do we need to update something?
|
||||||
|
|
||||||
// https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1165761&group_id=5470
|
// https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1165761&group_id=5470
|
||||||
// maybe it's that??? oh, damn.
|
// maybe it's that??? oh, damn.
|
||||||
// or maybe not. see http://www.python.org/doc/2.4.2/api/initialization.html
|
// or maybe not. see http://www.python.org/doc/2.4.2/api/initialization.html
|
||||||
|
@ -210,3 +212,4 @@ Scheduler::step_forward()
|
||||||
// - SimulationController that everything stopped
|
// - SimulationController that everything stopped
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace sgpem
|
||||||
#include "observed_subject.hh"
|
#include "observed_subject.hh"
|
||||||
#include "history.hh"
|
#include "history.hh"
|
||||||
#include "schedulable_list.hh"
|
#include "schedulable_list.hh"
|
||||||
|
#include "user_interrupt_exception.hh"
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
|
@ -96,7 +97,7 @@ namespace sgpem
|
||||||
at the simulation instant next to the current one, and extends the History by
|
at the simulation instant next to the current one, and extends the History by
|
||||||
one instant with it.
|
one instant with it.
|
||||||
*/
|
*/
|
||||||
void step_forward();
|
void step_forward() throw(UserInterruptException);
|
||||||
/**
|
/**
|
||||||
Sets the policy that will be used to generate the simulation at the next instant.
|
Sets the policy that will be used to generate the simulation at the next instant.
|
||||||
\param policy the policy that will be used to generate the simulation at the next instant.
|
\param policy the policy that will be used to generate the simulation at the next instant.
|
||||||
|
|
|
@ -73,7 +73,7 @@ Simulation::reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Simulation::run()
|
Simulation::run() throw(UserInterruptException)
|
||||||
{
|
{
|
||||||
History& h = History::get_instance();
|
History& h = History::get_instance();
|
||||||
|
|
||||||
|
@ -105,12 +105,22 @@ loop:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//step forward
|
try
|
||||||
Scheduler::get_instance().step_forward();
|
{
|
||||||
|
//step forward
|
||||||
|
Scheduler::get_instance().step_forward();
|
||||||
|
|
||||||
//sleep
|
//sleep
|
||||||
Glib::usleep(_timer_interval*1000);
|
Glib::usleep(_timer_interval*1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(UserInterruptException e)
|
||||||
|
{
|
||||||
|
stop();
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
//check the state
|
//check the state
|
||||||
if (_state == state_stopped || _state == state_paused)
|
if (_state == state_stopped || _state == state_paused)
|
||||||
return;
|
return;
|
||||||
|
@ -136,24 +146,43 @@ loop:
|
||||||
//by the last execution of upadate()
|
//by the last execution of upadate()
|
||||||
_state = state_paused;
|
_state = state_paused;
|
||||||
else
|
else
|
||||||
//step forward
|
{
|
||||||
Scheduler::get_instance().step_forward();
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//step forward
|
||||||
|
Scheduler::get_instance().step_forward();
|
||||||
|
}
|
||||||
|
catch(UserInterruptException e)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Simulation::jump_to(const uint& where)
|
Simulation::jump_to(const uint& where) throw(UserInterruptException)
|
||||||
{
|
{
|
||||||
//jump to position 0
|
//jump to position 0
|
||||||
reset();
|
reset();
|
||||||
bool old = _mode;
|
bool old = _mode;
|
||||||
_mode = false;
|
_mode = false;
|
||||||
|
|
||||||
// executes "where" steps
|
|
||||||
for (uint i=0; i < where; i++)
|
try
|
||||||
run();
|
{
|
||||||
|
// executes "where" steps
|
||||||
|
for (uint i=0; i < where; i++)
|
||||||
|
run();
|
||||||
|
}
|
||||||
|
catch(UserInterruptException e)
|
||||||
|
{
|
||||||
|
_mode = old;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
_state = state_paused;
|
_state = state_paused;
|
||||||
_mode = old;
|
_mode = old;
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace sgpem
|
||||||
Advances the simulation by one or more steps, depending on the
|
Advances the simulation by one or more steps, depending on the
|
||||||
actual state and on the value set with set_mode().
|
actual state and on the value set with set_mode().
|
||||||
*/
|
*/
|
||||||
void run();
|
void run() throw(UserInterruptException);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Pauses a running simulation.
|
\brief Pauses a running simulation.
|
||||||
|
@ -103,7 +103,7 @@ namespace sgpem
|
||||||
/**
|
/**
|
||||||
\brief Causes the simulation to jump to the given time unit.
|
\brief Causes the simulation to jump to the given time unit.
|
||||||
*/
|
*/
|
||||||
void jump_to(const uint&);
|
void jump_to(const uint&) throw(UserInterruptException);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Setter for the attribute timer_interval.
|
\brief Setter for the attribute timer_interval.
|
||||||
|
|
|
@ -6,6 +6,7 @@ class python_loader_configure(Policy) :
|
||||||
pass;
|
pass;
|
||||||
|
|
||||||
def configure(self):
|
def configure(self):
|
||||||
|
print "[II] Entering willingly an endless loop."
|
||||||
while True:
|
while True:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ class python_loader_get_time_slice(Policy) :
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_time_slice(self):
|
def get_time_slice(self):
|
||||||
|
print "[II] Entering willingly an endless loop."
|
||||||
while True:
|
while True:
|
||||||
pass
|
pass
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -9,6 +9,7 @@ class python_loader_is_preemptive(Policy) :
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def is_preemptive(self):
|
def is_preemptive(self):
|
||||||
|
print "[II] Entering willingly an endless loop."
|
||||||
while True:
|
while True:
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -15,5 +15,6 @@ class python_loader_sort_queue(Policy) :
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
def sort_queue(self, event, queue):
|
def sort_queue(self, event, queue):
|
||||||
|
print "[II] Entering willingly an endless loop."
|
||||||
while True:
|
while True:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -62,7 +62,7 @@ main(int argc, char** argv) {
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// Add current directory to search for uninstalled policies
|
// Add argv[1] as the directory to search for uninstalled policies
|
||||||
sgpem::GlobalSettings::instance().add_policies_dir(argv[1]);
|
sgpem::GlobalSettings::instance().add_policies_dir(argv[1]);
|
||||||
|
|
||||||
Glib::thread_init();
|
Glib::thread_init();
|
||||||
|
@ -94,15 +94,19 @@ main(int argc, char** argv) {
|
||||||
|
|
||||||
polman.test_init("python_loader_configure");
|
polman.test_init("python_loader_configure");
|
||||||
text_sim.run();
|
text_sim.run();
|
||||||
|
text_sim.stop();
|
||||||
|
|
||||||
polman.test_init("python_loader_is_preemptive");
|
polman.test_init("python_loader_is_preemptive");
|
||||||
text_sim.run();
|
text_sim.run();
|
||||||
|
text_sim.stop();
|
||||||
|
|
||||||
polman.test_init("python_loader_get_time_slice");
|
polman.test_init("python_loader_get_time_slice");
|
||||||
text_sim.run();
|
text_sim.run();
|
||||||
|
text_sim.stop();
|
||||||
|
|
||||||
polman.test_init("python_loader_sort_queue");
|
polman.test_init("python_loader_sort_queue");
|
||||||
text_sim.run();
|
text_sim.run();
|
||||||
|
text_sim.stop();
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,18 @@ check:
|
||||||
"by its priority enclosed between round parenthesis."));
|
"by its priority enclosed between round parenthesis."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
obj->run();
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
obj->run();
|
||||||
|
}
|
||||||
|
catch(UserInterruptException e)
|
||||||
|
{
|
||||||
|
obj->_devices[quale]->write_buffer(_("\nERROR: "));
|
||||||
|
obj->_devices[quale]->write_buffer(_(e.what()));
|
||||||
|
obj->_devices[quale]->write_buffer(_("\nSimulation is now stopped"));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (arguments[param] == "PAUSE")
|
else if (arguments[param] == "PAUSE")
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue