Package remote.motecontrol.client

Examples of remote.motecontrol.client.SimpleMoteManager


    this.connect();
  }

  private Session getSession() {
    if (session == null) {
      SimpleMoteManager mm = new SimpleMoteManager();
      session = new Session(mm);
      session.addSessionListener(this);
    }
    return session;
  }
View Full Code Here


            int i;
            String cmd = e.getActionCommand();
            SortedTreeNode[] nodes = getSelectedNodes(jTree);
            TableRow[] rows = getLeafValues(nodes);
            long[] motes = getMoteIds(rows);
            SimpleMoteManager moteManager = (SimpleMoteManager) session
                .getMoteManager();
            if (cmd.equals("release")) {
              moteManager.releaseMotes(motes);

            } else if (cmd.equals("console")) {
              for (i = 0; i < rows.length; i++) {
                getMoteView((MoteControlRow) rows[i]);
              }
            } else if (cmd.equals("program")) {
              java.util.Properties settings = getSettings();
              try {
                JFileChooser fc = new JFileChooser(settings
                    .getProperty("flashImagePath", "/"));
                fc.setFileFilter(new FlashImageFilter());
                int returnVal = fc
                    .showOpenDialog(getRootWindow());

                if (returnVal == JFileChooser.APPROVE_OPTION) {
                  File file = fc.getSelectedFile();
                  FileInputStream fi = new FileInputStream(
                      file);
                  byte[] bytes = new byte[(int) file.length()];
                  fi.read(bytes);
                  moteManager.program(motes, bytes);
                  fi.close();
                  settings.setProperty("flashImagePath", file
                      .getParent());
                  saveSettings();
                }
              } catch (Exception ex) {
                ex.printStackTrace();
              }
            } else if (cmd.equals("start")) {
              moteManager.start(motes);
            } else if (cmd.equals("stop")) {
              moteManager.stop(motes);
            } else if (cmd.equals("reset")) {
              moteManager.reset(motes);
            }
          }

        };
View Full Code Here

        ActionListener actionListener = new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            Properties settings = getSettings();
            SimpleMoteManager moteManager = (SimpleMoteManager) getSession()
                .getMoteManager();
            try {
              String cmd = e.getActionCommand();
              if (cmd.equals("program")) {
                JFileChooser fc = new JFileChooser(settings
                    .getProperty("flashImagePath", "/"));
                fc.setFileFilter(new FlashImageFilter());
                int returnVal = fc
                    .showOpenDialog(getRootWindow());

                if (returnVal == JFileChooser.APPROVE_OPTION) {
                  File file = fc.getSelectedFile();
                  FileInputStream fi = new FileInputStream(
                      file);
                  byte[] image = new byte[(int) file.length()];
                  fi.read(image);
                  moteManager.program(moteid, image);
                  fi.close();
                  settings.setProperty("flashImagePath", file
                      .getParent());
                  saveSettings();
                }
              } else if (cmd.equals("cancelprogram")) {
                moteManager.cancelProgramming(moteid);
              } else if (cmd.equals("start")) {
                moteManager.start(moteid);
              } else if (cmd.equals("stop")) {
                moteManager.stop(moteid);
              } else if (cmd.equals("reset")) {
                moteManager.reset(moteid);
              } else if (cmd.equals("clear")) {
                console.clear();
              } else if (cmd.equals("log_local")) {
                JFileChooser fc = new JFileChooser(settings.getProperty("moteLogPath", "/"));
                if (fc.showSaveDialog(getRootWindow()) == JFileChooser.APPROVE_OPTION) {
View Full Code Here

TOP

Related Classes of remote.motecontrol.client.SimpleMoteManager

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.