文章目录
- openpnp - src modify - SlotSchultzFeederConfigurationWizard
- 概述
- 笔记
- 备注
- END
openpnp - src modify - SlotSchultzFeederConfigurationWizard
概述
在给SlotSchultzFeeder分配元件时, 发现坐标文件中产生的Part名称是拼起来的, 名字很长.
在飞达元件下拉列表中选择时, 看不全, 不放心.
另外基准点元件的名称所在的文本编辑框宽度不够, 显示不全.
选择飞达动作时, 动作的名称也显示不全, 只能看到前半部分.
就想着将SlotSchultzFeeder信息页的UI元素的宽度加大.
改了一下, 好使.
效果如下:
笔记
提交到本地后, 和上一次的版本进行比对, 发现只改了 D:\my_openpnp\openpnp_github\src\main\java\org\openpnp\machine\reference\feeder\wizards\SlotSchultzFeederConfigurationWizard.java
在这个文件中, 只改了 SlotSchultzFeederConfigurationWizard(SlotSchultzFeeder feeder), 这个函数是动态设置UI元素的函数.
改动点如下:
修改后的完整函数如下:
public SlotSchultzFeederConfigurationWizard(SlotSchultzFeeder feeder) {
this.feeder = feeder;
JPanel slotPanel = new JPanel();
slotPanel.setBorder(new TitledBorder(null, "Slot", TitledBorder.LEADING, TitledBorder.TOP, null, null));
contentPanel.add(slotPanel);
slotPanel.setLayout(new BoxLayout(slotPanel, BoxLayout.Y_AXIS));
JPanel whateverPanel = new JPanel();
slotPanel.add(whateverPanel);
FormLayout fl_whateverPanel = new FormLayout(new ColumnSpec[] {
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,},
new RowSpec[] {
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,});
fl_whateverPanel.setColumnGroups(new int[][]{new int[]{4, 6, 8, 10}});
whateverPanel.setLayout(fl_whateverPanel);
feederNameTf = new JTextField();
whateverPanel.add(feederNameTf, "8, 2, 3, 1");
feederNameTf.setColumns(10);
JPanel panel_1 = new JPanel();
FlowLayout flowLayout_1 = (FlowLayout) panel_1.getLayout();
flowLayout_1.setAlignment(FlowLayout.LEFT);
whateverPanel.add(panel_1, "12, 2");
JButton loadFeederBtn = new JButton(loadFeederAction);
loadFeederBtn.setToolTipText("Load installed feeder to slot.");
panel_1.add(loadFeederBtn);
// JButton newFeederBtn = new JButton(newFeederAction);
// panel_1.add(newFeederBtn);
JButton deleteFeederBtn = new JButton(deleteFeederAction);
deleteFeederBtn.setToolTipText("Remove selected feeder from database.");
panel_1.add(deleteFeederBtn);
JLabel lblPickRetryCount = new JLabel("Pick Retry Count");
whateverPanel.add(lblPickRetryCount, "2, 12, right, default");
pickRetryCount = new JTextField();
pickRetryCount.setColumns(10);
whateverPanel.add(pickRetryCount, "4, 12, fill, default");
JLabel lblBank = new JLabel("Bank");
whateverPanel.add(lblBank, "2, 14, right, default");
bankCb = new JComboBox();
whateverPanel.add(bankCb, "4, 14, 3, 1");
bankCb.addActionListener(e -> {
feederCb.removeAllItems();
Bank bank = (Bank) bankCb.getSelectedItem();
feederCb.addItem(null);
if (bank != null) {
for (Feeder f : bank.getFeeders()) {
feederCb.addItem(f);
}
}
});
JLabel lblFeeder = new JLabel("Feeder");
whateverPanel.add(lblFeeder, "2, 2, right, default");
feederCb = new JComboBox();
whateverPanel.add(feederCb, "4, 2, 3, 1");
JPanel feederPanel = new JPanel();
feederPanel.setBorder(new TitledBorder(null, "Feeder", TitledBorder.LEADING, TitledBorder.TOP, null));
contentPanel.add(feederPanel);
FormLayout fl_feederPanel = new FormLayout(new ColumnSpec[] {
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,},
new RowSpec[] {
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,});
fl_feederPanel.setColumnGroups(new int[][]{new int[]{4, 6, 8, 10}});
feederPanel.setLayout(fl_feederPanel);
JLabel lblX_1 = new JLabel("X");
feederPanel.add(lblX_1, "4, 2");
JLabel lblY_1 = new JLabel("Y");
feederPanel.add(lblY_1, "6, 2");
JLabel lblZ_1 = new JLabel("Z");
feederPanel.add(lblZ_1, "8, 2");
JLabel lblRotation_1 = new JLabel("Rotation");
feederPanel.add(lblRotation_1, "10, 2");
JLabel lblOffsets = new JLabel("Offsets");
feederPanel.add(lblOffsets, "2, 4");
xOffsetTf = new JTextField();
feederPanel.add(xOffsetTf, "4, 4");
xOffsetTf.setColumns(10);
yOffsetTf = new JTextField();
feederPanel.add(yOffsetTf, "6, 4");
yOffsetTf.setColumns(10);
zOffsetTf = new JTextField();
feederPanel.add(zOffsetTf, "8, 4");
zOffsetTf.setColumns(10);
rotOffsetTf = new JTextField();
feederPanel.add(rotOffsetTf, "10, 4");
rotOffsetTf.setColumns(10);
// offsetLocButtons = new LocationButtonsPanel(xOffsetTf, yOffsetTf, zOffsetTf, rotOffsetTf);
offsetLocButtons = new LocationButtonsPanel(xOffsetTf, yOffsetTf, zOffsetTf, null);
feederPanel.add(offsetLocButtons, "12, 4");
JLabel lblPart = new JLabel("Part");
feederPanel.add(lblPart, "2, 6, right, default");
feederPartCb = new JComboBox();
feederPanel.add(feederPartCb, "4, 6, 9, 1"); // 增加飞达对应元件的显示名称的下拉列表框宽度, param3 is w
feederPartCb.setModel(new PartsComboBoxModel());
feederPartCb.setRenderer(new IdentifiableListCellRenderer<Part>());
JPanel panelActuator = new JPanel();
panelActuator.setBorder(new TitledBorder(null,
"Actuators", TitledBorder.LEADING, TitledBorder.TOP, null));
contentPanel.add(panelActuator);
// 定义子面板布局的坐标行列数, 元素放置都是根据几行几列作为位置来放的.
FormLayout fl_panelActuator = new FormLayout(new ColumnSpec[] {
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC,
FormSpecs.DEFAULT_COLSPEC
},
new RowSpec[] {
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC});
fl_panelActuator.setColumnGroups(new int[][]{new int[]{4, 6, 8, 10}});
panelActuator.setLayout(fl_panelActuator);
JLabel lblActuatorValue = new JLabel("Feeder Number:");
panelActuator.add(lblActuatorValue, "4, 2, right, default");
actuatorValue = new JTextField();
panelActuator.add(actuatorValue, "6, 2");
actuatorValue.setColumns(6);
JLabel lblActuator = new JLabel("Actuator");
panelActuator.add(lblActuator, "4, 4, left, default");
// get id 那行的UI元素
JLabel lblGetID = new JLabel("Get ID");
panelActuator.add(lblGetID, "2, 6, right, default");
comboBoxIdActuator = new JComboBox();
comboBoxIdActuator.setModel(new ActuatorsComboBoxModel(Configuration.get().getMachine()));
panelActuator.add(comboBoxIdActuator, "4, 6, fill, default");
btnIdActuator = new JButton(getIdActuatorAction);
panelActuator.add(btnIdActuator, "6, 6");
idText = new JTextField();
idText.setColumns(10);
panelActuator.add(idText, "8, 6");
// pre pick 那行的UI元素
JLabel lblFeed = new JLabel("Pre Pick");
panelActuator.add(lblFeed, "2, 8, right, default");
comboBoxFeedActuator = new JComboBox();
comboBoxFeedActuator.setModel(new ActuatorsComboBoxModel(Configuration.get().getMachine()));
panelActuator.add(comboBoxFeedActuator, "4, 8, fill, default");
btnTestFeedActuator = new JButton(testFeedActuatorAction);
panelActuator.add(btnTestFeedActuator, "6, 8");
JLabel lblPostPick = new JLabel("Post Pick");
panelActuator.add(lblPostPick, "2, 10, right, default");
comboBoxPostPickActuator = new JComboBox();
comboBoxPostPickActuator.setModel(new ActuatorsComboBoxModel(Configuration.get().getMachine()));
panelActuator.add(comboBoxPostPickActuator, "4, 10, fill, default");
btnTestPostPickActuator = new JButton(testPostPickActuatorAction);
panelActuator.add(btnTestPostPickActuator, "6, 10");
JLabel lblFeedCount = new JLabel("Get Feed Count");
panelActuator.add(lblFeedCount, "2, 12, right, default");
comboBoxFeedCountActuator = new JComboBox();
comboBoxFeedCountActuator.setModel(new ActuatorsComboBoxModel(Configuration.get().getMachine()));
panelActuator.add(comboBoxFeedCountActuator, "4, 12, fill, default");
btnGetFeedCountActuator = new JButton(getFeedCountActuatorAction);
panelActuator.add(btnGetFeedCountActuator, "6, 12");
feedCountValue = new JTextField();
feedCountValue.setColumns(8);
panelActuator.add(feedCountValue, "8, 12");
JLabel lblClearCount = new JLabel("Clear Feed Count");
panelActuator.add(lblClearCount, "2, 14, right, default");
comboBoxClearCountActuator = new JComboBox();
comboBoxClearCountActuator.setModel(new ActuatorsComboBoxModel(Configuration.get().getMachine()));
panelActuator.add(comboBoxClearCountActuator, "4, 14, fill, default");
btnClearCountActuator = new JButton(clearCountActuatorAction);
panelActuator.add(btnClearCountActuator, "6, 14");
JLabel lblGetPitch = new JLabel("Get Pitch");
panelActuator.add(lblGetPitch, "2, 16, right, default");
comboBoxPitchActuator = new JComboBox();
comboBoxPitchActuator.setModel(new ActuatorsComboBoxModel(Configuration.get().getMachine()));
panelActuator.add(comboBoxPitchActuator, "4, 16, fill, default");
btnPitchActuator = new JButton(pitchActuatorAction);
panelActuator.add(btnPitchActuator, "6, 16");
pitchValue = new JTextField();
pitchValue.setColumns(8);
panelActuator.add(pitchValue, "8, 16");
JLabel lblTogglePitch = new JLabel("Toggle Pitch");
panelActuator.add(lblTogglePitch, "2, 18, right, default");
comboBoxTogglePitchActuator = new JComboBox();
comboBoxTogglePitchActuator.setModel(new ActuatorsComboBoxModel(Configuration.get().getMachine()));
panelActuator.add(comboBoxTogglePitchActuator, "4, 18, fill, default");
btnTogglePitchActuator = new JButton(togglePitchActuatorAction);
panelActuator.add(btnTogglePitchActuator, "6, 18");
JLabel lblTogglePitchDesc = new JLabel("Toggle between 2 MM and 4 MM");
panelActuator.add(lblTogglePitchDesc, "8, 18, left, default");
JLabel lblGetStatus = new JLabel("Get Status");
panelActuator.add(lblGetStatus, "2, 20, right, default");
comboBoxStatusActuator = new JComboBox();
comboBoxStatusActuator.setModel(new ActuatorsComboBoxModel(Configuration.get().getMachine()));
panelActuator.add(comboBoxStatusActuator, "4, 20, fill, default");
btnStatusActuator = new JButton(statusActuatorAction);
panelActuator.add(btnStatusActuator, "6, 20");
statusText = new JTextField();
statusText.setColumns(50);
panelActuator.add(statusText, "8, 20");
if(Configuration.get().getMachine().isEnabled()){
// 命令不能并发, 下位机处理不过来.
my_delay_ms(300);
getIdActuatorAction.actionPerformed(null);
my_delay_ms(300);
getFeedCountActuatorAction.actionPerformed(null);
my_delay_ms(300);
pitchActuatorAction.actionPerformed(null);
my_delay_ms(300);
statusActuatorAction.actionPerformed(null);
}
for (Bank bank : SlotSchultzFeeder.getBanks()) {
bankCb.addItem(bank);
}
feederCb.addItem(null);
JLabel lblX = new JLabel("X");
whateverPanel.add(lblX, "4, 4, center, default");
JLabel lblY = new JLabel("Y");
whateverPanel.add(lblY, "6, 4, center, default");
JLabel lblZ = new JLabel("Z");
whateverPanel.add(lblZ, "8, 4, center, default");
JLabel lblRotation = new JLabel("Rotation");
whateverPanel.add(lblRotation, "10, 4, center, default");
JLabel lblPickLocation = new JLabel("Location");
whateverPanel.add(lblPickLocation, "2, 6, right, default");
xPickLocTf = new JTextField();
whateverPanel.add(xPickLocTf, "4, 6");
xPickLocTf.setColumns(10);
yPickLocTf = new JTextField();
whateverPanel.add(yPickLocTf, "6, 6");
yPickLocTf.setColumns(10);
zPickLocTf = new JTextField();
whateverPanel.add(zPickLocTf, "8, 6");
zPickLocTf.setColumns(10);
pickLocButtons = new LocationButtonsPanel(xPickLocTf, yPickLocTf, zPickLocTf, rotPickLocTf);
rotPickLocTf = new JTextField();
whateverPanel.add(rotPickLocTf, "10, 6");
rotPickLocTf.setColumns(10);
whateverPanel.add(pickLocButtons, "12, 6");
JButton fiducialAlign = new JButton(updateLocationAction);
whateverPanel.add(fiducialAlign, "14, 6");
fiducialAlign.setIcon(Icons.fiducialCheck);
fiducialAlign.setToolTipText("Update feeder location based on fiducial");
JLabel lblFiducialPart = new JLabel("Fiducial Part");
whateverPanel.add(lblFiducialPart, "2, 8, right, default");
fiducialPartTf = new JTextField();
// 参数2字符串为 "x, y, w, h", 增加w, 就是增加文本输入框的宽度
whateverPanel.add(fiducialPartTf, "4, 8, 8, 1"); // 增加飞达基准孔部件名称文本框的宽度, 参数3改大了.
fiducialPartTf.addActionListener(e -> {
feeder.setFiducialPart(fiducialPartTf.getText());
});
JLabel lblFeedRetryCount = new JLabel("Feed Retry Count");
whateverPanel.add(lblFeedRetryCount, "2, 10, right, default");
feedRetryCount = new JTextField();
whateverPanel.add(feedRetryCount, "4, 10");
feedRetryCount.setColumns(10);
bankNameTf = new JTextField();
whateverPanel.add(bankNameTf, "8, 14, 3, 1");
bankNameTf.setColumns(10);
JPanel panel = new JPanel();
FlowLayout flowLayout = (FlowLayout) panel.getLayout();
flowLayout.setAlignment(FlowLayout.LEFT);
whateverPanel.add(panel, "12, 14");
JButton newBankBtn = new JButton(newBankAction);
panel.add(newBankBtn);
JButton deleteBankBtn = new JButton(deleteBankAction);
panel.add(deleteBankBtn);
if (feeder.getBank() != null) {
for (Feeder f : feeder.getBank().getFeeders()) {
feederCb.addItem(f);
}
}
}
备注
对java不熟, 边改边实验看效果.
改完没啥不良反应.
突然发现, 官方代码的2022/8/1那天上午的最后的代码, 并不是官方打包的代码实现.
因为我发现我现在基于2022/8/1那天改动的代码, 引入坐标文件后, package封装中的参数多了一个pad-pitch字段, 官方版本(dev-2022-0801)不认得.
等有时间得确认一下, 官方dev-2022/8/1 那个版本, 到底是从哪个代码上编译出来的?