EMlab-generation Documentation  1.0
Documentation of the EMLab-Generation model.
PayOperatingAndMaintainanceCostsRole.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.operating;
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 import emlab.gen.role.AbstractEnergyProducerRole;
30 
38 @RoleComponent
39 public class PayOperatingAndMaintainanceCostsRole extends AbstractEnergyProducerRole implements Role<EnergyProducer> {
40 
41  @Autowired
42  Reps reps;
43 
44  public Reps getReps() {
45  return reps;
46  }
47 
48  @Transactional
49  public void act(EnergyProducer producer) {
50  logger.info("Pay the Operating and Maintainance cost tax");
51 
52  PowerPlantMaintainer maintainer = reps.genericRepository.findFirst(PowerPlantMaintainer.class);
53  int i = 0;
54  for (PowerPlant plant : reps.powerPlantRepository.findOperationalPowerPlantsByOwner(producer, getCurrentTick())) {
55  i++;
56  double money = plant.getActualFixedOperatingCost();
57  // TODO calculate actual based on modifier.
58  logger.info("Im paying {} for O and M of plant {}", money, plant.getName());
59  reps.nonTransactionalCreateRepository.createCashFlow(producer, maintainer, money, CashFlow.FIXEDOMCOST, getCurrentTick(), plant);
60  }
61  logger.info("I: {} have paid for {} plants ", producer, i);
62  }
63 }
Iterable< PowerPlant > findOperationalPowerPlantsByOwner(@Param("owner") EnergyProducer owner,@Param("tick") long tick)