Esempio n. 1
0
    def run(self):
        print("Running..")

        brews = 1
        brewcount = 0

        # add the pumps
        hlt_recirc = Pump(Pump.PUMP_BROWN)
        mlt_recirc = Pump(Pump.PUMP_MARCH)
        transfer = Pump(Pump.PUMP_MARCH)

        # This will run forever.
        while True:

            # Initially this will just be doing a single batch at a time
            # but this could allow recipes to be stacked.
            try:
                # load the recipe xml
                recipe = Recipe('step_mash_recipe.xml')

                # parse the recipe xml
                recipe.parse()
            except Exception as e:
                error_str = "Recipe parsing failed!"
                self.logger.critical(error_str)
                print(error_str)

            print("Mash steps are:")
            mash_steps = recipe.get_mash_steps()

            for steps in mash_steps:
                print(steps.tag, steps.attrib)
                for step in steps:
                    print(step.tag, step.text)

            # setup the vessels
            self.vessel_hlt = VesselHlt(self.logger, self.dbconn)
            self.vessel_hlt.strike_in_mlt(self.strike_in_mlt)
            self.vessel_hlt.set_target_strike_time()  # UNIX timestamp
            self.vessel_hlt.add_steps(recipe.get_mash_steps())

            self.vessel_mlt = VesselMlt(self.logger, self.dbconn)
            self.vessel_mlt.strike_in_mlt(self.strike_in_mlt)
            self.vessel_mlt.add_steps(recipe.get_mash_steps())

            self.vessel_ktl = VesselKettle(self.logger, self.dbconn)

            self.sensor_logger = SensorLogger(self.logger, self.dbconn)

            self.control = ControlInterface(self.logger, self.dbconn)

            children = []

            # Create forks for each vessel.
            # from http://www.petercollingridge.co.uk/blog/running-multiple-processes-python
            start_time = time.time()
            processes = self.VESSEL_COUNT + 2  # number of vessels plus the logger and webservice threads
            for process in range(self.VESSEL_COUNT):
                pid = os.fork()
                if pid:
                    children.append(pid)
                else:
                    self.processLauncher(process)
                    os._exit(0)

            # Wait for all the vessels to complete.
            for i, child in enumerate(children):
                os.waitpid(child, 0)

            brewcount += 1

            if (brewcount == brews):
                print("All batches completed. Exiting.")
                os._exit(0)
Esempio n. 2
0
 def run(self):
     print("Running..")
     
     brews = 1
     brewcount = 0
     
     # add the pumps
     hlt_recirc = Pump(Pump.PUMP_BROWN)
     mlt_recirc = Pump(Pump.PUMP_MARCH)
     transfer   = Pump(Pump.PUMP_MARCH)
     
     # This will run forever.
     while True:        
     
         # Initially this will just be doing a single batch at a time
         # but this could allow recipes to be stacked.
         try:
             # load the recipe xml
             recipe = Recipe('step_mash_recipe.xml')
     
             # parse the recipe xml
             recipe.parse()
         except Exception as e:
             error_str = "Recipe parsing failed!"
             self.logger.critical(error_str)
             print(error_str)
             
         print("Mash steps are:")
         mash_steps = recipe.get_mash_steps()
         
         for steps in mash_steps:
             print(steps.tag, steps.attrib)
             for step in steps:
                 print(step.tag, step.text)
         
         # setup the vessels 
         self.vessel_hlt = VesselHlt(self.logger, self.dbconn)
         self.vessel_hlt.strike_in_mlt(self.strike_in_mlt)
         self.vessel_hlt.set_target_strike_time() # UNIX timestamp
         self.vessel_hlt.add_steps(recipe.get_mash_steps())
         
         self.vessel_mlt = VesselMlt(self.logger, self.dbconn)
         self.vessel_mlt.strike_in_mlt(self.strike_in_mlt)
         self.vessel_mlt.add_steps(recipe.get_mash_steps())
         
         self.vessel_ktl = VesselKettle(self.logger, self.dbconn)
     
         self.sensor_logger = SensorLogger(self.logger, self.dbconn)
         
         self.control = ControlInterface(self.logger, self.dbconn)
     
         children = []
     
         # Create forks for each vessel.
         # from http://www.petercollingridge.co.uk/blog/running-multiple-processes-python
         start_time = time.time()
         processes = self.VESSEL_COUNT + 2 # number of vessels plus the logger and webservice threads
         for process in range(self.VESSEL_COUNT):
             pid = os.fork()
             if pid:
                 children.append(pid)
             else:
                 self.processLauncher(process)
                 os._exit(0)
         
         # Wait for all the vessels to complete.
         for i, child in enumerate(children):
             os.waitpid(child, 0)
         
         brewcount += 1
         
         if(brewcount == brews):
             print("All batches completed. Exiting.")
             os._exit(0)