EMlab-generation Documentation  1.0
Documentation of the EMLab-Generation model.
ProcessAcceptedPowerPlantDispatchRole.java
1 /*******************************************************************************
2  * Copyright 2012 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 package emlab.gen.role.market;
17 
18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.transaction.annotation.Transactional;
20 
21 import agentspring.role.Role;
22 import agentspring.role.RoleComponent;
29 
30 @RoleComponent
31 public class ProcessAcceptedPowerPlantDispatchRole extends AbstractMarketRole<ElectricitySpotMarket> implements Role<ElectricitySpotMarket> {
32 
33  @Autowired
34  Reps reps;
35 
36  @Override
37  @Transactional
38  public void act(ElectricitySpotMarket esm) {
39 
40  for (Segment segment : reps.segmentRepository.findAll()) {
41  SegmentClearingPoint scp = reps.segmentClearingPointRepository.findOneSegmentClearingPointForMarketSegmentAndTime(
42  getCurrentTick(), segment, esm, false);
43  for (PowerPlantDispatchPlan plan : reps.powerPlantDispatchPlanRepository
44  .findAllAcceptedPowerPlantDispatchPlansForMarketSegmentAndTime(esm, segment, getCurrentTick(),
45  false)) {
46 
47  reps.nonTransactionalCreateRepository.createCashFlow(esm, plan.getBidder(), plan.getAcceptedAmount() * scp.getPrice()
48  * segment.getLengthInHours(), CashFlow.ELECTRICITY_SPOT, getCurrentTick(), plan.getPowerPlant());
49  }
50 
51  }
52 
53  }
54 
55  @Override
56  public Reps getReps() {
57  return reps;
58  }
59 
60 }