本文整理汇总了Python中api.configuration_api.ConfigurationAPI.get_drips_per_mm方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationAPI.get_drips_per_mm方法的具体用法?Python ConfigurationAPI.get_drips_per_mm怎么用?Python ConfigurationAPI.get_drips_per_mm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.configuration_api.ConfigurationAPI
的用法示例。
在下文中一共展示了ConfigurationAPI.get_drips_per_mm方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_drips_per_mm_should_return_current_setting_if_unmarked
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import get_drips_per_mm [as 别名]
def test_get_drips_per_mm_should_return_current_setting_if_unmarked(self, mock_load):
configuration_API = ConfigurationAPI(ConfigurationManager())
mock_load.return_value = self.DEFAULT_CONFIG
configuration_API.load_printer('Printer')
actual = configuration_API.get_drips_per_mm()
self.assertEquals(self.DEFAULT_CONFIG['drips_per_mm'], actual)
示例2: test_mark_drips_should_when_target_specified
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import get_drips_per_mm [as 别名]
def test_mark_drips_should_when_target_specified(self, mock_current_z_location_mm, mock_start,mock_load,mock_save):
fake_drip_counter = 70
target_height = 10.0
expected_drips_per_mm = fake_drip_counter / target_height
configuration_API = ConfigurationAPI(ConfigurationManager())
mock_load.return_value = self.DEFAULT_CONFIG.copy()
configuration_API.load_printer('printer')
mock_current_z_location_mm.return_value = fake_drip_counter
configuration_API.start_counting_drips()
configuration_API.set_target_height(target_height)
configuration_API.mark_drips_at_target()
self.assertEquals(expected_drips_per_mm, configuration_API.get_drips_per_mm())
self.assertFalse(mock_save.called)
示例3: DripCalibrationUI
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import get_drips_per_mm [as 别名]
class DripCalibrationUI(PeachyFrame, FieldValidations):
def initialize(self):
self._current_printer = self.kwargs['printer']
self._configuration_api = ConfigurationAPI(self._configuration_manager)
self._configuration_api.load_printer(self._current_printer)
self.grid()
self._dripper_type = StringVar()
self._dripper_type.set(self._configuration_api.get_dripper_type())
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)
Radiobutton(self, text="Microphone Dripper", variable=self._dripper_type, value="audio", command = self._dripper_type_changed).grid(column=0,row=20,sticky=N+S+E+W)
Radiobutton(self, text="Emulated Dripper ", variable=self._dripper_type, value="emulated", command = self._dripper_type_changed).grid(column=1,row=20,sticky=N+S+E+W)
# ---------------- Microphone Dripper Frame Start -------------------------
self.update_drips_job = None
self.drips = 0
self._drip_count = IntVar()
self.drips_per_mm_field_text = DoubleVar()
self.drips_per_mm_field_text.set(self._configuration_api.get_drips_per_mm())
self._height_mm_entry = IntVar()
self._height_mm_entry.set(10)
self._average_drips = StringVar()
self._average_drips.set(0)
self.real_dripper_frame = LabelFrame(self, text="Microphone Dripper Setup", padx=5, pady=5)
self.real_dripper_frame.grid(column=0,row=30, columnspan=3)
Label(self.real_dripper_frame,text='Drips', anchor="w").grid(column=0,row=20,sticky=N+S+E+W)
Label(self.real_dripper_frame,textvariable=self._drip_count, anchor="w").grid(column=1,row=20,sticky=N+S+E+W)
Label(self.real_dripper_frame,text='Drips/Second (last 10 drips)', anchor="w").grid(column=0,row=25,sticky=N+S+E+W)
Label(self.real_dripper_frame,textvariable=self._average_drips, anchor="w").grid(column=1,row=25,sticky=N+S+E+W)
Button(self.real_dripper_frame,text=u"Reset Counter", command=self._reset).grid(column=2,row=20,sticky=N+S+E+W)
Label(self.real_dripper_frame,text="End Height in Millimeters", anchor="w",justify="right").grid(column=0,row=30,sticky=N+S+E+W)
Entry(self.real_dripper_frame, width=5, justify="left", textvariable=self._height_mm_entry, validate = 'key', validatecommand=self.validate_int_command()).grid(column=1,row=30,sticky=N+S+E+W)
Label(self.real_dripper_frame,text="Drips per mm", anchor="w", justify="right").grid(column=0,row=40,sticky=N+S+E+W)
Label(self.real_dripper_frame,textvariable=self.drips_per_mm_field_text, anchor="w").grid(column=1,row=40,sticky=N+S+E+W)
Button(self.real_dripper_frame,text=u"Mark", command=self._mark).grid(column=2,row=40,sticky=N+S+E+W)
Label(self.real_dripper_frame).grid(column=1,row=45)
self.real_dripper_frame.grid_remove()
# ---------------- Microphone Dripper Frame Stop -------------------------
# ---------------- Manual Dripper Frame Start ----------------------------
self._drips_per_second = DoubleVar()
self._drips_per_second.set(self._configuration_api.get_emulated_drips_per_second())
self.fake_dripper_frame = LabelFrame(self, text="Emulated Dripper Setup", padx=5, pady=5)
self.fake_dripper_frame.grid(column=0,row=40, columnspan=3,sticky=N+S+E+W)
self.fake_dripper_frame.grid_remove()
Label(self.fake_dripper_frame, text="Drips per second").grid(column=1,row=10)
Entry(self.fake_dripper_frame, textvariable=self._drips_per_second).grid(column=2,row=10)
# ---------------- Manual Dripper Frame Stop ----------------------------
Button(self,text=u"Save", command=self._save).grid(column=2,row=50,sticky=NSEW)
Button(self,text=u"Back", command=self._back).grid(column=0,row=50,sticky=N+S+E+W)
## destory Automaticness
self._dripper_type_changed()
self.update()
def _dripper_type_changed(self):
if self._dripper_type.get() == 'audio':
self._configuration_api.set_dripper_type('audio')
self.fake_dripper_frame.grid_remove()
self.real_dripper_frame.grid()
self._configuration_api.start_counting_drips(drip_call_back = self._drips_updated)
elif self._dripper_type.get() == 'emulated':
self._configuration_api.set_dripper_type('emulated')
self._configuration_api.stop_counting_drips()
self.real_dripper_frame.grid_remove()
self.fake_dripper_frame.grid()
else:
raise Exception('Unsupported Dripper: %s ' % self._dripper_type.get() )
def _drips_updated(self, drips, height, drips_per_second):
self._drip_count.set(drips)
self._average_drips.set("%0.2f" % drips_per_second)
def _reset(self):
self._configuration_api.reset_drips()
def _back(self):
self.navigate(SetupUI)
def _help(self):
PopUp(self,'Help', help_text.setup_drip_calibration_help)
#.........这里部分代码省略.........
示例4: DripCalibrationUI
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import get_drips_per_mm [as 别名]
class DripCalibrationUI(PeachyFrame, FieldValidations):
def initialize(self):
self._current_printer = self.kwargs['printer']
self._configuration_api = ConfigurationAPI(self._configuration_manager)
self._configuration_api.load_printer(self._current_printer)
self.update_drips_job = None
self.drips = 0
self._drip_count = IntVar()
self.grid()
self.drips_per_mm_field_text = DoubleVar()
self.drips_per_mm_field_text.set(self._configuration_api.get_drips_per_mm())
self._height_mm_entry = IntVar()
self._height_mm_entry.set(10)
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='Drips', anchor="w").grid(column=0,row=20,sticky=N+S+E+W)
Label(self,textvariable=self._drip_count, anchor="w").grid(column=1,row=20,sticky=N+S+E+W)
Button(self,text=u"Reset Counter", command=self._reset).grid(column=2,row=20,sticky=N+S+E+W)
Label(self,text="End Height in Millimeters", anchor="w",justify="right").grid(column=0,row=30,sticky=N+S+E+W)
Entry(self, width=5, justify="left", textvariable=self._height_mm_entry, validate = 'key', validatecommand=self.validate_int_command()).grid(column=1,row=30,sticky=N+S+E+W)
Label(self,text="Drips per mm", anchor="w", justify="right").grid(column=0,row=40,sticky=N+S+E+W)
Label(self,textvariable=self.drips_per_mm_field_text, anchor="w").grid(column=1,row=40,sticky=N+S+E+W)
Button(self,text=u"Mark", command=self._mark).grid(column=2,row=40,sticky=N+S+E+W)
Label(self).grid(column=1,row=45)
self._save_button = Button(self,text=u"Save", command=self._save, state=DISABLED)
self._save_button.grid(column=2,row=50,sticky=NSEW)
Button(self,text=u"Back", command=self._back).grid(column=0,row=50,sticky=N+S+E+W)
self._configuration_api.start_counting_drips(drip_call_back = self._drips_updated)
self.update()
def _drips_updated(self, drips, height):
self._drip_count.set(drips)
def _reset(self):
self._configuration_api.reset_drips()
def _back(self):
self.navigate(SetupUI)
def _help(self):
PopUp(self,'Help', help_text.setup_drip_calibration_help)
def _mark(self):
try:
self._configuration_api.set_target_height(self._height_mm_entry.get())
self._configuration_api.mark_drips_at_target()
self.drips_per_mm_field_text.set(self._configuration_api.get_drips_per_mm())
self._save_button.config(state = NORMAL)
except Exception as ex:
tkMessageBox.showwarning(
"Error",
ex.message
)
def _save(self):
self._configuration_api.stop_counting_drips()
self._configuration_api.save()
self.navigate(SetupUI)
def close(self):
self._configuration_api.stop_counting_drips()