Exemple #1
0
  public RealtimePanel(MachineInterface machine2) {
    super("Real time control and tuning");
    Image icon = Base.getImage("images/icon.gif", this);
    setIconImage(icon);

    machine = machine2;
    driver = machine.getDriver();

    ((RealtimeControl) driver).enableRealtimeControl(true);

    // create all our GUI interfaces
    JPanel speedPanel = new JPanel();
    JPanel extrusionPanel = new JPanel();
    add(new JLabel("Build speed (during extrusion)"));

    // Speed
    feedrateControl = new ControlSlider("Feedrate", "%", 5, 800, 100, speedPanel);
    // feedrateControl.getSlider().setMajorTickSpacing(10);
    Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
    labelTable.put(new Integer(10), new JLabel("Slow"));
    labelTable.put(new Integer(100), new JLabel(""));
    labelTable.put(new Integer(300), new JLabel("Fast"));
    labelTable.put(new Integer(500), new JLabel("Insane!"));
    feedrateControl.slider.setLabelTable(labelTable);

    //		add(new JLabel("Travel feedrate (no extrusion"),"growx,wrap");
    travelFeedrateControl = new ControlSlider("Travel feedrate", "%", 5, 800, 100, speedPanel);
    travelFeedrateControl.slider.setLabelTable(labelTable);

    // Extrusion
    extrusionPanel.add(new JLabel("Extrusion"), "growx,wrap");
    extrusionControl = new ControlSlider("Material muliplier", "%", 5, 500, 100, extrusionPanel);
    // TODO: extrusion scaling is not implemented in the driver yet.
    extrusionControl.slider.setEnabled(false);
    extrusionControl.field.setEnabled(false);

    mainPanel = new JPanel();
    mainPanel.setLayout(new MigLayout());
    mainPanel.add(speedPanel, "flowy,wrap");
    mainPanel.add(extrusionPanel, "flowy,wrap");

    new SpeedLimit(mainPanel);

    // Show comms debug checkbox
    JCheckBox showCommsDebug = new JCheckBox("Show communications");
    if (((RealtimeControl) driver).getDebugLevel() >= 2) showCommsDebug.setSelected(true);

    showCommsDebug.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (((JCheckBox) e.getSource()).isSelected()) {
              ((RealtimeControl) driver).setDebugLevel(2);
            } else {
              ((RealtimeControl) driver).setDebugLevel(1);
            }
          }
        });
    mainPanel.add(showCommsDebug, "flowy,wrap");
    add(mainPanel);
  }
Exemple #2
0
 @Override
 public void stateChanged(ChangeEvent e) {
   Object s = e.getSource();
   if (s instanceof JSlider) {
     int val = ((JSlider) s).getValue();
     // Base.logger.info("Slider value: "+val);
     field.setText(Integer.toString(val));
     if (s == feedrateControl.getSlider()) {
       ((RealtimeControl) driver).setFeedrateMultiplier((double) val / 100);
     } else if (s == extrusionControl.getSlider()) {
       ((RealtimeControl) driver).setExtrusionMultiplier((double) val / 100);
     } else if (s == travelFeedrateControl.getSlider()) {
       ((RealtimeControl) driver).setTravelFeedrateMultiplier((double) val / 100);
     }
   }
 }
Exemple #3
0
 public void focusLost(FocusEvent e) {
   double limit = Double.parseDouble(((JTextField) e.getSource()).getText());
   Base.logger.info("Setting feedrate limit to " + limit);
   ((RealtimeControl) driver).setFeedrateLimit(limit);
 }