Package org.openpnp.model

Examples of org.openpnp.model.Placement


            if (e.getValueIsAdjusting()) {
              return;
            }
            placementSelectionActionGroup
                .setEnabled(getSelectedPlacement() != null);
            Placement placement = getSelectedPlacement();
            CameraView cameraView = MainFrame.cameraPanel.getSelectedCameraView();
            if (cameraView != null) {
                          if (placement != null) {
                                Reticle reticle = new PackageReticle(placement.getPart().getPackage());
                                cameraView.setReticle(JobPanel.this.getClass().getName(), reticle);
                          }
                          else {
                              cameraView.removeReticle(JobPanel.this.getClass().getName());
                          }
View Full Code Here


      double placementX = Double.parseDouble(matcher.group(4));
      double placementY = Double.parseDouble(matcher.group(5));
      double placementRotation = Double.parseDouble(matcher.group(6));
      String placementLayer = matcher.group(7);
     
      Placement placement = new Placement(placementId);
      placement.setLocation(new Location(
              LengthUnit.Millimeters,
              placementX,
              placementY,
              0,
              placementRotation));
      Configuration cfg = Configuration.get();
            if (cfg != null && createMissingParts) {
                String partId = pkgName + "-" + partValue;
                Part part = cfg.getPart(partId);
                if (part == null) {
                    part = new Part(partId);
                    Package pkg = cfg.getPackage(pkgName);
                    if (pkg == null) {
                        pkg = new Package(pkgName);
                        cfg.addPackage(pkg);
                    }
                    part.setPackage(pkg);

                    cfg.addPart(part);
                }
                placement.setPart(part);

            }

      placement.setSide(side);
      placements.add(placement);
    }
    return placements;
  }
View Full Code Here

      // printf("%s %5.2f %5.2f %3.0f %s %s\n",

      Pattern pattern = Pattern.compile("(\\S+)\\s+(\\d+\\.\\d+)\\s+(\\d+\\.\\d+)\\s+(\\d{1,3})\\s(.*?)\\s(.*)");
      Matcher matcher = pattern.matcher(line);
      matcher.matches();
      Placement placement = new Placement(matcher.group(1));
      placement.setLocation(new Location(
              LengthUnit.Millimeters,
              Double.parseDouble(matcher.group(2)),
              Double.parseDouble(matcher.group(3)),
              0,
              Double.parseDouble(matcher.group(4))));
      Configuration cfg = Configuration.get();
            if (cfg != null && createMissingParts) {
                String packageId = matcher.group(6);

                String partId = packageId + "-" + matcher.group(5);
                Part part = cfg.getPart(partId);
                if (part == null) {
                    part = new Part(partId);
                    Package pkg = cfg.getPackage(packageId);
                    if (pkg == null) {
                        pkg = new Package(packageId);
                        cfg.addPackage(pkg);
                    }
                    part.setPackage(pkg);

                    cfg.addPart(part);
                }
                placement.setPart(part);

            }

      placement.setSide(side);
      placements.add(placement);
    }
    return placements;
  }
View Full Code Here

        return job;
    }

    public static Placement createPlacement(String id, String partId, double x,
            double y, double z, double rotation, Side side) {
        Placement placement = new Placement(id);
        placement.setPart(Configuration.get().getPart(partId));
        placement.setLocation(new Location(LengthUnit.Millimeters, x, y, z,
                rotation));
        placement.setSide(side);
        return placement;
    }
View Full Code Here

              return;
            }
            placementSelectionActionGroup
                .setEnabled(getSelectedPlacement() != null);
           
                        Placement placement = getSelectedPlacement();
                        if (placement != null) {
                            Reticle reticle = new OutlineReticle(placement.getPart().getPackage().getOutline());
                            MainFrame.cameraPanel.getSelectedCameraView().setReticle(BoardsPanel.this.getClass().getName(), reticle);
                        }
                        else {
                            MainFrame.cameraPanel.getSelectedCameraView().removeReticle(BoardsPanel.this.getClass().getName());
                        }           
View Full Code Here

        LinkedHashMap<PlacementSolution, Location> placementSolutionLocations = new LinkedHashMap<PlacementSolution, Location>();
        for (PlacementSolution solution : solutions) {
                BoardLocation bl = solution.boardLocation;
                Part part = solution.placement.getPart();
                Feeder feeder = solution.feeder;
                Placement placement = solution.placement;
                Nozzle nozzle = solution.nozzle;
                NozzleTip nozzleTip = solution.nozzleTip;
               
                firePartProcessingStarted(solution.boardLocation, solution.placement);
       
                Location placementLocation =
                        Utils2D.calculateBoardPlacementLocation(bl, placement);

        // Update the placementLocation with the proper Z value. This is
        // the distance to the top of the board plus the height of
        // the part.
                Location boardLocation = bl.getLocation().convertToUnits(placementLocation.getUnits());
        double partHeight = part.getHeight().convertToUnits(placementLocation.getUnits()).getValue();
        placementLocation = placementLocation.derive(null, null, boardLocation.getZ() + partHeight, null);

        // NozzleTip Changer
        if (nozzle.getNozzleTip() != nozzleTip) {
              fireDetailedStatusUpdated(String.format("Unload nozzle tip from nozzle %s.", nozzle.getId()));       

              if (!shouldJobProcessingContinue()) {
                  return;
              }
             
                    try {
                        nozzle.unloadNozzleTip();
                    }
                    catch (Exception e) {
                        fireJobEncounteredError(JobError.PickError, e.getMessage());
                        return;
                    }
                   
                    fireDetailedStatusUpdated(String.format("Load nozzle tip %s into nozzle %s.", nozzleTip.getId(), nozzle.getId()));       

                    if (!shouldJobProcessingContinue()) {
                        return;
                    }
                                       
              try {
                      nozzle.loadNozzleTip(nozzleTip);
              }
              catch (Exception e) {
                  fireJobEncounteredError(JobError.PickError, e.getMessage());
                  return;
              }
             
              if (nozzle.getNozzleTip() != nozzleTip) {
                        fireJobEncounteredError(JobError.PickError, "Failed to load correct nozzle tip");
                        return;
              }
        }
        // End NozzleTip Changer
       
        if (!nozzle.getNozzleTip().canHandle(part)) {
                    fireJobEncounteredError(JobError.PickError, "Selected nozzle tip is not compatible with part");
                    return;
        }
       
        pick(nozzle, feeder, bl, placement);
        placementSolutionLocations.put(solution, placementLocation);
      }
       
            // TODO: a lot of the event fires are broken
        for (PlacementSolution solution : solutions) {
                Nozzle nozzle = solution.nozzle;
                BoardLocation bl = solution.boardLocation;
                Placement placement = solution.placement;
                Location placementLocation = placementSolutionLocations.get(solution);
                place(nozzle, bl, placementLocation, placement);
            }
    }
   
View Full Code Here

        while ((solutions = jobPlanner.getNextPlacementSolutions(head)) != null) {
            for (PlacementSolution solution : solutions) {
                BoardLocation bl = solution.boardLocation;
                Part part = solution.placement.getPart();
                Feeder feeder = solution.feeder;
                Placement placement = solution.placement;
                Nozzle nozzle = solution.nozzle;
                NozzleTip nozzleTip = solution.nozzleTip;
     
                if (nozzle == null) {
                    fireJobEncounteredError(JobError.HeadError, "No Nozzle available to service Placement " + placement);
                    return;
                }
       
                if (part == null) {
                    fireJobEncounteredError(JobError.PartError, String.format("Part not found for Board %s, Placement %s", bl.getBoard().getName(), placement.getId()));
                    return;
                }

                if (feeder == null) {
                    fireJobEncounteredError(JobError.FeederError, "No viable Feeders found for Part " + part.getId());
View Full Code Here

          for (PlacementSolution solution : solutions) {
         
          BoardLocation bl = solution.boardLocation;
          Part part = solution.placement.getPart();
          Feeder feeder = solution.feeder;
          Placement placement = solution.placement;
          Nozzle nozzle = solution.nozzle;
          NozzleTip nozzletip = solution.nozzleTip;

          if (nozzle == null) {
                      fireJobEncounteredError(JobError.HeadError, "No Nozzle available to service Placement " + placement);
View Full Code Here

        firePartProcessingStarted(solution.boardLocation, solution.placement);
       
        BoardLocation bl = solution.boardLocation;
        Part part = solution.placement.getPart();
        Feeder feeder = solution.feeder;
        Placement placement = solution.placement;
        Nozzle nozzle = solution.nozzle;
        NozzleTip nozzleTip = solution.nozzleTip;

        // Determine where we will place the part
        Location boardLocation = bl.getLocation();
        Location placementLocation = placement.getLocation();

        // We will work in the units of the placementLocation, so convert
        // anything that isn't in those units to it.
        boardLocation = boardLocation.convertToUnits(placementLocation.getUnits());
       
        // If we are placing the bottom of the board we need to invert
        // the placement location.
        if (bl.getSide() == Side.Bottom) {
          placementLocation = placementLocation.invert(true, false, false, false);
        }

        // Create the point that represents the final placement location
        Point p = new Point(placementLocation.getX(),
            placementLocation.getY());

        // Rotate and translate the point into the same coordinate space
        // as the board
        p = Utils2D.rotateTranslateScalePoint(p, boardLocation
            .getRotation(), boardLocation.getX(), boardLocation
            .getY(), 1.0, 1.0);

        // Update the placementLocation with the transformed point
        placementLocation = placementLocation.derive(p.getX(), p.getY(), null, null);

        // Update the placementLocation with the board's rotation and
        // the placement's rotation
        // This sets the rotation of the part itself when it will be
        // placed
        placementLocation = placementLocation.derive(
                null,
                null,
                null,
                (placementLocation.getRotation() + boardLocation.getRotation()) % 360.0);

        // Update the placementLocation with the proper Z value. This is
        // the distance to the top of the board minus the height of
        // the part.
        double partHeight = part.getHeight().convertToUnits(placementLocation.getUnits()).getValue();
        placementLocation = placementLocation.derive(null, null, boardLocation.getZ() - partHeight, null);


       
                // NozzleTip Changer
                if (nozzle.getNozzleTip() != nozzleTip) {
                    fireDetailedStatusUpdated(String.format("Unload nozzle tip from nozzle %s.", nozzle.getId()));       

                    if (!shouldJobProcessingContinue()) {
                        return;
                    }
                   
                    try {
                        nozzle.unloadNozzleTip();
                    }
                    catch (Exception e) {
                        fireJobEncounteredError(JobError.PickError, e.getMessage());
                        return;
                    }
                   
                    fireDetailedStatusUpdated(String.format("Load nozzle tip %s into nozzle %s.", nozzleTip.getId(), nozzle.getId()));       

                    if (!shouldJobProcessingContinue()) {
                        return;
                    }
                                       
                    try {
                        nozzle.loadNozzleTip(nozzleTip);
                    }
                    catch (Exception e) {
                        fireJobEncounteredError(JobError.PickError, e.getMessage());
                        return;
                    }
                   
                    if (nozzle.getNozzleTip() != nozzleTip) {
                        fireJobEncounteredError(JobError.PickError, "Failed to load correct nozzle tip");
                        return;
                    }
                   
                    try {
                        ((ZippyNozzleTip) nozzleTip).calibrate((ZippyNozzle) nozzle);                   
                    }
                    catch (Exception e) {
                        fireJobEncounteredError(JobError.PickError, e.getMessage());
                        return;
                    }
                }
                // End NozzleTip Changer
               
                if (!nozzle.getNozzleTip().canHandle(part)) {
                    fireJobEncounteredError(JobError.PickError, "Selected nozzle tip is not compatible with part");
                }
               
        pick(nozzle, feeder, bl, placement);
        placementSolutionLocations.put(solution, placementLocation);
      }
       
            // TODO: a lot of the event fires are broken
        for (PlacementSolution solution : solutions) {
                Nozzle nozzle = solution.nozzle;
                BoardLocation bl = solution.boardLocation;
                Placement placement = solution.placement;
                Location placementLocation = placementSolutionLocations.get(solution);
                place(nozzle, bl, placementLocation, placement);
            }
       
    }
View Full Code Here

  }

  @Override
  public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    try {
      Placement placement = board.getPlacements().get(rowIndex);
      if (columnIndex == 1) {
        placement.setPart((Part) aValue);
      }
      else if (columnIndex == 2) {
        placement.setSide((Side) aValue);
      }
      else if (columnIndex == 3) {
        LengthCellValue value = (LengthCellValue) aValue;
        value.setDisplayNativeUnits(true);
        Length length = value.getLength();
        Location location = placement.getLocation();
        location = Length.setLocationField(configuration, location, length, Length.Field.X, true);
        placement.setLocation(location);
      }
      else if (columnIndex == 4) {
        LengthCellValue value = (LengthCellValue) aValue;
        value.setDisplayNativeUnits(true);
        Length length = value.getLength();
        Location location = placement.getLocation();
        location = Length.setLocationField(configuration, location, length, Length.Field.Y, true);
        placement.setLocation(location);
      }
            else if (columnIndex == 5) {
                placement.setLocation(placement.getLocation().derive(null, null, null, Double.parseDouble(aValue.toString())));
            }
            else if (columnIndex == 6) {
                placement.setPlace((Boolean) aValue);
            }
    }
    catch (Exception e) {
      // TODO: dialog, bad input
    }
View Full Code Here

TOP

Related Classes of org.openpnp.model.Placement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.