コード例 #1
0
  /** Composes and submits the appropriate order for the given timeslot. */
  private void submitOrder(double neededKWh, int timeslot) {
    double neededMWh = neededKWh / 1000.0;

    MarketPosition posn = broker.getBroker().findMarketPositionByTimeslot(timeslot);
    if (posn != null) neededMWh -= posn.getOverallBalance();
    if (Math.abs(neededMWh) <= minMWh) {
      log.info("no power required in timeslot " + timeslot);
      return;
    }
    Double limitPrice = computeLimitPrice(timeslot, neededMWh);
    log.info("new order for " + neededMWh + " at " + limitPrice + " in timeslot " + timeslot);
    Order order = new Order(broker.getBroker(), timeslot, neededMWh, limitPrice);
    lastOrder.put(timeslot, order);
    broker.sendMessage(order);
  }
コード例 #2
0
 /** Receives a MarketPosition message, representing our commitments on the wholesale market */
 public synchronized void handleMessage(MarketPosition posn) {
   broker.getBroker().addMarketPosition(posn, posn.getTimeslotIndex());
 }