def event(self, eventname, eventdata, sender_rte): #print('Node {} received {} data from {}'.format(self.node_id, eventname, sender_id)) print('SIM EVT: {0} {1}'.format(eventname, eventdata)) # Keep track of event processing event_processed = False if eventname == b'STACKCMD': # We received a single stack command. Add it to the existing stack stack.stack(eventdata, sender_rte) event_processed = True elif eventname == b'BATCH': # We are in a batch simulation, and received an entire scenario. Assign it to the stack. self.reset() stack.set_scendata(eventdata['scentime'], eventdata['scencmd']) self.op() event_processed = True elif eventname == b'QUIT': # BlueSky is quitting self.quit() elif eventname == b'GETSIMSTATE': # Send list of stack functions available in this sim to gui at start stackdict = {cmd: val[0][len(cmd) + 1:] for cmd, val in stack.cmddict.items()} shapes = [shape.raw for shape in areafilter.areas.values()] simstate = dict(pan=bs.scr.def_pan, zoom=bs.scr.def_zoom, stackcmds=stackdict, shapes=shapes) self.send_event(b'SIMSTATE', simstate, target=sender_rte) else: # This is either an unknown event or a gui event. event_processed = bs.scr.event(eventname, eventdata, sender_rte) return event_processed
def event(self, eventname, eventdata, sender_rte): # Keep track of event processing event_processed = False if eventname == b'STACKCMD': # We received a single stack command. Add it to the existing stack stack.stack(eventdata, sender_rte) event_processed = True elif eventname == b'BATCH': # We are in a batch simulation, and received an entire scenario. Assign it to the stack. self.reset() stack.set_scendata(eventdata['scentime'], eventdata['scencmd']) self.op() event_processed = True elif eventname == b'QUIT': # BlueSky is quitting self.quit() elif eventname == b'GETSIMSTATE': # Send list of stack functions available in this sim to gui at start stackdict = {cmd : val[0][len(cmd) + 1:] for cmd, val in stack.cmddict.items()} shapes = [shape.raw for shape in areafilter.areas.values()] simstate = dict(pan=bs.scr.def_pan, zoom=bs.scr.def_zoom, stackcmds=stackdict, shapes=shapes) self.send_event(b'SIMSTATE', simstate, target=sender_rte) else: # This is either an unknown event or a gui event. event_processed = bs.scr.event(eventname, eventdata, sender_rte) return event_processed
def event(self, event): # Keep track of event processing event_processed = False if event.type() == StackTextEventType: # We received a single stack command. Add it to the existing stack stack.stack(event.cmdtext, event.sender_id) event_processed = True elif event.type() == BatchEventType: # We are in a batch simulation, and received an entire scenario. Assign it to the stack. self.reset() stack.set_scendata(event.scentime, event.scencmd) self.start() event_processed = True elif event.type() == SimQuitEventType: # BlueSky is quitting self.quit() else: # This is either an unknown event or a gui event. event_processed = bs.scr.event(event) return event_processed