Example #1
0
  public DeathInfo(Robot robot) {

    // Initialize data members
    timeOfDeath = Simulation.instance().getMasterClock().getMarsClock().getDateTimeStamp();
    /*
            Complaint serious = person.getPhysicalCondition().getMostSerious();
            if (serious != null) illness = serious.getName();

            if (person.getLocationSituation() == LocationSituation.OUTSIDE) placeOfDeath = "Outside";
            else {
                containerUnit = person.getContainerUnit();
                placeOfDeath = containerUnit.getName();
            }

            locationOfDeath = person.getCoordinates();
    */
    BotMind botMind = robot.getBotMind();

    robotJob = botMind.getRobotJob();
    /*
            if (mind.getMission() != null) {
                mission = mind.getMission().getName();
                missionPhase = mind.getMission().getPhaseDescription();
            }
    */
    TaskManager taskMgr = botMind.getTaskManager();
    if (taskMgr.hasTask()) {
      task = taskMgr.getTaskName();
      TaskPhase phase = taskMgr.getPhase();
      if (phase != null) {
        taskPhase = phase.getName();
      } else {
        taskPhase = "";
      }
    }

    Iterator<Malfunctionable> i = MalfunctionFactory.getMalfunctionables(robot).iterator();
    Malfunction mostSerious = null;
    int severity = 0;
    while (i.hasNext()) {
      Malfunctionable entity = i.next();
      MalfunctionManager malfunctionMgr = entity.getMalfunctionManager();
      if (malfunctionMgr.hasEmergencyMalfunction()) {
        Malfunction m = malfunctionMgr.getMostSeriousEmergencyMalfunction();
        if (m.getSeverity() > severity) {
          mostSerious = m;
          severity = m.getSeverity();
        }
      }
    }
    if (mostSerious != null) malfunction = mostSerious.getName();

    this.robotType = robot.getRobotType();
  }