Skip to content

Commit

Permalink
Inherit from base
Browse files Browse the repository at this point in the history
Entity derived from TrafArrays, causing an infinite recursion in sim.reset()
  • Loading branch information
jooste committed Oct 25, 2023
1 parent 601e178 commit 1e22882
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions bluesky/simulation/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

# Local imports
import bluesky as bs
from bluesky.core.base import Base
from bluesky.network import context as ctx
import bluesky.core as core
from bluesky.core import plugin, simtime, Signal, Entity
from bluesky.core import plugin, simtime, Entity
from bluesky.core.signal import subscriber
from bluesky.core.walltime import Timer
from bluesky.core.timedfunction import hooks
from bluesky.stack import simstack, recorder
Expand All @@ -23,7 +25,7 @@
# Register settings defaults
bs.settings.set_variable_defaults(simdt=0.05)

class Simulation(Entity):
class Simulation(Base):
''' The simulation object. '''
def __init__(self):
super().__init__()
Expand Down Expand Up @@ -65,11 +67,6 @@ def __init__(self):
signal.signal(signal.SIGINT, lambda *args: self.quit())
signal.signal(signal.SIGTERM, lambda *args: self.quit())


# Connect incoming signals
Signal('BATCH').connect(self.start_batch_scenario)
Signal('STACK').connect(self.on_stack_received)

def run(self):
''' Start the main loop of this simulation. '''
while self.running:
Expand Down Expand Up @@ -249,13 +246,15 @@ def batch(self, fname):

return True

@subscriber(topic='BATCH')
def start_batch_scenario(self, data):
''' Start a scenario coming from the server batch. '''
# We are in a batch simulation, and received an entire scenario. Assign it to the stack.
self.reset()
bs.stack.set_scendata(data['scentime'], data['scencmd'])
self.op()

@subscriber(topic='STACK')
def on_stack_received(self, data):
# We received a single stack command. Add it to the existing stack
bs.stack.stack(data, sender_id=ctx.sender_id)
Expand Down

0 comments on commit 1e22882

Please sign in to comment.