本文整理汇总了Python中api.configuration_api.ConfigurationAPI.set_target_height方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationAPI.set_target_height方法的具体用法?Python ConfigurationAPI.set_target_height怎么用?Python ConfigurationAPI.set_target_height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.configuration_api.ConfigurationAPI
的用法示例。
在下文中一共展示了ConfigurationAPI.set_target_height方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mark_drips_should_when_target_specified
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import set_target_height [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)
示例2: test_set_target_height_should_throw_when_not_numeric
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import set_target_height [as 别名]
def test_set_target_height_should_throw_when_not_numeric(self):
configuration_API = ConfigurationAPI(ConfigurationManager())
with self.assertRaises(Exception):
configuration_API.set_target_height('a')
示例3: test_set_target_height_should_throw_when_0_or_below
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import set_target_height [as 别名]
def test_set_target_height_should_throw_when_0_or_below(self):
configuration_API = ConfigurationAPI(ConfigurationManager())
with self.assertRaises(Exception):
configuration_API.set_target_height(0.0)
示例4: test_set_target_height_should_work_for__positive_numbers
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import set_target_height [as 别名]
def test_set_target_height_should_work_for__positive_numbers(self):
configuration_API = ConfigurationAPI(ConfigurationManager())
configuration_API.set_target_height(10.0)
configuration_API.set_target_height(10)
示例5: DripCalibrationUI
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import set_target_height [as 别名]
#.........这里部分代码省略.........
# ---------------- 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)
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())
except Exception as ex:
tkMessageBox.showwarning(
"Error",
ex.message
)
def _save(self):
self._configuration_api.set_emulated_drips_per_second(self._drips_per_second.get())
self._configuration_api.stop_counting_drips()
self._configuration_api.save()
self.navigate(SetupUI)
def close(self):
self._configuration_api.stop_counting_drips()
示例6: DripCalibrationUI
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import set_target_height [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()