Ejemplo n.º 1
0
  public ArrayList getClassesRuns() {
    classesRuns = new ArrayList<String>();

    StringBuffer classRun = new StringBuffer();
    StringBuffer testClassRun;

    for (int run = 1; run < 3; run++) {
      for (RaceRun r : getCompletedRunsByClassTime()) {
        if (r.getRunNumber() == run) {
          testClassRun = new StringBuffer();
          testClassRun.append(r.getBoat().getBoatClass());
          testClassRun.append(":");
          testClassRun.append(run);
          testClassRun.append(":");
          testClassRun.append(r.getStatusString());

          if (testClassRun.toString().compareTo(classRun.toString()) != 0) {
            classRun = testClassRun;
            classesRuns.add(classRun.toString());
          }
        }
      }
    }
    return (classesRuns);
  }
Ejemplo n.º 2
0
 public void markClassRun(String boatClass, int runNbr, RaceRun.Status status) {
   for (RaceRun r : getCompletedRunsByClassTime()) {
     if (r.getRunNumber() == runNbr) {
       if (r.getBoat().getBoatClass().compareTo(boatClass) == 0) {
         r.setStatus(status);
       }
     }
   }
   updateResults(true);
 }
Ejemplo n.º 3
0
 public boolean isDNF(String bibNumber, int runNumber) {
   boolean dnf = false;
   for (RaceRun rr : completedRuns) {
     if (rr.getBoat().getRacer().getBibNumber().equals(bibNumber)
         && rr.getRunNumber() == runNumber) {
       if (rr.isDnf()) {
         dnf = true;
       }
     }
   }
   return (dnf);
 }
Ejemplo n.º 4
0
  public void loadSerializedData() {
    // fixme        Race x = loadXML();
    // return;
    // lastRace.getName();
    //        RaceRun run;
    try {
      //          lastRace.loadSerializedData();
      String fileName = lastRace.getName();
      FileInputStream fileIn = new FileInputStream(fileName + ".ser"); // "RaceRun.ser");
      try {
        ObjectInputStream in = new ObjectInputStream(fileIn);
        deSerialize(in);

        in.close();
        fileIn.close();

        tagHeuerConnected = new Boolean(false); // / make sure it exists - transient object
        microgateConnected = new Boolean(false); // / make sure it exists - transient object

      } catch (InvalidClassException ice) {
        log.info("Invalid Class from deserialization " + ice.classname);
      } catch (EOFException eof) {
        log.info("EOF on Serialized data");
      } catch (IOException i) {
        i.printStackTrace();
        // } catch (ClassNotFoundException cnf) {
        //    cnf.printStackTrace();
      } catch (Exception e) {
        e.printStackTrace();
      }
    } catch (FileNotFoundException fnf) {
      // Empty block OK - ignore this exception
    }

    // load required transient members
    Log raceRunLog = Log.getInstance();
    for (RaceRun r : activeRuns) {
      r.setLog(raceRunLog);
    }
    for (RaceRun r : completedRuns) {
      r.setLog(raceRunLog);
    }
    if (pendingRerun != null) {
      pendingRerun.setLog(raceRunLog);
    }

    //     updateResults();   //todo OK Here ???        NO - didn't set

  }
Ejemplo n.º 5
0
  private Result findRacer(RaceRun run) {
    Result result = null;
    for (Result r : results) {
      if (r.getRacer() == run.getBoat().getRacer()) {
        result = r;
        break;
      }
    }

    return result;
  }
Ejemplo n.º 6
0
  private boolean sameRun(RaceRun ourRun, RaceRun otherRun) {
    boolean same = false;
    BoatEntry b;
    Racer racer;
    String bib;
    try {
      b = ourRun.getBoat();
      racer = b.getRacer();
      bib = racer.getBibNumber();

      if (bib.compareTo(otherRun.getBoat().getRacer().getBibNumber()) == 0) {
        if (ourRun.getRunNumber() == otherRun.getRunNumber()) {
          same = true;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    return (same);
  }
Ejemplo n.º 7
0
  private boolean sameRun(RaceRun ourRun, PhotoCellRaceRun otherRun) {
    boolean same = false;
    BoatEntry b;
    Racer racer;
    String bib;
    try {
      b = ourRun.getBoat();
      racer = b.getRacer();
      bib = racer.getBibNumber();

      if (bib.compareTo(otherRun.getBibNumber()) == 0) {
        // We only want to store real time Tag Heuer electronic eye times
        // with the current run
        if (ourRun.getRunNumber() == otherRun.getRunNumber()) {
          same = true;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    return (same);
  }
Ejemplo n.º 8
0
  public void associatePhotoCellRun(PhotoCellRaceRun photoCellRun) {

    RaceRun matchingRun = null;

    for (RaceRun r : activeRuns) {
      try {
        if (sameRun(r, photoCellRun)) {
          matchingRun = r;
          // log.info/*trace*/("Found bib#" + r.getBoat().getRacer().getBibNumber() + " r#"+
          // r.getRunNumber() +  " in Active Runs");

        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    if (matchingRun == null) {
      for (RaceRun r : completedRuns) {
        try {
          if (sameRun(r, photoCellRun)) {
            matchingRun = r;
            //    log.trace("Found bib#" + r.getBoat().getRacer().getBibNumber() + " r#"+
            // r.getRunNumber() + " + in Completed Runs");
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }

    if (matchingRun != null) {
      matchingRun.setPhotoCellRaceRun(
          photoCellRun); /// MUST FIX 2016 Nationals ERROR CONCurrentMpdificationException
    }
  }
Ejemplo n.º 9
0
  public RaceRun getExistingRun(BoatEntry be) { // todo Add Run#
    RaceRun run = null;
    for (RaceRun r : completedRuns) {
      if (r.getRunNumber() == currentRunIteration && r.getBoat() == be) {
        run = r;
        break;
      }
    }

    if (run == null) {
      for (RaceRun r : activeRuns) {
        if (r.getRunNumber() == currentRunIteration && r.getBoat() == be) {
          run = r;
          break;
        }
      }
    }

    return run;
  }
Ejemplo n.º 10
0
  private ArrayList<Result> accumulateResults(ArrayList<RaceRun> runs) {
    Result res;
    results = new ArrayList<Result>();

    for (RaceRun r : runs) {
      res = findRacer(r);
      if (res == null) {
        res = new Result();
        results.add(res);
      }
      res.setRacer(r.getBoat().getRacer());
      res.setBoat(r.getBoat());

      switch (r.getRunNumber()) {
        case 1:
          res.setRun1(r);
          break;
        case 2:
          res.setRun2(r);
          break;
      }
    }

    float run1Time;
    float run2Time;
    for (Result res1 : results) {
      // run1Time = (float)999999.99;
      // run2Time = (float)999999.99;

      try {

        if (res1.getRun1() == null || res1.getRun2() == null) {
          if (res1.getRun1() == null) {
            res1.setBestRun(res1.getRun2());
          }
          if (res1.getRun2() == null) {
            res1.setBestRun(res1.getRun1());
          }
        } else {
          run1Time = res1.getRun1().getElapsed() + res1.getRun1().getTotalPenalties();
          run2Time = res1.getRun2().getElapsed() + res1.getRun2().getTotalPenalties();
          if (run1Time <= run2Time) {
            res1.setBestRun(res1.getRun1());
          } else {
            res1.setBestRun(res1.getRun2());
          }
        }
      } catch (Exception e) {
        log.write(e);
      }
    }

    ArrayList<Result> sorted = Result.getResultsByClassTime(results);
    results = sorted; // A10112013

    String lastBoatClass = "";
    int place = 1;

    for (Result r : sorted) {
      try {
        r.getRun1()
            .setGold(false); // / TODO: if skipping 1st runs fro some reason, this will cause a null
        // pointer reference
        r.getRun1().setSilver(false);
        r.getRun1().setBronze(false);
      } catch (NullPointerException e) {
        // Intentionally empty exception block
      }

      try {
        r.getRun2().setGold(false);
        r.getRun2().setSilver(false);
        r.getRun2().setBronze(false);
      } catch (NullPointerException e) {
        // Intentionally empty exception block
      }

      // todo check this logic   20141122
      try {
        if (lastBoatClass.compareTo(r.getBoat().getBoatClass()) != 0) {
          lastBoatClass = r.getBoat().getBoatClass();
          place = 1;
        }
        switch (place) {
          case 1:
            r.getBestRun().setGold(true);
            break;
          case 2:
            r.getBestRun().setSilver(true);
            break;
          case 3:
            r.getBestRun().setBronze(true);
            break;
          default:
            break;
        }
      } catch (NullPointerException e) {
        // Intentionally empty exception block
      }

      r.getBestRun().setPlaceInClass(place++);
    }
    return (sorted);
  }
Ejemplo n.º 11
0
 public void updateResults(RaceRun run, boolean saveSerialized) {
   updateResults(saveSerialized); // /MUST FIX 2016 Nationals ERROR CONCurrentMpdificationException
   racerResultsHTTP.outputWeb(run.getBoat());
   // M161006    scoreboardResultsHTTP_New.outputWeb("Sorted", getCompletedRunsByClassTime(),
   // true);
 }