Made RT interrupt changes
This commit is contained in:
parent
770af49c87
commit
68a247654d
10 changed files with 47 additions and 20 deletions
|
|
@ -1092,7 +1092,10 @@ class BaseSimulator(Solver):
|
|||
interrupt = self.threading_backend.getInterrupt()
|
||||
if interrupt is None:
|
||||
self.realtime_counter = 100
|
||||
self.threading_backend.wait(wait_time, self.runsim)
|
||||
if wait_time == float('inf') and getattr(self, "accept_external_input", False):
|
||||
self.threading_backend.wait(0.01, self.runsim)
|
||||
else:
|
||||
self.threading_backend.wait(wait_time, self.runsim)
|
||||
return True
|
||||
try:
|
||||
info = interrupt.split(" ")
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ class Controller(BaseSimulator):
|
|||
self.running_irreversible = None
|
||||
self.initial_allocator = None
|
||||
self.prev_termination_time = 0.0
|
||||
self.accept_external_input = False
|
||||
|
||||
def __setstate__(self, retdict):
|
||||
"""
|
||||
|
|
@ -317,6 +318,14 @@ class Controller(BaseSimulator):
|
|||
self.termination_condition = termination_condition
|
||||
self.termination_time_check = False
|
||||
|
||||
def setAcceptExternalInputs(self, aei):
|
||||
"""
|
||||
Sets the controller to accept external inputs.
|
||||
When enabled, the "early-return" of the simulator when all components have an infinite
|
||||
time-advance is ignored.
|
||||
"""
|
||||
self.accept_external_input = aei
|
||||
|
||||
def findAndPerformRelocations(self, gvt, activities, horizon):
|
||||
"""
|
||||
First requests the relocator for relocations to perform, and afterwards actually perform them.
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class ThreadingBackend(object):
|
|||
|
||||
def interrupt(self, value):
|
||||
"""
|
||||
Interrupt a running wait call.
|
||||
Interrupt a running wait call, overwriting any previous interrupts.
|
||||
|
||||
:param value: the value that interrupts
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -623,6 +623,7 @@ class SimulatorConfiguration(object):
|
|||
if not isinstance(ports, dict):
|
||||
raise DEVSException("Realtime input port references should be a dictionary")
|
||||
self.simulator.realtime_port_references = ports
|
||||
self.simulator.accept_external_input = True
|
||||
|
||||
def setModelState(self, model, new_state):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -210,6 +210,7 @@ class Simulator(object):
|
|||
self.setSchedulerActivityHeap()
|
||||
self.locations_file = None
|
||||
self.allocator = None
|
||||
self.accept_external_input = False
|
||||
self.realtime_extra = []
|
||||
|
||||
self.model_ids = []
|
||||
|
|
@ -584,6 +585,7 @@ class Simulator(object):
|
|||
self.controller.setDSDEVS(self.dsdevs)
|
||||
self.controller.setActivityTracking(self.activity_tracking)
|
||||
self.controller.setClassicDEVS(self.classicDEVS)
|
||||
self.controller.setAcceptExternalInputs(self.accept_external_input)
|
||||
self.controller.setCellLocationTracer(self.x_size,
|
||||
self.y_size,
|
||||
self.location_cell_view)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue