openpnp – modify source code – SlotSchultzFeederConfigurationWizard

Article directory

    • openpnp-src modify-SlotSchultzFeederConfigurationWizard
    • Overview
    • notes
    • Remark
    • END

openpnp – src modify – SlotSchultzFeederConfigurationWizard

Overview

When assigning components to SlotSchultzFeeder, I found that the Part names generated in the coordinate file were spelled together and the names were very long.
When selecting from the feeder component drop-down list, I don’t feel confident because I can’t see everything.
In addition, the text edit box where the name of the reference point component is located is not wide enough and the display is incomplete.
When selecting the feeder action, the name of the action is not fully displayed and only the first half is visible.
Just want to increase the width of the UI elements of the SlotSchultzFeeder information page.
I changed it and it works.
The effect is as follows:

Notes

After submitting it to the local computer, comparing it with the previous version, we found that only D:\my_openpnp\openpnp_github\src\main\java\org\openpnp\machine\reference\feeder\wizards\SlotSchultzFeederConfigurationWizard.java has been changed.


In this file, only SlotSchultzFeederConfigurationWizard(SlotSchultzFeeder feeder) has been changed. This function is a function that dynamically sets UI elements.
The changes are as follows:


The modified complete function is as follows:

 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"); // Increase the width of the drop-down list box of the display name of the feeder corresponding component, 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);
        // Define the number of coordinates, rows, and columns of the sub-panel layout. Element placement is based on several rows and columns as positions.
        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 the id of the UI element in that row
        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 elements for that row
        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()){<!-- -->
            // The commands cannot be concurrent, and the lower computer cannot process them.

            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();

        // Parameter 2 string is "x, y, w, h", increasing w means increasing the width of the text input box
        whateverPanel.add(fiducialPartTf, "4, 8, 8, 1"); // Increase the width of the Feida reference hole component name text box, parameter 3 has been changed to a larger size.
        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);
            }
        }
    }

Remarks

I’m not familiar with java, so I’ll experiment and see the effect while making changes.
There were no adverse reactions after the modification.

Suddenly I discovered that the last code of the official code on the morning of 2022/8/1 was not the officially packaged code implementation.
Because I found that based on the code I changed on 2022/8/1, after introducing the coordinate file, the parameters in the package package added a pad-pitch field, which the official version (dev-2022-0801) did not recognize.


I need to confirm when I have time. Which code is the official dev-2022/8/1 version compiled from?

END