Exemplo n.º 1
0
  public Section export() {

    Section section;
    Line line;
    double minValue;
    double maxValue;
    double minSpecifiedValue;
    double maxSpecifiedValue;
    double expectedMaxLatency;
    double expectedMinLatency;
    String sectionName;

    minValue = 0.0;
    maxValue = 0.0;
    minSpecifiedValue = 0.0;
    maxSpecifiedValue = 0.0;

    issues = new ArrayList<ReportedCell>();

    expectedMaxLatency = GetProperties.getMaximumLatencyinMilliSec(this.relatedEndToEndFlow);
    expectedMinLatency = GetProperties.getMinimumLatencyinMilliSec(this.relatedEndToEndFlow);

    if (relatedEndToEndFlow != null) {
      sectionName = relatedEndToEndFlow.getComponentInstancePath();
    } else {
      sectionName = "Unnamed flow";
    }

    section = new Section(sectionName + getSyncLabel());

    line = new Line();
    line.addHeaderContent("Contributor");
    line.addHeaderContent("Min Specified");
    line.addHeaderContent("Min Value");
    line.addHeaderContent("Min Method");
    line.addHeaderContent("Max Specified");
    line.addHeaderContent("Max Value");
    line.addHeaderContent("Max Method");
    line.addHeaderContent("Comments");
    section.addLine(line);

    // will populate the comments section
    minValue = getMinimumActualLatency();
    maxValue = getMaximumActualLatency();
    minSpecifiedValue = getMinimumSpecifiedLatency();
    maxSpecifiedValue = getMaximumSpecifiedLatency();

    // reporting each entry
    for (LatencyContributor lc : this.contributors) {
      if (!skipMeInReport(lc)) {
        for (Line l : lc.export()) {
          section.addLine(l);
        }
      }
    }

    line = new Line();
    line.addContent("Latency Total");
    line.addContent(minSpecifiedValue + "ms");
    line.addContent(minValue + "ms");
    line.addContent("");
    line.addContent(maxSpecifiedValue + "ms");
    line.addContent(maxValue + "ms");
    line.addContent("");
    section.addLine(line);

    line = new Line();
    line.setSeverity(ReportSeverity.SUCCESS);

    line.addContent("End to End Latency");
    line.addContent("");
    line.addContent(expectedMinLatency + "ms");
    line.addContent("");
    line.addContent("");
    line.addContent(expectedMaxLatency + "ms");
    line.addContent("");

    /*
     * In that case, the end to end flow has a minimum latency
     */
    if (expectedMinLatency > 0) {
      if (expectedMinLatency < minSpecifiedValue) {
        reportSummaryWarning(
            "Sum of minimum specified latencies ("
                + minSpecifiedValue
                + " ms) is greater than minimum end to end latency ("
                + expectedMinLatency
                + "ms)");
      }

      if (expectedMinLatency < minValue) {
        reportSummaryError(
            "Sum of minimum actual latencies ("
                + minValue
                + " ms) is greater than minimum end to end latency ("
                + expectedMinLatency
                + "ms)");
      }
    } else {
      reportSummaryWarning("Minimum end to end latency is not pecified or zero");
    }

    /** Here, the max latency value has been defined */
    if (expectedMaxLatency > 0) {
      if (expectedMaxLatency < maxSpecifiedValue) {
        reportSummaryError(
            "Sum of maximum specified latency ("
                + maxSpecifiedValue
                + "ms) exceeds end to end latency ("
                + expectedMaxLatency
                + "ms)");
      }

      if (expectedMaxLatency < maxValue) {
        reportSummaryError(
            "Sum of maximum actual latencies ("
                + maxValue
                + "ms) exceeds end to end latency ("
                + expectedMaxLatency
                + "ms)");
      }
    } else {
      reportSummaryWarning("End to end latency is not specified");
    }

    /**
     * If the expected latency is defined and consistent with the max value, everything should be ok
     * It means that the number calculated from the component is correct and less than the latency
     * specifications. In case of Min latency the actual sum should be higher.
     */
    if ((minValue > 0)
        && (maxValue > 0)
        && (expectedMaxLatency > 0)
        && (expectedMinLatency > 0)
        && (minValue >= expectedMinLatency)
        && (expectedMaxLatency >= maxValue)) {
      reportSummaryInfo(
          "end-to-end flow latency for "
              + this.relatedEndToEndFlow.getName()
              + " calculated from the components is correct with the expected latency specifications");
    }
    section.addLine(line);

    if (issues.size() > 0) {
      line = new Line();
      line.addHeaderContent("End to end Latency Summary");
      section.addLine(line);
      for (ReportedCell issue : issues) {
        line = new Line();
        String msg = issue.getMessage();
        issue.setMessage(issue.getSeverity().toString());
        line.addCell(issue);
        line.addContent(msg);
        section.addLine(line);
      }
    }

    return section;
  }