def test_get_config_returns_current_config(self, mock_load): expected = { 'name':'MegaPrint' } mock_load.return_value = expected capi = ConfigurationAPI(ConfigurationManager()) capi.load_printer('printer') actual = capi.get_current_config() self.assertEquals(expected, actual)
class PrintUI(PeachyFrame): def initialize(self): self.grid() self.file_opt = options = {} options['defaultextension'] = '.gcode' options['filetypes'] = [('GCode files', '.gcode'),('all files', '.*'), ] options['initialdir'] = '.' options['parent'] = self options['title'] = 'Select file to print' self._configuration_api = ConfigurationAPI(self._configuration_manager) self._printer_selection_current = StringVar() if not self._configuration_api.get_available_printers(): self._configuration_api.add_printer("Peachy Printer") available_printers = self._configuration_api.get_available_printers() self._printer_selection_current.set(available_printers[0]) self._printer_selected(available_printers[0]) OptionMenu(self, self._printer_selection_current, *available_printers, command = self._printer_selected).grid(column=1,row=10,sticky=N+S+E+W) Label(self).grid(column=1,row=20) Button(self,text=u"Verify G Code", command=self.verify_g_code_click).grid(column=1,row=25,sticky=N+S+E+W) Button(self,text=u"Print G Code", command=self.print_g_code_click).grid(column=1,row=30,sticky=N+S+E+W) Label(self).grid(column=1,row=40) Button(self,text=u"Back", command=self._back).grid(column=0,row=50) self.update() def _printer_selected(self, selection): self._configuration_api.load_printer(selection) def print_g_code_click(self): filename = tkFileDialog.askopenfile(**self.file_opt) if filename: self.navigate(PrintStatusUI, printer =self._printer_selection_current.get(), filename = filename, config = self._configuration_api.get_current_config(), calling_class = PrintUI) def verify_g_code_click(self): filename = tkFileDialog.askopenfile(**self.file_opt) if filename: self.navigate(VerifyStatusUI, printer =self._printer_selection_current.get(), filename = filename, config = self._configuration_api.get_current_config(), calling_class = PrintUI) def _back(self): self.navigate(MainUI) def close(self): pass
class PrintUI(PeachyFrame): def initialize(self): self.grid() self.file_opt = options = {} options['defaultextension'] = '.gcode' options['filetypes'] = [ ('GCode files', '.gcode'), ('all files', '.*'), ] options['initialdir'] = '.' options['parent'] = self options['title'] = 'Select file to print' self._configuration_api = ConfigurationAPI(self._configuration_manager) self._printer_selection_current = StringVar() if not self._configuration_api.get_available_printers(): self._configuration_api.add_printer("Peachy Printer") available_printers = self._configuration_api.get_available_printers() self._printer_selection_current.set(available_printers[0]) self._printer_selected(available_printers[0]) OptionMenu(self, self._printer_selection_current, *available_printers, command=self._printer_selected).grid(column=1, row=10, sticky=N + S + E + W) Label(self).grid(column=1, row=20) Button(self, text=u"Verify G Code", command=self.verify_g_code_click).grid(column=1, row=25, sticky=N + S + E + W) Button(self, text=u"Print G Code", command=self.print_g_code_click).grid(column=1, row=30, sticky=N + S + E + W) Label(self).grid(column=1, row=40) Button(self, text=u"Back", command=self._back).grid(column=0, row=50) self.update() def _printer_selected(self, selection): self._configuration_api.load_printer(selection) def print_g_code_click(self): filename = tkFileDialog.askopenfile(**self.file_opt) if filename: self.navigate(PrintStatusUI, printer=self._printer_selection_current.get(), filename=filename, config=self._configuration_api.get_current_config(), calling_class=PrintUI) def verify_g_code_click(self): filename = tkFileDialog.askopenfile(**self.file_opt) if filename: self.navigate(VerifyStatusUI, printer=self._printer_selection_current.get(), filename=filename, config=self._configuration_api.get_current_config(), calling_class=PrintUI) def _back(self): self.navigate(MainUI) def close(self): pass
class CureTestUI(PeachyFrame): def initialize(self): self.grid() self._current_printer = self.kwargs['printer'] self._configuration_api = ConfigurationAPI(self._configuration_manager) self._configuration_api.load_printer(self._current_printer) self._base_height = IntVar() self._base_height.set(3) self._total_height = IntVar() self._total_height.set(23) self._start_speed = IntVar() self._start_speed.set(50) self._stop_speed = IntVar() self._stop_speed.set(250) self._best_height = IntVar() self._best_height.set(0) Label(self, text = 'Printer: ').grid(column=0,row=10) Label(self, text = self._configuration_api.current_printer()).grid(column=1,row=10) Button(self, text='?', command=self._help).grid(column=2, row=10,stick=N+E) Label(self).grid(column=1,row=15) Label(self, text = "Base Height (mm)" ).grid(column=0,row=20) Entry(self, textvariable = self._base_height).grid(column=1, row=20) Label(self, text = "Total Height (mm)" ).grid(column=0,row=30) Entry(self, textvariable = self._total_height).grid(column=1, row=30) Label(self, text = "Start Speed (mm)" ).grid(column=0,row=40) Entry(self, textvariable = self._start_speed).grid(column=1, row=40) Label(self, text = "Finish Speed (mm)" ).grid(column=0,row=50) Entry(self, textvariable = self._stop_speed).grid(column=1, row=50) Label(self).grid(column=1,row=60) Button(self, text ="Run Test", command = self._start).grid(column=2,row=70,sticky=N+S+E) Label(self).grid(column=1,row=80) Label(self, text = "Best height above base (mm)" ).grid(column=0,row=90) self._best_height_field = Entry(self, textvariable = self._best_height) self._best_height_field.grid(column=1, row=90) Label(self).grid(column=1,row=100) Button(self, text ="Save", command = self._save).grid(column=2,row=110,sticky=N+S+W) Button(self, text ="Back", command = self._back).grid(column=0,row=110,sticky=N+S+W) self.update() def _back(self): self.navigate(SetupUI) def _help(self): PopUp(self,'Help', help_text.cure_test_help) def _save(self): try: speed = self._configuration_api.get_speed_at_height( self._base_height.get(), self._total_height.get(), self._start_speed.get(), self._stop_speed.get(), self._best_height.get() ) self._configuration_api.set_speed(speed) self.navigate(SetupUI) except Exception as ex: tkMessageBox.showwarning("Error", ex.message) def _start(self): try: cure_test = self._configuration_api.get_cure_test( self._base_height.get(), self._total_height.get(), self._start_speed.get(), self._stop_speed.get() ) self.navigate(PrintStatusUI,layer_generator = cure_test, config = self._configuration_api.get_current_config(), calling_class = CureTestUI, printer = self._current_printer) except Exception as ex: tkMessageBox.showwarning("Error", ex.message) def close(self): pass
class CureTestUI(PeachyFrame): def initialize(self): self.grid() self._current_printer = self.kwargs['printer'] self._configuration_api = ConfigurationAPI(self._configuration_manager) self._configuration_api.load_printer(self._current_printer) self._base_height = IntVar() self._base_height.set(3) self._total_height = IntVar() self._total_height.set(23) self._start_speed = IntVar() self._start_speed.set(50) self._stop_speed = IntVar() self._stop_speed.set(250) self._best_height = IntVar() self._best_height.set(0) Label(self, text='Printer: ').grid(column=0, row=10) Label(self, text=self._configuration_api.current_printer()).grid(column=1, row=10) Button(self, text='?', command=self._help).grid(column=2, row=10, stick=N + E) Label(self).grid(column=1, row=15) Label(self, text="Base Height (mm)").grid(column=0, row=20) Entry(self, textvariable=self._base_height).grid(column=1, row=20) Label(self, text="Total Height (mm)").grid(column=0, row=30) Entry(self, textvariable=self._total_height).grid(column=1, row=30) Label(self, text="Start Speed (mm)").grid(column=0, row=40) Entry(self, textvariable=self._start_speed).grid(column=1, row=40) Label(self, text="Finish Speed (mm)").grid(column=0, row=50) Entry(self, textvariable=self._stop_speed).grid(column=1, row=50) Label(self).grid(column=1, row=60) Button(self, text="Run Test", command=self._start).grid(column=2, row=70, sticky=N + S + E) Label(self).grid(column=1, row=80) Label(self, text="Best height above base (mm)").grid(column=0, row=90) self._best_height_field = Entry(self, textvariable=self._best_height) self._best_height_field.grid(column=1, row=90) Label(self).grid(column=1, row=100) Button(self, text="Save", command=self._save).grid(column=2, row=110, sticky=N + S + W) Button(self, text="Back", command=self._back).grid(column=0, row=110, sticky=N + S + W) self.update() def _back(self): self.navigate(SetupUI) def _help(self): PopUp(self, 'Help', help_text.cure_test_help) def _save(self): try: speed = self._configuration_api.get_speed_at_height( self._base_height.get(), self._total_height.get(), self._start_speed.get(), self._stop_speed.get(), self._best_height.get()) self._configuration_api.set_speed(speed) self.navigate(SetupUI) except Exception as ex: tkMessageBox.showwarning("Error", ex.message) def _start(self): try: cure_test = self._configuration_api.get_cure_test( self._base_height.get(), self._total_height.get(), self._start_speed.get(), self._stop_speed.get()) self.navigate(PrintStatusUI, layer_generator=cure_test, config=self._configuration_api.get_current_config(), calling_class=CureTestUI, printer=self._current_printer) except Exception as ex: tkMessageBox.showwarning("Error", ex.message) def close(self): pass