def MainLoop(): if node_only: runNode() else: # ====================================================================== # Create gui and simulation objects # ====================================================================== global navdb, manager, gui manager = MainManager() gui = Gui() navdb = Navdatabase('global') # Read database from specified folder telnet_in = StackTelnetServer() sim = Simulation(manager) # Initialize the gui (loading graphics data, etc.) gui.init(navdb) # Start the node manager manager.start() # Start the telnet input server for stack commands telnet_in.listen(port=settings.telnet_port) # Start the gui gui.start() print 'Stopping telnet server.' telnet_in.close() # Close the manager, stop all nodes manager.stop() sim.quit() # ====================================================================== # Clean up before exit. Comment this out when debugging for checking # variables in the shell. # ====================================================================== del gui print 'BlueSky normal end.'
def __init__(self): #TMX constructor # Show splash screen & version number in console splash.show() print "*** BlueSky Open Air Traffic sim v0.7 ***" # Initialize print "Initializing Blue Sky objects...." # Create objects for simulation, traffic, screen, keyboard & command stack # To be used as global self.sim = Simulation(self) # contains time, simmode, etc. self.traf = Traffic(self) # contains data on aircraft self.keyb = Keyboard(self) # processes input from keyboard & mouse self.scr = Screen(self) # screen output object self.cmd = Commandstack(self) # list with strings with commands from file or user self.df = DataFeed(self) # render real time flights with ADS-B datafeed return
class TMX(): """Main BlueSky Traffic simulation main executable (tmx) object""" def __init__(self): #TMX constructor # Show splash screen & version number in console splash.show() print "*** BlueSky Open Air Traffic sim v0.7 ***" # Initialize print "Initializing Blue Sky objects...." # Create objects for simulation, traffic, screen, keyboard & command stack # To be used as global self.sim = Simulation(self) # contains time, simmode, etc. self.traf = Traffic(self) # contains data on aircraft self.keyb = Keyboard(self) # processes input from keyboard & mouse self.scr = Screen(self) # screen output object self.cmd = Commandstack(self) # list with strings with commands from file or user self.df = DataFeed(self) # render real time flights with ADS-B datafeed return def run(self): """Start running the simulator (set sim mode)""" self.sim.start() # Main loop for tmx object while not self.sim.mode == self.sim.end : self.sim.update() # Update clock: t, dt self.keyb.update() # Check for keys & mouse self.cmd.checkfile() # Process input file self.cmd.process() # Process commands self.traf.update() # Traffic movements and controls self.scr.update() # GUI update # Restart traffic simulation: if self.sim.mode == self.sim.init: self.reset() return def reset(self): """Reset Traffic database""" del self.traf self.traf = Traffic(self) self.sim.start() self.scr.objdel() # Delete user defined objects return def stack(self,txt): """Add a commandline to stack, may be multiple commands separated by""" self.cmd.stack(txt) return def __del__(self): """Clean up. tmx object destructor, called when object is deleted """ print "Deleting BlueSky objects..." del self.traf del self.sim del self.keyb del self.cmd del self.scr del self.df pg.quit() return