Пример #1
0
  /*compute the initial Time outs for all equipments */
  private void computeInitialTimes() {
    System.out.println("t0 is" + t0);
    double timeDiff = 0;

    /*Times for available equipment will depend on the type and position in queue as it's FIFO */
    generateRandomOrderTimes();

    /*for equipment on rent, it's simply at the end of the rental period */
    for (Equipment e : rentEquipment) {
      e.timeIn = System.currentTimeMillis() - t0;
      timeDiff = nextRandomTime(RENTALFREQUENCY[e.type - 1]);
      e.timeOut = System.currentTimeMillis() + timeDiff - t0;
      System.out.println("I am in state " + e.state + " and order " + rentEquipment.indexOf(e));
      System.out.println(
          "My time in is "
              + e.timeIn
              + " And my time out is "
              + e.timeOut
              + " and the difference between the 2 is "
              + (e.timeOut - e.timeIn));
      /*System.out.println("and nextRandomTime returns" + nextRandomTime(e.timeIn,RENTALFREQUENCY[e.type-1]) +" for type "+e.type+" for RentalFrequency "+RENTALFREQUENCY[e.type-1]);
      System.out.println("For equipment in state "+e.state+" and order "+rentEquipment.indexOf(e)+" : inter-arrival is "+(e.timeOut-e.timeIn)); */
    }

    /*for equipment in the shop, it's simply at the end of the rental period */
    for (Equipment e : shopEquipment) {
      e.timeIn = System.currentTimeMillis() - t0;
      timeDiff = nextRandomTime(SHOPFREQUENCY[e.type - 1]);
      e.timeOut = System.currentTimeMillis() + timeDiff - t0;
      System.out.println("I am in state " + e.state + " and order " + shopEquipment.indexOf(e));
      System.out.println(
          "My time in is "
              + e.timeIn
              + " And my time out is "
              + e.timeOut
              + " and the difference between the 2 is "
              + (e.timeOut - e.timeIn));
      /*System.out.println("For equipment in state "+e.state+" and order "+shopEquipment.indexOf(e)+" : inter-arrival is "+(e.timeOut-e.timeIn)); */
    }
  }