Esempio n. 1
0
    def readRecipe(self, recipe=""):

        if recipe:
            self.recipeFile = recipe

        text = ""
        with open(self.recipeFile) as f:

            text = f.read()

            try:
                text = text.decode(config.codepage)
            except UnicodeDecodeError:
                pass

            if type(text) != unicode:
                try:
                    text = text.decode('utf-8')
                except UnicodeDecodeError:
                    pass

            self.program = None
            try:
                self.program = dsl.parse(text)
            except Exception as err:
                message = messages.file_error % helper.unicode_escape(err)
                helper.console(message)
                dialog.infoDialog(message, class_name="")

        if config.print_debug and self.program is not None:
            helper.console(text)
            print(self.program.pretty().encode(config.codepage))
            print(unicode(self.program).encode(config.codepage))
Esempio n. 2
0
 def on_start_clicked(self, widget):
     logging.info("on_start_clicked()")
     if cook.State.is_running(self.cook.state):
         dialog.infoDialog(u"Сначала остановите текущую операцию.", "Выполняется операция.", self.window)
     elif not self.cook.program:
         dialog.infoDialog(u"Не выбран или не открыт рецепт.", "Откройте рецепт.", self.window)
     else:
         if dialog.yesNoDialog(u"Начать выполнение рецепта?", self.window):
             self.cook.program_execute()
             self.ui_notebook_update()
Esempio n. 3
0
 def on_start_clicked(self, widget):
     logging.info("on_start_clicked()")
     if cook.State.is_running(self.cook.state):
         dialog.infoDialog(u"Сначала остановите текущую операцию.",
                           "Выполняется операция.", self.window)
     elif not self.cook.program:
         dialog.infoDialog(u"Не выбран или не открыт рецепт.",
                           "Откройте рецепт.", self.window)
     else:
         if dialog.yesNoDialog(u"Начать выполнение рецепта?", self.window):
             self.cook.program_execute()
             self.ui_notebook_update()
Esempio n. 4
0
    def openFile(self):
        if cook.State.is_running(self.cook.state):
            dialog.infoDialog(u"Сначала остановите текущую операцию.", "Выполняется операция.", self.window)
        else:
            file = dialog.selectFile(u"Рецепт производства", self.window)
            if file != "":
                file = file.decode('utf-8')
                # self.cook.stop()
                logging.info("Selected file " + file)
                self.cook.readRecipe(file)

            self.ui_update_recipe_name()
            self.ui_update_recipe()
            self.ui_update_manual()
            self.notebook.set_current_page(self.recipe_page_number)
Esempio n. 5
0
    def openFile(self):
        if cook.State.is_running(self.cook.state):
            dialog.infoDialog(u"Сначала остановите текущую операцию.",
                              "Выполняется операция.", self.window)
        else:
            file = dialog.selectFile(u"Рецепт производства", self.window)
            if file != "":
                file = file.decode('utf-8')
                # self.cook.stop()
                logging.info("Selected file " + file)
                self.cook.readRecipe(file)

            self.ui_update_recipe_name()
            self.ui_update_recipe()
            self.ui_update_manual()
            self.notebook.set_current_page(self.recipe_page_number)
Esempio n. 6
0
    def on_manual_enable_clicked(self, widget):

        if cook.State.is_running(self.cook.state):
            dialog.infoDialog(u"Сначала остановите текущую операцию.", "Выполняется операция.", self.window)
        else:
            if dialog.yesNoDialog("Выполнить ручную операцию?", self.window):
                logging.info("on_manual_enable_clicked()")

                freq = float(self.ui_manual_freq.get_text())
                execution_time = int(self.ui_manual_time.get_text())
                if self.ui_manual_direction.get_active():
                    direction = cp2000.Direction.FWD
                else:
                    direction = cp2000.Direction.REV
                period = int(self.ui_manual_direction_time.get_text())

                self.cook.manual_execute(direction, freq, execution_time, period)
                self.ui_notebook_update()
Esempio n. 7
0
    def on_manual_enable_clicked(self, widget):

        if cook.State.is_running(self.cook.state):
            dialog.infoDialog(u"Сначала остановите текущую операцию.",
                              "Выполняется операция.", self.window)
        else:
            if dialog.yesNoDialog("Выполнить ручную операцию?", self.window):
                logging.info("on_manual_enable_clicked()")

                freq = float(self.ui_manual_freq.get_text())
                execution_time = int(self.ui_manual_time.get_text())
                if self.ui_manual_direction.get_active():
                    direction = cp2000.Direction.FWD
                else:
                    direction = cp2000.Direction.REV
                period = int(self.ui_manual_direction_time.get_text())

                self.cook.manual_execute(direction, freq, execution_time,
                                         period)
                self.ui_notebook_update()
Esempio n. 8
0
    def user_interaction_command(self):

        if self.cook.is_running and \
                cook.paused(self.cook.user_interaction) and \
                (self.cook.command is not None):

            args = self.cook.command.args if hasattr(self.cook.command, 'args') else None

            if args and self.cook.command.name == "message_dialog":
                dialog.infoDialog(args['message'], parent=self.window)

            elif args and self.cook.command.name == "input":
                res = dialog.textInputDialog(
                            message=args['message'],
                            value=args['default'],
                            title="Введите значение", value_message="Значение",
                            parent=self.window)

                self.cook.command.result = res.decode("utf-8")

            cook.pause(self.cook.user_interaction, False)
Esempio n. 9
0
def startPuzzleScene(challenge = None, isShowInstructions = True):
    from challenge_global_data import LoadedChallengeGlobalData
    from dialog import infoDialog

    loadedChallenge = LoadedChallengeGlobalData(challenge)
    
    if isShowInstructions and loadedChallenge.getInstructions():
        return infoDialog(
            title=loadedChallenge.getName(),
            subtitle=loadedChallenge.getInstructions(),
            callback=lambda:navigate('MAIN')
        )
    navigate('MAIN')
Esempio n. 10
0
    def on_clicked_menu_item(self, button, *args):
        if len(args) == 0:
            dialog.infoDialog(u"Не задан файл рецепта.", parent=self.window)
            return

        if args[0] == "--back--":
            self.fill_menu()
            return

        file = os.path.join(config.data_dir, args[0])
        if not os.path.isfile(file):
            file = args[0]

        if config.print_debug:
            helper.console(file)

        if not os.path.isfile(file):
            dialog.infoDialog(u"Не найден файл рецепта.", parent=self.window)
            return

        self.cook.readRecipe(file)
        self.notebook.set_current_page(self.recipe_page_number)
Esempio n. 11
0
    def user_interaction_command(self):

        if self.cook.is_running and \
                cook.paused(self.cook.user_interaction) and \
                (self.cook.command is not None):

            args = self.cook.command.args if hasattr(self.cook.command,
                                                     'args') else None

            if args and self.cook.command.name == "message_dialog":
                dialog.infoDialog(args['message'], parent=self.window)

            elif args and self.cook.command.name == "input":
                res = dialog.textInputDialog(message=args['message'],
                                             value=args['default'],
                                             title="Введите значение",
                                             value_message="Значение",
                                             parent=self.window)

                self.cook.command.result = res.decode("utf-8")

            cook.pause(self.cook.user_interaction, False)
Esempio n. 12
0
    def on_clicked_menu_item(self, button, *args):
        if len(args) == 0:
            dialog.infoDialog(u"Не задан файл рецепта.", parent=self.window)
            return

        if args[0] == "--back--":
            self.fill_menu()
            return

        file = os.path.join(config.data_dir, args[0])
        if not os.path.isfile(file):
            file = args[0]

        if config.print_debug:
            helper.console(file)

        if not os.path.isfile(file):
            dialog.infoDialog(u"Не найден файл рецепта.", parent=self.window)
            return

        self.cook.readRecipe(file)
        self.notebook.set_current_page(self.recipe_page_number)
Esempio n. 13
0
            if args.datadir is not None:
                if not os.path.isdir(args.datadir):
                    print("Error: Directory \"" + args.datadir + "\" is not exist.")
                    exit(1)

                config.config_files(args.datadir.decode(sys.getfilesystemencoding()).rstrip('/\\'))

            if config.emulate_instrument:
                instrument = None
            else:
                instrument = cp2000.CP2000.get_instrument(config.PORT,
                                                          config.ADDRESS,
                                                          config.minimalmodbus_mode)
                if not instrument:
                    logging.error("Нет связи с прибором.")
                    dialog.infoDialog(
                        "Нет связи с прибором.", explains="Не удается установить соединение с прибором. " +
                        "Проверьте целостность кабеля и настройки программы.")
                    exit(1)

            program.run_main(instrument, args.recipe)

    elif args.command == "cp2000_test":
        cp2000.cp2000_communication_test()

    elif args.command == "cook":
        print("The command hasn't been released yet.")

    elif args.command == "reglist":
        print("The command hasn't been released yet.")