示例#1
0
文件: Main.java 项目: openpnp/openpnp
  public static void main(String[] args) {
    // http://developer.apple.com/library/mac/#documentation/Java/Conceptual/Java14Development/07-NativePlatformIntegration/NativePlatformIntegration.html#//apple_ref/doc/uid/TP40001909-212952-TPXREF134
    System.setProperty("apple.laf.useScreenMenuBar", "true");
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
      throw new Error(e);
    }

    File configurationDirectory = new File(System.getProperty("user.home"));
    configurationDirectory = new File(configurationDirectory, ".openpnp");

    if (System.getProperty("configDir") != null) {
      configurationDirectory = new File(System.getProperty("configDir"));
    }

    configurationDirectory.mkdirs();

    configureLogging(configurationDirectory);

    Configuration.initialize(configurationDirectory);
    final Configuration configuration = Configuration.get();
    EventQueue.invokeLater(
        new Runnable() {
          public void run() {
            try {
              MainFrame frame = new MainFrame(configuration);
              frame.setVisible(true);
              Logger.debug(
                  String.format(
                      "Bienvenue, Wilkommen, Hello, Namaskar, Welkom to OpenPnP version %s.",
                      Main.getVersion()));
              configuration.getScripting().on("Startup", null);
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });
  }
示例#2
0
  /**
   * Creates a basic job in memory and attempts to run it. The Driver is monitored to make sure it
   * performs a pre-defined set of expected moves. This test is intended to test the primary motions
   * and operation of the entire system, including feeding, picking, placing and basic job
   * processing.
   *
   * <p>TODO: Don't ignore additional movements after the expected movements complete. This should
   * cause the test to fail and it does not currently.
   *
   * @throws Exception
   */
  @Test
  public void testSimpleJob() throws Exception {
    File workingDirectory = Files.createTempDir();
    workingDirectory = new File(workingDirectory, ".openpnp");
    System.out.println("Configuration directory: " + workingDirectory);

    // Copy the required configuration files over to the new configuration
    // directory.
    FileUtils.copyURLToFile(
        ClassLoader.getSystemResource("config/BasicJobTest/machine.xml"),
        new File(workingDirectory, "machine.xml"));
    FileUtils.copyURLToFile(
        ClassLoader.getSystemResource("config/BasicJobTest/packages.xml"),
        new File(workingDirectory, "packages.xml"));
    FileUtils.copyURLToFile(
        ClassLoader.getSystemResource("config/BasicJobTest/parts.xml"),
        new File(workingDirectory, "parts.xml"));

    Configuration.initialize(workingDirectory);
    Configuration.get().load();

    Machine machine = Configuration.get().getMachine();
    ReferenceMachine referenceMachine = (ReferenceMachine) machine;
    TestDriver testDriver = (TestDriver) referenceMachine.getDriver();
    BasicJobTestDriverDelegate delegate = new BasicJobTestDriverDelegate();
    testDriver.setDelegate(delegate);

    Job job = createSimpleJob();

    Head h1 = machine.getHead("H1");
    Nozzle n1 = h1.getNozzle("N1");
    Nozzle n2 = h1.getNozzle("N2");

    delegate.expectMove(
        "Move N1 Nozzle Change Unload", n1, new Location(LengthUnit.Millimeters, 40, 0, 0, 0), 1.0);
    delegate.expectMove(
        "Move N1 Nozzle Change Load", n1, new Location(LengthUnit.Millimeters, 50, 0, 0, 0), 1.0);

    delegate.expectMove(
        "Move N1 to F1", n1, new Location(LengthUnit.Millimeters, -10, 0, 0, 0), 1.0);
    delegate.expectPick(n1);

    delegate.expectMove(
        "Move N2 to F1", n2, new Location(LengthUnit.Millimeters, -20, 0, 0, 0), 1.0);
    delegate.expectPick(n2);

    delegate.expectMove(
        "Move N1 to R1, Safe-Z", n1, new Location(LengthUnit.Millimeters, 0, 10, 0, 45), 1.0);
    delegate.expectMove(
        "Move N1 to R1, Z", n1, new Location(LengthUnit.Millimeters, 0, 10, 0.825500, 45), 1.0);
    delegate.expectPlace(n1);
    delegate.expectMove(
        "Move N1 to R1, Safe-Z", n1, new Location(LengthUnit.Millimeters, 0, 10, 0, 45), 1.0);

    delegate.expectMove(
        "Move N2 to R2, Safe-Z", n2, new Location(LengthUnit.Millimeters, 00, 20, 0, 90), 1.0);
    delegate.expectMove(
        "Move N2 to R2, Z", n2, new Location(LengthUnit.Millimeters, 00, 20, 0.825500, 90), 1.0);
    delegate.expectPlace(n2);
    delegate.expectMove(
        "Move N2 to R2, Safe-Z", n2, new Location(LengthUnit.Millimeters, 00, 20, 0, 90), 1.0);

    JobProcessor jobProcessor = machine.getPnpJobProcessor();
    machine.setEnabled(true);
    jobProcessor.initialize(job);
    while (jobProcessor.next()) ;
  }