本文整理汇总了Python中api.configuration_api.ConfigurationAPI.set_serial_port方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationAPI.set_serial_port方法的具体用法?Python ConfigurationAPI.set_serial_port怎么用?Python ConfigurationAPI.set_serial_port使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.configuration_api.ConfigurationAPI
的用法示例。
在下文中一共展示了ConfigurationAPI.set_serial_port方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_serial_options_loads_correctly
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import set_serial_port [as 别名]
def test_get_serial_options_loads_correctly(self, mock_save, mock_load):
expected_enabled = True
expected_port = 'com54'
expected_on = 'GOGOGO'
expected_off = 'STOPSTOP'
mock_load.return_value = self.default_config
expected = self.default_config
expected.serial.on = expected_enabled
expected.serial.port = expected_port
expected.serial.on_command = expected_on
expected.serial.off_command = expected_off
configuration_API = ConfigurationAPI(ConfigurationManager())
configuration_API.load_printer("test")
configuration_API.set_serial_enabled(expected_enabled)
configuration_API.set_serial_port(expected_port)
configuration_API.set_serial_on_command(expected_on)
configuration_API.set_serial_off_command(expected_off)
self.assertEquals( expected_enabled ,configuration_API.get_serial_enabled())
self.assertEquals( expected_port ,configuration_API.get_serial_port())
self.assertEquals( expected_on ,configuration_API.get_serial_on_command())
self.assertEquals( expected_off ,configuration_API.get_serial_off_command())
self.assertConfigurationEqual(expected, mock_save.mock_calls[0][1][0])
示例2: test_get_serial_options_loads_correctly
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import set_serial_port [as 别名]
def test_get_serial_options_loads_correctly(self, mock_save, mock_load):
expected_enabled = True
expected_port = 'com54'
expected_on = 'GOGOGO'
expected_off = 'STOPSTOP'
mock_load.return_value = self.DEFAULT_CONFIG.copy()
expected_config = self.DEFAULT_CONFIG.copy()
expected_config['use_serial_zaxis'] = expected_enabled
expected_config['serial_port'] = expected_port
expected_config['serial_on'] = expected_on
expected_config['serial_off'] = expected_off
configuration_API = ConfigurationAPI(ConfigurationManager())
configuration_API.load_printer("test")
configuration_API.set_serial_enabled(expected_enabled)
configuration_API.set_serial_port(expected_port)
configuration_API.set_serial_on_command(expected_on)
configuration_API.set_serial_off_command(expected_off)
mock_save.assert_called_with(expected_config)
示例3: SetupOptionsUI
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import set_serial_port [as 别名]
class SetupOptionsUI(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.option_add('*Dialog.msg.width', 50)
self.laser_thickness_entry_text = DoubleVar()
self.laser_thickness_entry_text.set(self._configuration_api.get_laser_thickness_mm())
self.sublayer_height_entry_text = DoubleVar()
self.sublayer_height_entry_text.set(self._configuration_api.get_sublayer_height_mm())
self.max_lead_distance_entry_text = DoubleVar()
self.max_lead_distance_entry_text.set(self._configuration_api.get_max_lead_distance_mm())
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 = "Spot Diameter (mm) [0.5]" ).grid(column=0,row=20)
Entry(self, textvariable = self.laser_thickness_entry_text).grid(column=1, row=20)
Label(self, text = "Sub Layer Height (mm) [0.05]" ).grid(column=0,row=30)
Entry(self, textvariable = self.sublayer_height_entry_text).grid(column=1, row=30)
Label(self, text = "Maximum Lead Distance (mm) [0.5]" ).grid(column=0,row=40)
Entry(self, textvariable = self.max_lead_distance_entry_text).grid(column=1, row=40)
Label(self).grid(column=1,row=50)
advanced_frame = LabelFrame(self, text="Advanced Options (use at your own risk)", padx=5, pady=5)
advanced_frame.grid(column=0,row=60, columnspan=3)
# ----------------------Frame Start---------------------------
self._use_serial = IntVar()
self._use_serial.set(self._configuration_api.get_serial_enabled())
self._serial_on_command = StringVar()
self._serial_on_command.set(self._configuration_api.get_serial_on_command())
self._serial_off_command = StringVar()
self._serial_off_command.set(self._configuration_api.get_serial_off_command())
self._serial_port = StringVar()
self._serial_port.set(self._configuration_api.get_serial_port())
Checkbutton(advanced_frame, text="Use Serial Drip Control", variable = self._use_serial, command=self._showhide_serial).grid(column=0, row = 10)
Label(advanced_frame,text="Serial Port").grid(column=0, row=20)
self._serial_port_entry = Entry(advanced_frame,textvariable=self._serial_port)
self._serial_port_entry.grid(column=1, row=20)
Label(advanced_frame,text="Serial On Command").grid(column=0, row=30)
self._serial_on_entry = Entry(advanced_frame,textvariable=self._serial_on_command)
self._serial_on_entry.grid(column=1, row=30)
Label(advanced_frame,text="Serial Off Command").grid(column=0, row=40)
self._serial_off_entry = Entry(advanced_frame,textvariable=self._serial_off_command)
self._serial_off_entry.grid(column=1, row=40)
self._showhide_serial()
# ----------------------Frame End---------------------------
Label(self).grid(column=1,row=70)
Button(self, text ="Back", command = self._back).grid(column=0,row=80,sticky=N+S+W)
Button(self, text ="Save", command = self._save).grid(column=2,row=80,sticky=N+S+E)
self.update()
def _showhide_serial(self):
if self._use_serial.get():
self._serial_off_entry.configure(state='normal')
self._serial_on_entry.configure(state='normal')
self._serial_port_entry.configure(state='normal')
else:
self._serial_off_entry.configure(state='disabled')
self._serial_on_entry.configure(state='disabled')
self._serial_port_entry.configure(state='disabled')
def _help(self):
PopUp(self,'Help', help_text.options_help)
def _back(self):
self.navigate(SetupUI)
def _save(self):
self._configuration_api.set_laser_thickness_mm(float(self.laser_thickness_entry_text.get()))
self._configuration_api.set_sublayer_height_mm(float(self.sublayer_height_entry_text.get()))
self._configuration_api.set_max_lead_distance_mm(float(self.max_lead_distance_entry_text.get()))
self._configuration_api.set_serial_enabled(bool(self._use_serial.get()))
self._configuration_api.set_serial_port(self._serial_port.get())
self._configuration_api.set_serial_on_command(self._serial_on_command.get())
self._configuration_api.set_serial_off_command(self._serial_off_command.get())
self.navigate(SetupUI)
def close(self):
pass