Exemplo n.º 1
0
  /**
   * Execute the commnad and returns how many rows of commandEva the command had.
   *
   * <p>that : the environment where the command is called commandEva : the whole command Eva
   * indxCommandEva : index of commandEva where the commnad starts
   */
  public int execute(listix that, Eva commandEva, int indxComm) {
    listixCmdStruct cmd = new listixCmdStruct(that, commandEva, indxComm);

    String[] aa = cmd.getArgs(true);
    if (aa.length > 0) aa[0] = org.gastona.commonGastona.getGastConformFileName(aa[0]);

    String[] arrComanda = new String[aa.length + 4];
    arrComanda[0] = System.getProperty("java.home", "") + "/bin/java";
    arrComanda[1] = "-cp";
    arrComanda[2] = System.getProperty("java.class.path", ".");
    arrComanda[3] = "gastona.gastona";
    for (int ii = 0; ii < aa.length; ii++) arrComanda[4 + ii] = aa[ii];

    // copy parameters
    // java -cp classpath gastona.gastona script.gast pa1 pa2
    //

    cmd.getLog().dbg(2, "GAST", "passed parameters " + cmd.getArgSize());

    // for (int ii = 0; ii < arrComanda.length; ii ++)
    //    System.out.println (arrComanda[ii]);
    javaRun.launch(arrComanda);

    cmd.checkRemainingOptions(true);
    return 1;
  }
Exemplo n.º 2
0
  /**
   * Execute the commnad and returns how many rows of commandEva the command had.
   *
   * <p>that : the environment where the command is called commandEva : the whole command Eva
   * indxCommandEva : index of commandEva where the commnad starts
   */
  public int execute(listix that, Eva commands, int indxComm) {
    listixCmdStruct cmd = new listixCmdStruct(that, commands, indxComm);

    String oper = cmd.getArg(0);
    String msgName = cmd.getArg(1);
    int nTimesLeft = stdlib.atoi(cmd.getArg(2));
    int intervalSec = stdlib.atoi(cmd.getArg(3));
    int meters = stdlib.atoi(cmd.getArg(4));

    // ... String  customFile = cmd.takeOptionString(new String [] { "FROMFILE", "FILE" }, "" );

    // ... startLine = stdlib.atoi (cmd.takeOptionString(new String [] {"STARTLINE", "START",
    // "BEGIN", "BEGINLINE" }, "1"));

    cmd.getLog().dbg(2, "GPS", "operation [" + oper + "]");
    System.out.println("TESCUCHO...");

    if (oper.equalsIgnoreCase("GET POSITION")) {
      System.out.println("OK! programo para " + intervalSec + "segundos y tiempo " + nTimesLeft);

      LocationManager locMan =
          (LocationManager)
              androidSysUtil.getMainAppContext().getSystemService(Context.LOCATION_SERVICE);

      GPSListener lis = new GPSListener(msgName, nTimesLeft, locMan);

      locMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, intervalSec * 1000, meters, lis);

      /*
               Location loca = mlocManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
               if (loca != null)
                  lis.onLocationChanged (loca);
               else
               {
                  cmd.getLog().dbg (2, "GET POSITION cannot obtain last location");
                  lis.sendPosition (0., 0.);
               }
      */
    } else {
      cmd.getLog().err("GPS", "Operation [" + oper + "] unknown");
    }

    cmd.checkRemainingOptions(true);
    return 1;
  }