Пример #1
0
  @Override
  public void recordstate(double time, boolean exportflows, int outsteps) throws SiriusException {
    success = false;
    double min = Math.floor(time / 60);
    double hrs = Math.floor(min / 60);
    ts.set(Calendar.HOUR_OF_DAY, (int) hrs);
    ts.set(Calendar.MINUTE, (int) (min - hrs * 60));
    ts.set(Calendar.SECOND, (int) (time - min * 60));
    OutputParameters params =
        new OutputParameters(
            exportflows,
            0 == scenario.clock.getCurrentstep() ? 1 : outsteps,
            scenario.getSimDtInSeconds() * outsteps);

    for (com.relteq.sirius.jaxb.Network network : scenario.getNetworkList().getNetwork()) {
      for (com.relteq.sirius.jaxb.Link link : network.getLinkList().getLink()) {
        Link _link = (Link) link;
        try {
          LinkDataTotal db_ldt = fill_total(_link, params);
          fill_detailed(_link, params, db_ldt.getSpeed());
        } catch (Exception exc) {
          throw new SiriusException(exc);
        } finally {
          _link.reset_cumulative();
        }
      }
    }
    success = true;
  }
Пример #2
0
  /**
   * Fills link_data_total table
   *
   * @param link
   * @param param output parameters
   * @return the stored row
   * @throws Exception
   */
  private LinkDataTotal fill_total(Link link, OutputParameters params) throws Exception {
    LinkDataTotal db_ldt = new LinkDataTotal();
    db_ldt.setLinkId(str2id(link.getId()));
    db_ldt.setNetworkId(str2id(link.myNetwork.getId()));
    db_ldt.setDataSources(db_simulation_run.getDataSources());
    db_ldt.setTs(ts.getTime());
    db_ldt.setAggregation("raw");
    db_ldt.setType("mean");
    db_ldt.setCellNumber(Integer.valueOf(0));
    // mean density, vehicles
    double density = SiriusMath.sum(link.cumulative_density[0]) / params.getNsteps();
    db_ldt.setDensity(BigDecimal.valueOf(density));

    FundamentalDiagram fd = link.currentFD(0);
    if (null != fd) {
      if (params.doExportFlows()) {
        // input flow, vehicles
        db_ldt.setInFlow(BigDecimal.valueOf(SiriusMath.sum(link.cumulative_inflow[0])));
        // output flow, vehicles
        double outflow = SiriusMath.sum(link.cumulative_outflow[0]);
        db_ldt.setOutFlow(BigDecimal.valueOf(outflow));

        // free flow speed, m/s
        BigDecimal ffspeed = fd.getFreeFlowSpeed();
        // speed, m/s
        if (density <= 0) db_ldt.setSpeed(ffspeed);
        else {
          double speed =
              outflow * link.getLength().doubleValue() / (params.getOutputPeriod() * density);
          if (null != ffspeed && speed > ffspeed.doubleValue()) db_ldt.setSpeed(ffspeed);
          else if (!Double.isNaN(speed)) db_ldt.setSpeed(BigDecimal.valueOf(speed));
        }
      }
      // free flow speed, m/s
      db_ldt.setFreeFlowSpeed(fd.getFreeFlowSpeed());
      // critical speed, m/s
      db_ldt.setCriticalSpeed(fd.getCriticalSpeed());
      // congestion wave speed, m/s
      db_ldt.setCongestionWaveSpeed(fd.getCongestionSpeed());
      // maximum flow, vehicles per second per lane
      db_ldt.setCapacity(fd.getCapacity());
      // jam density, vehicles per meter per lane
      db_ldt.setJamDensity(fd.getJamDensity());
      // capacity drop, vehicle per second per lane
      db_ldt.setCapacityDrop(fd.getCapacityDrop());
    }
    db_ldt.save();
    return db_ldt;
  }