Example #1
0
def set_up_brew_stage(request_number):
    """
    Initializes a Brew Batch Stage Object in order to start the brewing process
    :param request_number: ServiceNow generated request number
    :return: a Brew Batch Stage instance
    """
    print("Starting Prep Stage")

    # Create Prep BB Stage obj
    bbs = BrewBatchStage.BrewBatchStage(datetime.datetime.now(), 0,
                                        'Recipe retrieved')

    time.sleep(1)

    # Create log in ServiceNow
    print("Logging to ServiceNow...")
    time.sleep(1)
    status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"Starting Prep Process\"}"
    sn_log = ServiceNowLog()
    ServiceNowLog.create_new_log(sn_log, status_log)
    print("Successfully logged that Prep Stage has started")

    # Create local log
    log = Log.Log(12, "Prep", "Recipe Retrieved", datetime.datetime.now(),
                  "pass")

    print("-----------------------------------------")
    print(log.generate_log())

    print("-----------------------------------------")
    return bbs
Example #2
0
    def mill_grains(self, recipe, request_number):  # Mill_grains process start
        """
        The start of milling grains
        :param request_number: a brew batch request number
        :param recipe: recipe instance
        :return: Return Log
        """
        self.mill_time = recipe.get_mill_time()
        self.grains_weight = recipe.get_grain_weight(recipe.get_grain())

        try:
            # log to begin process
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Starting Mashing Process\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.Milling", "Milling Started",
                      datetime.datetime.now(), "pass")
            print(log.generate_log())
            print("-----------------------------------------")
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.Milling",
                                               "Milling Started")

            while self.mill_time > 0:
                print("Milling Time Left: ", self.mill_time, "min")
                time.sleep(sleep_time)
                self.mill_time -= 1

                if self.mill_time == 0:
                    print("Grains milled")
                    print("-----------------------------------------")

            # log to end process
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Milling Ended\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(2, "Mashing.Milling", "Milling Ended",
                      datetime.datetime.now(), "pass")
            print(log.generate_log())
            print("-----------------------------------------")
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.Milling",
                                               "Milling Ended")
            self.send_grains_to_sparging_tank(recipe, request_number)
        except Exception as e:  # error handling
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Mashing Process Failed\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.Milling", "Milling Started",
                      datetime.datetime.now(), "fail")
            print(log.generate_log())
            print("-----------------------------------------")
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.Milling",
                                               "Milling Failed")
            print(e)
Example #3
0
    def separate_wort(self, recipe, request_number):
        # Separates the wort from the mash
        """
        Displays a count down while wort separation is in process
        :param recipe: a recipe instance
        :param request_number: a brew batch request number
        :return: Current date, time and count down to separating wort.
        """

        self.separation_time = recipe.get_wort_separation_time()

        try:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Separating Wort\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(4, "Mashing.Wort", "Wort Separation Started", datetime.datetime.now(), "pass")
            print(log.generate_log())
            print("-----------------------------------------")
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number, "Mashing.Wort", "Wort Separation Started")

            # Counts the separation time in seconds
            while self.separation_time > 0:
                print("Wort Separating Time Left: ", self.separation_time, "min")
                time.sleep(sleep_time)
                self.separation_time -= 1

                # Verifies that the wort separation has been completed.
                if self.separation_time == 0:
                    print("Wort Separation Completed")
                    print("-----------------------------------------")

            # Generates a log and displays the process has been successfully completed.
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Wort Separated\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(5, "Mashing.Wort", "Wort Separation Ended", datetime.datetime.now(), "pass")
            print(log.generate_log())
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number, "Mashing.Wort", "Wort Separation Ended")

            print("-----------------------------------------")

            print("Wort Separated from Mash")
            print("-----------------------------------------")
            return True

        except Exception as e:  # error handling
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Wort Separation Failed\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.Wort", "Wort Separation Failed", datetime.datetime.now(), "fail")
            print(log.generate_log())
            print("-----------------------------------------")
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number, "Mashing.Wort", "Wort Separation Failed")

            print(e)
Example #4
0
 def sanitization(self, request_number):
     """
     Main method that runs the sanitation process to clean equipment
     Completion is done by pressing enter and sends logging to ServiceNOW throughout the process
     :param request_number: a brew batch request number
     :return: void
     """
     log_no = 0
     try:
         time.sleep(sleep_time)
         log_no += 1
         status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"Sanitization\"}"
         sn_log = ServiceNowLog()
         ServiceNowLog.create_new_log(sn_log, status_log)
         log = Log(log_no, "Prep.Sanitization", "Asked for manual input if Sanitization completed.",
                   datetime.datetime.now(),
                   "pass")
         print(log.generate_log())
         ml = MongoLogging.MongoLogging()
         MongoLogging.MongoLogging.MongoLog(ml, request_number, "Prep.Sanitization", "Asked for manual input if Sanitization completed")
         time.sleep(sleep_time * 2)
         input("\033[1m" + "\n    1. Press Enter when sanitization is done:" + "\033[0m \n")
         # GPIO.wait_for_edge(self.button,GPIO.FALLING)
         time.sleep(sleep_time)
         # noinspection PyRedundantParentheses
         message = ("   Sanitization Completed.\n")
         print("\t\t" + message + "\n")
         log_no += 1
         status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"Sanitization\"}"
         sn_log = ServiceNowLog()
         ServiceNowLog.create_new_log(sn_log, status_log)
         log = Log(log_no, "Prep.Sanitization", "Sanitization done - Input received.", datetime.datetime.now(),
                   "pass")
         print(log.generate_log())
         ml = MongoLogging.MongoLogging()
         MongoLogging.MongoLogging.MongoLog(ml, request_number, "Prep.Sanitization", "Sanitization done -Input received.")
         time.sleep(sleep_time * 2)
     except Exception as e:
         print(e)
         log_no += 1
         status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"Sanitization\"}"
         sn_log = ServiceNowLog()
         ServiceNowLog.create_new_log(sn_log, status_log)
         log = Log(int(log_no), "Prep.Sanitization", "Input for Sanitization completed failed.",
                   datetime.datetime.now(),
                   "fail")
         print(log.generate_log())
         ml = MongoLogging.MongoLogging()
         MongoLogging.MongoLogging.MongoLog(ml, request_number, "Prep.Sanitization", "Input for Sanitization completed failed")
         time.sleep(sleep_time * 2)
     return log_no
Example #5
0
 def print_start_info(self, request_number, boil_temp, boil_time,
                      stage_date_time):
     """
     Prints start stage information to the screen
     :param request_number:
     :param stage_date_time: Start time of the stage
     :param boil_time: Time boil lasts
     :param boil_temp: Temperature
     :param is_boiling: Is it boiling
     """
     print("Starting Boil Stage")
     sleep(sleep_time)
     print("Logging to ServiceNow...")
     sleep(sleep_time)
     status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Boiling\", \"log\":\"Starting Boil Process\"}"
     sn_log = ServiceNowLog()
     ServiceNowLog.create_new_log(sn_log, status_log)
     sleep(sleep_time)
     print("Logging to MongoDB...")
     sleep(sleep_time)
     ml = MongoLogging.MongoLogging()
     MongoLogging.MongoLogging.MongoLog(ml, request_number, "Boiling",
                                        "Starting Boil Process")
     print("Successfully logged that Boil Stage has started")
     print("-----------------------------------------")
     sleep(sleep_time)
     print("Start Time:", stage_date_time)
     sleep(sleep_time)
     print("Boil Time:", boil_time, "Minutes")
     sleep(sleep_time)
     print("Boil Temp:", boil_temp, "Degrees Celsius")
     print("-----------------------------------------")
     sleep(sleep_time)
     print("Turning on Burner...")
     sleep(sleep_time * 3)
     print("Burner is up to temp! Temperature =", boil_temp, "degrees")
     sleep(sleep_time)
     print('Now boiling for', boil_time, "Minutes...")
Example #6
0
    def add_water(self, recipe, request_number):
        """
        Water added to tank from hot liquor tank (HLT)
        :param recipe: a recipe instance
        :param request_number: a brew batch request number
        :return:
        """
        try:
            #adding heated water to tank

            self.water_temp = recipe.get_water_temp()

            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Adding Hot Water to Tank\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.Sparging", "Heated water added to tank",
                      datetime.datetime.now(), "pass")
            print(log.generate_log())

            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.Sparging",
                                               "Heated water added to tank")

            print("-----------------------------------------"
                  )  # prints line to separate statements & log 1 is created

            print("Water Temp: ", self.water_temp,
                  "degrees F")  # displays water temp in degrees F
            print("Added Heated Water to Sparging Tank"
                  )  # print validates the process of water being heated
            print(
                "-----------------------------------------"
            )  # prints line to separate the next process in sparging tank

            self.stir_mash(recipe, request_number)
        except Exception as e:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Adding Hot Water to Tank Failed\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.Sparging", "Adding Hot Water to Tank Failed",
                      datetime.datetime.now(), "fail")
            print(log.generate_log())
            print("-----------------------------------------")
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(
                ml, request_number, "Mashing.Sparging",
                "Adding Hot Water to Tank Failed")

            print(e)
 def get_QA_Check(self, request_number):
     text = input(
         "Please Inspect the Brew Quality. Does it Meet Our Standards (Yes/No)?: "
     )
     # save text as variable
     quality_checked = text
     while quality_checked != "Yes" or quality_checked != "No":
         if quality_checked == "Yes":
             print("Logging to ServiceNow...")
             sleep(sleep_time)
             status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Boiling\", \"log\":\"Finished Boiling; Passed QA\"}"
             sn_log = ServiceNowLog()
             ServiceNowLog.create_new_log(sn_log, status_log)
             sleep(sleep_time)
             print("Logging to MongoDB...")
             sleep(sleep_time)
             ml = MongoLogging.MongoLogging()
             MongoLogging.MongoLogging.MongoLog(
                 ml, request_number, "Boiling",
                 "Finished Boiling; Passed QA")
             sleep(sleep_time)
             print(
                 "Successfully logged that Boil has completed and passes Quality Assurance."
             )
             sleep(sleep_time)
             return True
             # Call Team Ferment
         elif quality_checked == "No":
             print("Logging to ServiceNow...")
             sleep(sleep_time)
             status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Boiling\", \"log\":\"Finished Boiling; Failed QA\"}"
             sn_log = ServiceNowLog()
             ServiceNowLog.create_new_log(sn_log, status_log)
             sleep(sleep_time)
             sleep(sleep_time)
             print("Logging to MongoDB...")
             sleep(sleep_time)
             ml = MongoLogging.MongoLogging()
             MongoLogging.MongoLogging.MongoLog(
                 ml, request_number, "Boiling",
                 "Finished Boiling; Failed QA")
             print("Quality Did not Pass, Please inspect and trash.")
             sleep(sleep_time)
             return False
         else:
             text = input("Please Enter Yes or No: ")
             quality_checked = text
    def heat_water(self, recipe,
                   request_number):  # Water heating process starts
        """
        The start of water heating
        :param request_number: a brew request number
        :param recipe: a recipe instance
        :return: return log
        """

        self.water_amount = recipe.get_water_volume()
        self.water_temp = recipe.get_water_temp()

        try:
            # log to begin process
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Water heating\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.HotLiquorTank", "Water heating started.",
                      datetime.datetime.now(), "pass")
            print(log.generate_log())
            print("-----------------------------------------")

            print("Water Temperature Heated To: ", self.water_temp,
                  " degrees F")
            print("-----------------------------------------")

            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.HotLiquorTank",
                                               "Water heating started")

            self.check_water_temp(recipe, request_number)

        except Exception as e:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Water Heating Failed\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.Milling", "Water Heating Failed",
                      datetime.datetime.now(), "fail")
            print(log.generate_log())
            print("-----------------------------------------")
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.HotLiquorTank",
                                               "Water Heating Failed")
            print(e)
    def send_hot_water_to_sparging_tank(self, recipe, request_number):
        """
        Sends water to sparging tank
        :param recipe: a recipe instance
        :param request_number: a bre batch request number
        :return: print statement
        """
        try:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Sending Hot Water to Sparging Tank\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(3, "Mashing.HotLiquorTank",
                      "Sending Hot Water to Sparging Tank",
                      datetime.datetime.now(), "pass")
            print(log.generate_log())
            print("-----------------------------------------")

            print("Hot water is sent to Sparging Tank.")
            print("-----------------------------------------")

            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(
                ml, request_number, "Mashing.HotLiquorTank",
                "Hot water is sent to Sparging Tank")

            st = SpargingTank()
            st.add_water(recipe, request_number)
        except Exception as e:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Sending Hot Water to Sparging Tank Failed\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.HotLiquorTank",
                      "Sending Hot Water to Sparging Tank Failed",
                      datetime.datetime.now(), "fail")
            print(log.generate_log())
            print("-----------------------------------------")

            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(
                ml, request_number, "Mashing.HotLiquorTank",
                "Sending Hot Water to Sparging Tank Failed")

            print(e)
Example #10
0
    def sparg_the_tank(self, recipe, request_number):
        #empty the tank while spraying water over the remaing grains
        """
        Function to remove finished wort from Sparging tank.
        :param recipe: a Recipe Instance
        :param request_number: a brew batch request number
        :return: Return log 4
        """
        try:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Sparging the Tank\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(4, "Mashing.Sparging", "Sparging the Tank",
                      datetime.datetime.now(), "pass")
            print(log.generate_log())
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.Sparging",
                                               "Sparging the Tank")

            print("-----------------------------------------"
                  )  # prints line to separate statements & log 4 is created

            print("Tank emptying, washing grains."
                  )  # Finishing before sending it to the boiling phase
            print("-----------------------------------------")
            w = Wort()
            w.check_hot_water_temp(recipe, request_number)
        except Exception as e:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Sparging the Tank Failed\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.Sparging", "Sparging the Tank Failed",
                      datetime.datetime.now(), "fail")
            print(log.generate_log())
            print("-----------------------------------------")
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.Sparging",
                                               "Sparging the Tank Failed")

            print(e)
Example #11
0
    def send_grains_to_sparging_tank(self, recipe, request_number):
        """
        Adds grains to the Sparging Tank
        :param recipe: a Recipe instance
        :param request_number: a bre batch request number
        :return: print statement
        """
        try:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Sending Grains to Sparging Tank\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(3, "Mashing.Milling", "Send Grains to Sparging Tank",
                      datetime.datetime.now(), "pass")
            print(log.generate_log())
            print("-----------------------------------------")

            print("Grains added to Sparging Tank")
            print("-----------------------------------------")

            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(
                ml, request_number, "Mashing.Milling",
                "Sending Grains to Sparging Tank")

            hlt = HotLiquorTank()
            hlt.heat_water(recipe, request_number)
        except Exception as e:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Sending Grains to Sparging Tank Failed\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.Milling", "Sending Grains to Sparging Tank",
                      datetime.datetime.now(), "fail")
            print(log.generate_log())
            print("-----------------------------------------")
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(
                ml, request_number, "Mashing.Milling",
                "Sending Grains to Sparging Tank Failed")

            print(e)
    def check_water_volume(self, recipe, request_number):
        """
        Getter for water volume
        :param recipe: a recipe instance
        :param request_number: a brew batch request number
        :return: water volume.
        """
        try:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Checking Water Volume\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(3, "Mashing.HotLiquorTank", "Checking Water Volume",
                      datetime.datetime.now(), "pass")
            print(log.generate_log())
            print("-----------------------------------------")

            print("Water Volume: ", self.water_amount, "gallons")
            print("-----------------------------------------")

            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.HotLiquorTank",
                                               "Checking Water Volume")

            self.send_hot_water_to_sparging_tank(recipe, request_number)

        except Exception as e:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Checking Water Volume Failed\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1,
                      "Mashing.HotLiquorTank", "Checking Water Volume Failed",
                      datetime.datetime.now(), "fail")
            print(log.generate_log())
            print("-----------------------------------------")
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.HotLiquorTank",
                                               "Checking Water Volume Failed")
            print(e)
Example #13
0
    def check_wort_volume(self, recipe, request_number):    # Wort Volume? Should we use it as BatchSize
        # Displays wort volume
        """
        Displays the correct wort volume / generates a log
        :param recipe: a recipe instance
        :param request_number: a brew batch request number
        :return: Current date, time and correct wort volume / and a log
        """

        self.wort_volume = recipe.get_wort_volume()

        # Records correct wort volume to Log
        try:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Check Wort Volume\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(3, "Mashing.Wort", "Check Wort Volume", datetime.datetime.now(), "pass")
            print(log.generate_log())

            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number, "Mashing.Wort", "Check Wort Volume")

            print("-----------------------------------------")

            print("Wort Volume: ", self.wort_volume, "gallons")
            print("-----------------------------------------")

            self.separate_wort(recipe, request_number)
        except Exception as e:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Check Wort Volume Failed\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.Wort", "Check Wort Volume Failed", datetime.datetime.now(), "fail")
            print(log.generate_log())
            print("-----------------------------------------")

            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number, "Mashing.Wort", "Check Wort Volume Failed")

            print(e)
    def check_water_temp(self, recipe, request_number):
        """
        Checks the current temperature of the water.
        :param recipe: Recipe instance
        :param request_number: a brew batch request number
        :return: current water temperature
        """
        try:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Checking Water Temp\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(2, "Mashing.HotLiquorTank", "Checking Water Temperature",
                      datetime.datetime.now(), "pass")
            print(log.generate_log())
            print("-----------------------------------------")

            print("Water Temperature: ", self.water_temp, "degrees F")
            print("-----------------------------------------")

            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.HotLiquorTank",
                                               "Checking Water Temperature")

            self.check_water_volume(recipe, request_number)

        except Exception as e:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Checking Water Temperature Failed\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.HotLiquorTank", "Checking Water Temperature",
                      datetime.datetime.now(), "fail")
            print(log.generate_log())
            print("-----------------------------------------")

            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.HotLiquorTank",
                                               "Water Temperature Failed")
            print(e)
Example #15
0
    def check_hot_water_temp(self, recipe, request_number):
        # Checks for water temperature
        """
        Displays correct water temp in the wort phase / generates a log
        :param recipe: a recipe instance
        :param request_number: a brew batch request number
        :return: Displays current date, time and correct water temperature
        """

        self.hot_water_temp = recipe.get_water_temp()

        # Records correct hot water temp to Log
        try:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Checking Water Temp\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.Wort", "Checking Water Temp", datetime.datetime.now(), "pass")
            print(log.generate_log())
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number, "Mashing.Wort", "Checking Water Temp")

            print("-----------------------------------------")

            print("Hot Water Temperature: ", self.hot_water_temp, "degrees F")
            print("-----------------------------------------")

            self.check_water_volume(recipe, request_number)
        except Exception as e:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Checking Water Temp Failed\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.Wort", "Checking Water Temp Failed", datetime.datetime.now(), "fail")
            print(log.generate_log())
            print("-----------------------------------------")
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number, "Mashing.Wort", "Checking Water Temp Failed")

            print(e)
Example #16
0
    def check_water_volume(self, recipe, request_number):
        # Checks for water volume
        """
        Displays the correct water volume / generates a log
        :param recipe: a recipe instance
        :param request_number: a brew batch request number
        :return: Current date, time and correct water volume
        """

        self.water_volume = recipe.get_water_volume()

        try:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Checking Water Volume\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(2, "Mashing.Wort", "Checking Water Volume", datetime.datetime.now(), "pass")
            print(log.generate_log())
            print("-----------------------------------------")

            print("Water Volume: ", self.water_volume, "gallons")
            print("-----------------------------------------")
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number, "Mashing.Wort", "Checking Water Volume")

            self.check_wort_volume(recipe, request_number)
        except Exception as e:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Checking Water Volume Failed\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.Wort", "Checking Water Volume Failed", datetime.datetime.now(), "fail")
            print(log.generate_log())
            print("-----------------------------------------")
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number, "Mashing.Wort", "Checking Water Volume Failed")

            print(e)
Example #17
0
    def stir_mash(self, recipe, request_number):
        #stirring the wort in progress
        """
        Function to stir the Wort-in progress sparging tank
        :param recipe: a Recipe Instance
        :param request_number: a brew batch request number
        :return: Return log 2
        """
        try:
            self.stir_time = recipe.get_stir_time()

            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Stirring Mash\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(2, "Mashing.Sparging", "Sparging Process Started",
                      datetime.datetime.now(), "pass")
            print(log.generate_log())
            print("-----------------------------------------"
                  )  # prints line to separate statements & log 2 is created
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.Sparging",
                                               "Sparging Process Started")

            while self.stir_time > 0:
                print("Stirring Time Left: ", self.stir_time,
                      "min")  # prints number of seconds left until stirring is
                # finished
                time.sleep(sleep_time)
                self.stir_time -= 1

                if self.stir_time == 0:
                    print(
                        "SpargingTank stirred"
                    )  # print validates that SpargingTank is finished stirring
                    print("-----------------------------------------")

            status_log = "{\"batch_id\":\"" + request_number + "\",\"brew_batch_stage\":\"Mashing\",\"log\":\"Mash Stirred\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(3, "Mashing.Sparging", "Sparging Process Ended",
                      datetime.datetime.now(), "pass")
            print(log.generate_log())
            print("-----------------------------------------"
                  )  # prints line to separate statements & log 3 is created

            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.Sparging",
                                               "Sparging Process Ended")

            print(
                "Mash Stirred")  # print that the mashing is finished stirring
            print("-----------------------------------------"
                  )  # prints line to separate process within SpargingTank
            self.sparg_the_tank(recipe, request_number)
        except Exception as e:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Mashing\", \"log\":\"Mashing Stirred Failed\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            log = Log(1, "Mashing.Sparging", "Mashing Stirred Failed",
                      datetime.datetime.now(), "fail")
            print(log.generate_log())
            print("-----------------------------------------")

            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                               "Mashing.Sparging",
                                               "Mashing Stirred Failed")

            print(e)
Example #18
0
    def read_temp(self, request_number):
        """
        Gathers temperature readings for yeast and logs those readings to ServiceNow and MongoDB
        A keyboard input is used proceed to the next step
        :param request_number: a brew batch request number
        :return: temperature reading
        """
        try:

            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"Temperature\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            self.log_no = self.log_no + 1
            log = Log(self.log_no, "Prep.Temperature",
                      "Waiting to measure temperature of yeast",
                      datetime.datetime.now(), "pass")
            print(log.generate_log())
            time.sleep(sleep_time)
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(
                ml, request_number, "Prep.Temperature",
                "Waiting to measure temperature of yeast")
            time.sleep(sleep_time)
            temperature = random.randrange(55, 85, 1)
            input(
                "\033[1m    2. Press Enter to measure temperature of yeast: \033[0m\n"
            )
            time.sleep(sleep_time * 3)
            print(
                '\t\t\tTemp = \033[1m{0:0.0f}*\033[0;0m F'.format(temperature))
            time.sleep(sleep_time * 2)
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"Temperature\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            self.log_no = self.log_no + 1
            log = Log(self.log_no,
                      "Prep.Temperature", "Temperature of yeast received",
                      datetime.datetime.now(), "pass")
            print(log.generate_log())
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(
                ml, request_number, "Prep.Temperature",
                "Temperature of yeast received")
            time.sleep(sleep_time * 2)
            return temperature
        except Exception as e:
            # Exception: checks if measurement has failed
            print(e)
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"Temperature\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            self.log_no = self.log_no + 1
            log = Log(self.log_no, "Prep.Temperature",
                      "Failed to check temperature of yeast",
                      datetime.datetime.now(), "fail")
            print(log.generate_log())
            time.sleep(sleep_time * 2)
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(
                ml, request_number, "Prep.Temperature",
                "Fail to check temperature of yeast")
            time.sleep(sleep_time * 2)
Example #19
0
    def yeast_temp(self, request_number):
        """
        Determines if yeast is within temperature range through a while loop that checks
        this range. If the temperature of yeast is in range, a log is saved. And if not,
        another yeast is needed for temperature measurement

        :param request_number: a brew batch request number
        :return: void
        """
        tmp = self.read_temp(request_number)
        # noinspection PyRedundantParentheses
        while (tmp > 80 or tmp < 60):
            try:
                print("\t\b***Temperature of yeast is out of range.***")
                print(
                    "  ***Bring another yeast and measure temperature again.*** \n"
                )
                time.sleep(sleep_time * 3)
                status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"Temperature\"}"
                sn_log = ServiceNowLog()
                ServiceNowLog.create_new_log(sn_log, status_log)
                self.log_no = self.log_no + 1
                log = Log(self.log_no, "Prep.Temperature",
                          "Temperature of yeast is not in range.",
                          datetime.datetime.now(), "fail")
                print(log.generate_log())
                time.sleep(sleep_time * 2)
                ml = MongoLogging.MongoLogging()
                MongoLogging.MongoLogging.MongoLog(
                    ml, request_number, "Prep.Temperature",
                    "Temperature of yeast is not in range.")
                time.sleep(sleep_time)
            except Exception as e:
                print(e)
            tmp = self.read_temp(request_number)
        try:
            print(
                "       Temperature of yeast is in range and ready to use.\n")
            time.sleep(sleep_time * 2)
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"Temperature\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            self.log_no = self.log_no + 1
            log = Log(self.log_no,
                      "Prep.Temperature", "Temperature of yeast measured.",
                      datetime.datetime.now(), "pass")
            print(log.generate_log())
            time.sleep(sleep_time * 2)
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(
                ml, request_number, "Prep.Temperature",
                "Temperature of yeast measured")
            time.sleep(sleep_time * 2)
        except Exception as e:

            # Exception: checks if measurement has failed
            print(e)
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"Temperature\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            self.log_no = self.log_no + 1
            log = Log(self.log_no, "Prep.Temperature",
                      "Failed to measure temperature of yeast",
                      datetime.datetime.now(), "fail")
            print(log.generate_log())
            time.sleep(sleep_time * 2)
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(
                ml, request_number, "Prep.Temperature",
                "Failed to measure temperature of yeast")
            time.sleep(sleep_time)
Example #20
0
# Rev

import threading
import time
import sys

from TeamPrep import QualityCheck_Prep
from TeamPrep.Sanitization import Sanitization
from TeamPrep.Temperature import Temperature
from TeamPrep.WeightScale import WeightScale
from Brewing.ServiceNowLog import ServiceNowLog

s = Sanitization()
t = Temperature()
w = WeightScale()
s1 = ServiceNowLog()
# this function will be called on the start of every thread
sleep_time = .25


def thread_function():
    """
    Method thread function that gathers each of Prep's functionality
    Threading is implemented in the main method below with exception handling
    :return: void
    """
    while True:
        try:
            s.sanitization()
            try:
                t.yeast_temp()
    def read_weight_hops(self, recipe, request_number):
        """
        Displays the actual weight of the hops
        :param recipe: a Recipe instance
        :param request_number: a brew batch request number
        :return:  a float, the weight that goes into the weight scale
        """
        try:
            hop = list(recipe.hop_hop_amt.keys())
            weight = list(recipe.hop_hop_amt.values())
            weight = list(map(lambda x: float(x.replace(",", "")), weight))
            j = 1
            for i in range(len(hop)):
                weight_scale = 0.0
                status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"WeightScale\"}"
                sn_log = ServiceNowLog()
                ServiceNowLog.create_new_log(sn_log, status_log)
                self.log_no = self.log_no + 1
                log = Log(self.log_no, "Prep.WeightScale", "Weight scale is set to zero.",
                          datetime.datetime.now(),
                          "pass")
                print(log.generate_log())
                time.sleep(sleep_time)
                ml = MongoLogging.MongoLogging()
                MongoLogging.MongoLogging.MongoLog(ml, request_number, "Prep.WeightScale",
                                                   "Weight scale is set to zero")
                time.sleep(1)
                status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"WeightScale\"}"
                sn_log = ServiceNowLog()
                ServiceNowLog.create_new_log(sn_log, status_log)
                self.log_no = self.log_no + 1
                log = Log(self.log_no, "Prep.WeightScale", "Brewer is being asked to dispense " + hop[i] + ".",
                          datetime.datetime.now(),
                          "pass")
                print(log.generate_log())
                time.sleep(sleep_time)
                ml = MongoLogging.MongoLogging()
                MongoLogging.MongoLogging.MongoLog(ml, request_number, "Prep.WeightScale",
                                                   "Brewer is being asked to dispense " + hop[i] + ".")
                time.sleep(1)
                print(
                    "    \033[1m4." + str(j) + " To brew the beer for this batch, " + str(weight[i]) + " oz of " + hop[
                        i] + " Hops needed.\033[0m\n")
                time.sleep(sleep_time)
                print("       ****Weight scale is calibrated to \033[1m0.0\033[0m. \n")
                time.sleep(sleep_time)
                input("       Press Enter to dispense \033[1m" + hop[i] + "\033[0m Hops:\n")

                for weight_scale in arange(float(weight[i])):
                    weight_scale = weight_scale + 1
                    time.sleep(sleep_time * 2)

                    print("       \033[1m" + str(weight_scale) + "\033[0m pound(s) \033[1m" + hop[
                        i] + "\033[0m Hops received. \033[1m" + str(
                        float(weight[i]) - weight_scale) + "\033[0m pound(s) left to be dispensed. \n")
                    time.sleep(sleep_time)
                    if float(weight[i]) == weight_scale:
                        time.sleep(sleep_time)
                        print("       \033[1m" + hop[i] + "\033[0m Hops are measured and \033[1m" + str(
                            weight_scale) + "\033[0m pounds received. \n")
                        time.sleep(sleep_time)
                        status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"WeightScale\"}"
                        sn_log = ServiceNowLog()
                        ServiceNowLog.create_new_log(sn_log, status_log)
                        self.log_no = self.log_no + 1
                        log = Log(self.log_no, "Prep.WeightScale", hop[i] + " hop received.",
                                  datetime.datetime.now(),
                                  "pass")
                        print(log.generate_log())
                        time.sleep(sleep_time * 2)
                        ml = MongoLogging.MongoLogging()
                        MongoLogging.MongoLogging.MongoLog(ml, request_number, "Prep.WeightScale",
                                                           hop[i] + "hop received.")
                    time.sleep(sleep_time * 2)
                j = j + 1
                i = i + 1
            return weight_scale
        except Exception as e:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"WeightScale\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            self.log_no = self.log_no + 1
            log = Log(self.log_no + 1, "Prep.WeightScale", "Failed to dispense " + hop[i] + ".",
                      datetime.datetime.now(),
                      "fail")
            print(log.generate_log())
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number, "Prep.WeightScale",
                                               "Failed to dispense " + hop[i] + ".")
            print(e)
    def read_weight_grains(self, recipe, request_number):
        """
        Displays the actual weight of the grains
        :param recipe: a Recipe instance
        :param request_number: brew request number
        :return: a float, the grains weight that goes into the weight scale
        """
        try:
            grain = list(recipe.grain.keys())
            weight = list(recipe.grain.values())
            weight = list(map(lambda x: float(x.replace(",", "")), weight))
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"WeightScale\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            self.log_no = self.log_no + 1
            log = Log(self.log_no, "Prep.WeightScale", "Grains list and weight copied from ordered brew recipe.",
                      datetime.datetime.now(),
                      "pass")
            print(log.generate_log())
            time.sleep(sleep_time)
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number, "Prep.WeightScale",
                                               "Grains list and weight copied from ordered brew recipe")
            time.sleep(1)
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"WeightScale\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            self.log_no = self.log_no + 1
            log = Log(self.log_no, "Prep.WeightScale", "Hops list and weight copied from ordered brew recipe.",
                      datetime.datetime.now(),
                      "pass")
            print(log.generate_log())
            time.sleep(sleep_time)
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number, "Prep.WeightScale",
                                               "Hops list and weight copied from ordered brew recipe")
            time.sleep(sleep_time)
            j = 1

            for i in range(len(grain)):
                weight_scale = 0.0
                status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"WeightScale\"}"
                sn_log = ServiceNowLog()
                ServiceNowLog.create_new_log(sn_log, status_log)
                self.log_no = self.log_no + 1
                log = Log(self.log_no + 1, "Prep.WeightScale", "Weight scale is set to zero.",
                          datetime.datetime.now(),
                          "pass")
                print(log.generate_log())
                time.sleep(sleep_time)
                ml = MongoLogging.MongoLogging()
                MongoLogging.MongoLogging.MongoLog(ml, request_number, "Prep.WeightScale",
                                                   "Weight scale is set to zero")
                time.sleep(sleep_time)
                status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"WeightScale\"}"
                sn_log = ServiceNowLog()
                ServiceNowLog.create_new_log(sn_log, status_log)
                self.log_no = self.log_no + 1
                log = Log(self.log_no, "Prep.WeightScale", "Brewer is being asked to dispense " + grain[i] + ".",
                          datetime.datetime.now(),
                          "pass")
                print(log.generate_log())
                time.sleep(sleep_time)
                ml = MongoLogging.MongoLogging()
                MongoLogging.MongoLogging.MongoLog(ml, request_number, "Prep.WeightScale",
                                                   "Brewer is being asked to dispense " + grain[i] + ".")
                time.sleep(sleep_time)
                print("    \033[1m3." + str(j) + " To brew the beer for this batch, " + str(weight[i]) + " pounds of " +
                      grain[i]
                      , " needed.\033[0m\n"
                      )
                time.sleep(sleep_time)
                print("       ****Weight scale is calibrated to \033[1m0.0\033[0m. \n")
                time.sleep(sleep_time)
                input("       Press the Enter to dispense \033[1m" + grain[i] + "\033[0m:\n")

                for weight_scale in arange(float(weight[i])):
                    weight_scale = weight_scale + 1.0
                    time.sleep(sleep_time)
                    print("       \033[1m" + str(
                        weight_scale) + "\033[0;0m pound(s) \033[1m" + grain[i] + "\033[0m received. \033[1m" + str(
                        weight[i] - weight_scale) + "\033[0m pound(s) left to be dispensed. \n")
                    time.sleep(sleep_time)
                    if float(weight[i]) == weight_scale:
                        print("       \033[1m" + grain[i] + "\033[0m are measured and \033[1m" + str(
                            weight_scale) + "\033[0m pounds received.  \n")
                        status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"WeightScale\"}"
                        sn_log = ServiceNowLog()
                        ServiceNowLog.create_new_log(sn_log, status_log)
                        self.log_no = self.log_no + 1
                        log = Log(self.log_no, "Prep.WeightScale", grain[i] + " grain received.",
                                  datetime.datetime.now(),
                                  "pass")
                        print(log.generate_log())
                        time.sleep(sleep_time)
                        ml = MongoLogging.MongoLogging()
                        MongoLogging.MongoLogging.MongoLog(ml, request_number, "Prep.WeightScale",
                                                           grain[i] + "grain received.")
                    time.sleep(sleep_time)
                j = j + 1
                i = i + 1
            return weight_scale
        except Exception as e:
            status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"WeightScale\"}"
            sn_log = ServiceNowLog()
            ServiceNowLog.create_new_log(sn_log, status_log)
            self.log_no = self.log_no + 1
            log = Log(self.log_no, "Prep.WeightScale", "Failed to dispense " + grain[i] + ".",
                      datetime.datetime.now(),
                      "fail")
            print(log.generate_log())
            ml = MongoLogging.MongoLogging()
            MongoLogging.MongoLogging.MongoLog(ml, request_number, "Prep.WeightScale",
                                               "Failed to dispense " + grain[i] + ".")
            print(e)
 def get_QA_Check(self, request_number):
     """
     Gets the Quality Assurance for the Prep Stage
     :param request_number: a brew batch request number
     :return: True if QA passes
     """
     status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"QualityCheck_Prep\"}"
     sn_log = ServiceNowLog()
     ServiceNowLog.create_new_log(sn_log, status_log)
     self.log_no = self.log_no + 1
     log = Log(self.log_no + 1,
               "Prep.QualityCheck", " Prep quality check started.",
               datetime.datetime.now(), "pass")
     print(log.generate_log())
     time.sleep(sleep_time)
     ml = MongoLogging.MongoLogging()
     MongoLogging.MongoLogging.MongoLog(ml, request_number,
                                        "Prep.QualityCheck",
                                        "Prep quality check started.")
     time.sleep(sleep_time)
     print(
         "Please Inspect the Prep Quality Before Starting Brewing to Check if it Meets CGMP Standards: \n"
     )
     # save text as variable
     quality_checked = ""
     while quality_checked != "Yes" or quality_checked != "No":
         if quality_checked == "Yes":
             print("Logging to ServiceNow...")
             time.sleep(sleep_time)
             status_log = "{\"batch_id\":\"1\", \"brew_batch_stage\":\"Preparation\", \"log\":\"Finished Prep process; Passed QA\"}"
             time.sleep(sleep_time)
             status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"QualityCheck_Prep\"}"
             sn_log = ServiceNowLog()
             ServiceNowLog.create_new_log(sn_log, status_log)
             time.sleep(sleep_time)
             self.log_no = self.log_no + 1
             log = Log(self.log_no, "Prep.QualityCheck",
                       " Prep quality check: Passed QA.",
                       datetime.datetime.now(), "pass")
             print(log.generate_log())
             ml = MongoLogging.MongoLogging()
             MongoLogging.MongoLogging.MongoLog(
                 ml, request_number, "Prep.QualityCheck",
                 "Prep quality check: Passed QA.")
             time.sleep(sleep_time)
             print(
                 "Successfully logged that Prep processes has completed and passes Quality Assurance."
             )
             time.sleep(sleep_time)
             return True
         elif quality_checked == "No":
             print("Logging to ServiceNow...")
             time.sleep(sleep_time)
             status_log = "{\"batch_id\":\"" + request_number + "\", \"brew_batch_stage\":\"Prep\", \"log\":\"QualityCheck_Prep\"}"
             sn_log = ServiceNowLog()
             ServiceNowLog.create_new_log(sn_log, status_log)
             time.sleep(sleep_time)
             self.log_no = self.log_no + 1
             log = Log(self.log_no, "Prep.QualityCheck",
                       " Prep quality check: Failed QA.",
                       datetime.datetime.now(), "pass")
             print(log.generate_log())
             ml = MongoLogging.MongoLogging()
             MongoLogging.MongoLogging.MongoLog(
                 ml, request_number, "Prep.QualityCheck",
                 "Prep quality check: Failed QA.")
             time.sleep(sleep_time)
             print(
                 "\nQuality Did not Pass, make correction and inspect again.\n"
             )
             quality_checked = ""
             time.sleep(sleep_time)
         else:
             text = input("\nPlease Enter Yes or No: ")
             quality_checked = text