def __init__(self): if not pygame.font: print 'Warning, fonts disabled' if not pygame.mixer: print 'Warning, sound disabled' """this function is called when the program starts. it initializes everything it needs, then runs in a loop until the function returns.""" #Initialize Everything pygame.init() #self.screen = pygame.display.set_mode((640, 480), pygame.FULLSCREEN | pygame.DOUBLEBUF) self.screen = pygame.display.set_mode((640, 480), pygame.HWSURFACE) pygame.display.set_caption('VacuumFire') #pygame.display.toggle_fullscreen() pygame.mouse.set_visible(0) #icon icon, foo = utils.load_image('icon.png') pygame.display.set_icon(icon) intro = Intro(self.screen) vacuum = False self.clock = pygame.time.Clock() #Load musics self.music = {} self.music['game'] = utils.load_sound('level_1.ogg') self.music_game_playing = False self.music['intro'] = utils.load_sound('intro.ogg') self.music['intro'].play() #Loop intro or game depending on intro's state while 1: self.clock.tick(50) if intro.menu_finished == False: intro.loop() else: self.music['intro'].stop() if self.music_game_playing == False: self.music['game'].play() self.music_game_playing = True if vacuum == False: vacuum = Vacuum(self.screen) if vacuum.scene_finished == True: intro = Intro(self.screen) vacuum = False else: vacuum.loop() pygame.display.flip()
def cli_entrypoint(): parser = argparse.ArgumentParser() parser.add_argument('-c', help='config file', default='./config.ini') args = parser.parse_args() DemoConfig.config_file = args.c config = DemoConfig() # create table session = DemoData.get_session(config) session.close() logging.basicConfig(level=config.log_level) vacuum = Vacuum() pool = Pool() try: vacuum.start() pool.start() server = ThreadedHTTPServer(('0.0.0.0', config.http_port), Handler) server.serve_forever() except (KeyboardInterrupt, SystemExit): logging.info("Exit signal catched") vacuum.stop = True
def add_isttok(self, pixel_samples=1000000): nickel_roughness = 0.23 min_wl = 50 max_wl = 51 # add vessel and cameras self.vessel = import_stl( "../isttok_3d/vessel5_stl.stl", scaling=1, mode='binary', parent=self.world, material=RoughNickel(nickel_roughness), #AbsorbingSurface(), transform=translate(0, 0, 0) * rotate(0, 0, 0)) self.camera_top = import_stl( "../isttok_3d/camera_top3_stl.stl", scaling=1, mode='binary', parent=self.world, material=AbsorbingSurface(), transform=translate( self.x_shift_top, self.y_shift_top + self.tube_height + self.lid_top, self.vessel_width / 2.0) * rotate(0, -90, 0)) # self.camera_outer = import_stl("../isttok_3d/camera_outer3_stl.stl", scaling=1, mode='binary', parent=self.world, # material=AbsorbingSurface(), # transform=translate(self.x_shift_outer - self.tube_height - self.lid_outer, # 0.0, # self.vessel_width / 2.0) * rotate(-90, 0, 0)) self.camera_outer = import_stl( "../isttok_3d/camera_outer4_newpin_stl.stl", scaling=1, mode='binary', parent=self.world, material=AbsorbingSurface(), transform=translate( self.x_shift_outer - self.tube_height - self.lid_outer, 0.0, self.vessel_width / 2.0) * rotate(-90, 0, 0)) pinhole_sphere_radius = 0.0005 # 0.0005 self.top_pinhole = Sphere(radius=pinhole_sphere_radius, parent=self.world, transform=translate(self.x_shift_top, self.y_shift_top, self.vessel_width / 2), material=Vacuum()) pinhole_sphere_radius = 0.00035 # 0.0005 self.out_pinhole = Sphere(radius=pinhole_sphere_radius, parent=self.world, transform=translate(self.x_shift_outer, 0.0, self.vessel_width / 2), material=Vacuum()) for i in range(16): self.top_power.append(PowerPipeline0D(accumulate=False)) self.out_power.append(PowerPipeline0D(accumulate=False)) top_px_x = self.top_px_first_x - i * 0.00095 top_px_y = self.top_px_first_y - i * 2 * (self.top_twist / 15) top_angle = degrees(asin(2 * self.top_twist / 0.01425)) out_px_y = self.out_px_first_y - i * 0.00095 out_px_x = self.out_px_first_x - i * 2 * (self.out_twist / 15) out_angle = -degrees(asin(2 * self.out_twist / 0.01425)) self.top_px.append( TargettedPixel( targets=[self.top_pinhole], targetted_path_prob=1.0, pipelines=[self.top_power[i]], x_width=0.00075, y_width=0.00405, min_wavelength=min_wl, max_wavelength=max_wl, spectral_bins=1, pixel_samples=pixel_samples, parent=self.world, quiet=True, ray_importance_sampling=True, ray_important_path_weight=0.05, ray_max_depth=50, transform=translate(top_px_x, top_px_y, self.top_px_z) * rotate(0, 0, top_angle) * rotate(0, -90, 0))) self.out_px.append( TargettedPixel( targets=[self.out_pinhole], targetted_path_prob=1.0, pipelines=[self.out_power[i]], x_width=0.00075, y_width=0.00405, min_wavelength=min_wl, max_wavelength=max_wl, spectral_bins=1, pixel_samples=pixel_samples, parent=self.world, quiet=True, ray_importance_sampling=True, ray_important_path_weight=0.05, ray_max_depth=50, transform=translate(out_px_x, out_px_y, self.out_px_z) * rotate(0, 0, out_angle) * rotate(-90, 0, 90)))
def __init__(self): super(HyperloopSim, self).__init__() # --------------------------------------------------------------------------- # # Freestream Component # --------------------------------------------------------------------------- # self.add('freestream', Freestream()) # --------------------------------------------------------------------------- # # Inlet Design Component # --------------------------------------------------------------------------- # #self.add('supin', SUPIN()) # --------------------------------------------------------------------------- # # Thermo Cycle Component # --------------------------------------------------------------------------- # self.add('cycle', CycleWrap()) # NPSS #self.add('cycle', CompressionCycle()) # Pycycle # --------------------------------------------------------------------------- # # Geometry Component # --------------------------------------------------------------------------- # #self.add('geometry', ESP()) # Engineering Sketch Pad (uses .csm files) #self.add('geometry', SolidWorks()) # Solidworks # --------------------------------------------------------------------------- # # Pointwise Mesher Component # --------------------------------------------------------------------------- # self.add('pointwise', Pointwise()) # --------------------------------------------------------------------------- # # AFLR3 Mesher Component # --------------------------------------------------------------------------- # self.add('aflr3', AFLR3()) # --------------------------------------------------------------------------- # # Fun3D CFD Component # --------------------------------------------------------------------------- # #self.add('fun3d', Fun3D()) # --------------------------------------------------------------------------- # # Liner Induction Motor Component # --------------------------------------------------------------------------- # #self.add('lim', LIM()) # --------------------------------------------------------------------------- # # Cost Component # --------------------------------------------------------------------------- # self.add('cost', TubeCost()) # Tom Gregory Model # --------------------------------------------------------------------------- # # Mission Workflow # --------------------------------------------------------------------------- # # Rob Faulk # --------------------------------------------------------------------------- # # Power Component # --------------------------------------------------------------------------- # self.add('battery', Battery()) # add more here for vacuum, lim # --------------------------------------------------------------------------- # # Tube Structure Component # --------------------------------------------------------------------------- # self.add('struct', TubeStructural()) # --------------------------------------------------------------------------- # # Vacuum Component # --------------------------------------------------------------------------- # self.add('vacuum', Vacuum()) # --------------------------------------------------------------------------- # # Tube Thermal Component # --------------------------------------------------------------------------- # self.add('thermal', TubeWallTemp()) # --------------------------------------------------------------------------- # # Create Main Group Workflow # --------------------------------------------------------------------------- # # Add component instances to top-level Group self.set_order(['freestream', 'cycle', \ 'pointwise', 'aflr3', 'cost', 'battery', 'struct', \ 'vacuum', 'thermal']) # 'supin', geometry', 'fun3d',
"""Main module that runs continously to monitor assorted sensors""" import time import json import graphyte from pressure import Pressure from vacuum import Vacuum from dust import Dust from temperature import Temperature from relative_humidity import RelativeHumidity T = Temperature() P = Pressure() V = Vacuum() D = Dust() RH = RelativeHumidity() with open('sensorConfig.json') as json_file: FILE_DATA = json.load(json_file) graphyte.init(FILE_DATA["ip address"] ) # initializes Grafana to send data to this ip address RUN = True while RUN: VACUUM_DATA = V.vacuum() PRESSURE_DATA = P.pressure() DUST_DATA = D.dust()