EMlab-generation Documentation  1.0
Documentation of the EMLab-Generation model.
PayCO2TaxRole.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;
28 import emlab.gen.role.AbstractEnergyProducerRole;
29 
37 @RoleComponent
38 public class PayCO2TaxRole extends AbstractEnergyProducerRole implements Role<EnergyProducer> {
39 
40  @Autowired
41  Reps reps;
42 
43  public Reps getReps() {
44  return reps;
45  }
46 
47  @Override
48  @Transactional
49  public void act(EnergyProducer producer) {
50  logger.info("Pay the CO2 tax");
51 
52  Government government = reps.genericRepository.findFirst(Government.class);
53 
54  for (PowerPlant plant : reps.powerPlantRepository.findOperationalPowerPlantsByOwner(producer, getCurrentTick())) {
55  double money = calculateCO2Tax(plant, false, getCurrentTick());
56  CashFlow cf = reps.nonTransactionalCreateRepository.createCashFlow(producer, government, money, CashFlow.CO2TAX, getCurrentTick(), plant);
57  logger.info("Cash flow created: {}", cf);
58  }
59  }
60 
61 }
Iterable< PowerPlant > findOperationalPowerPlantsByOwner(@Param("owner") EnergyProducer owner,@Param("tick") long tick)