public byte[] filter(String filter, Map<String, String> header) {
    String inHost = header.get("host");
    String hostIP;
    int pos0 = inHost.lastIndexOf(":");
    if (pos0 > 0) {
      hostIP = inHost.substring(0, pos0);
    } else {
      hostIP = inHost;
    }
    log.info("preforming the following substitutions for myrobotlab.html");
    // log.info("from client @ {}", socket.getRemoteSocketAddress());
    log.info("<%=getHostAddress%> --> {}", hostIP);
    filter = filter.replace("<%=getHostAddress%>", hostIP);
    log.info("<%=wsPort%> --> {}", webgui.port);
    filter = filter.replace("<%=wsPort%>", webgui.port.toString());
    log.info("<%=runtimeName%> --> {}", Runtime.getInstance().getName());
    filter = filter.replace("<%=runtimeName%>", Runtime.getInstance().getName());
    log.info("<%=webguiName%> --> {}", webgui.getName());
    filter = filter.replace("<%=webguiName%>", webgui.getName());
    log.info("<%=httpPort%> --> {}", webgui.port.toString());
    filter = filter.replace("<%=httpPort%>", webgui.port.toString());
    // filter.replace(, newChar);

    if (webgui.useLocalResources()) {
      filter = filter.replace("<%=mrl.script.location%>", "");
    } else {
      filter =
          filter.replace(
              "<%=mrl.script.location%>",
              "http://myrobotlab.googlecode.com/svn/trunk/myrobotlab/src/resource/WebGUI/");
    }
    return filter.getBytes();
  }
示例#2
0
  public MainTest() {

    // make and start an Arduino
    Arduino arduino = new Arduino("arduino");
    arduino.startService();
    // connect default 8 N 1 to serial device
    arduino.connect("/dev/ttyACM0");
    // arduino.connect("COM10");
    // arduino.setBoard("diecimila");
    arduino.connect();

    // make and start a Proxy
    Proxy proxy = new Proxy("myApp");
    proxy.startService();

    // add this class so it can receive any messages sent to it
    proxy.addMessageListener(this);

    // subscribe to the methods/messages we are interested in
    // arduino.publishPin(Pin) --- is sent to us with msg.method name = "ourData"
    proxy.subscribe("publishPin", arduino.getName(), "ourData", Pin.class);
    arduino.digitalWrite(13, 1);

    // start a gui if you want
    /*
    GUIService gui = new GUIService("gui");
    gui.startService();
    */

    while (cnt < 100) {
      ++cnt;
      try {

        // ################# Works Now ;)
        // ###################
        for (Pin p : arduino.getPinList()) {
          System.out.print(p.value + " ");
        }
        System.out.println();
        arduino.digitalWrite(13, 1); // turn on LED
        arduino.digitalWrite(9, 0); // turn on LED
        Thread.sleep(500);
        arduino.digitalWrite(8, 0); // turn on LED
        arduino.digitalWrite(9, 1); // turn on LED
        Thread.sleep(500);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    // when you are done
    Runtime.releaseAll();
  }
示例#3
0
  @Override
  public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    // parent.getSelectedComponent()
    if (boundServiceName.equals(getText())) {
      // Service Frame
      ServiceInterface sw = Runtime.getService(getText());
      if ("info".equals(cmd)) {
        BareBonesBrowserLaunch.openURL("http://myrobotlab.org/service/" + sw.getSimpleName());

      } else if ("detach".equals(cmd)) {
        undockPanel();
      } else if ("release".equals(cmd)) {
        myService.send(Runtime.getInstance().getName(), "releaseService", boundServiceName);
      } else if ("prevent export".equals(cmd)) {
        myService.send(boundServiceName, "allowExport", false);
        allowExportMenuItem.setIcon(Util.getImageIcon("allowExport.png"));
        allowExportMenuItem.setActionCommand("allow export");
        allowExportMenuItem.setText("allow export");
      } else if ("allow export".equals(cmd)) {
        myService.send(boundServiceName, "allowExport", true);
        allowExportMenuItem.setIcon(Util.getImageIcon("preventExport.png"));
        allowExportMenuItem.setActionCommand("prevent export");
        allowExportMenuItem.setText("prevent export");
      }
    } else {
      // Sub Tabbed sub pane
      ServiceInterface sw = Runtime.getService(boundServiceName);
      if ("info".equals(cmd)) {
        BareBonesBrowserLaunch.openURL(
            "http://myrobotlab.org/service/" + sw.getSimpleName() + "#" + getText());

      } else if ("detach".equals(cmd)) {
        undockPanel();
      }
    }
  }