/* * Copyright (C) 2014 slehuta * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * . */ package rules; import fr.ifremer.isisfish.entities.Metier; import fr.ifremer.isisfish.rule.AbstractRule; import fr.ifremer.isisfish.simulator.SimulationContext; import fr.ifremer.isisfish.types.TimeStep; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.StringUtil; /** * InitContextValues.java * * Created: 9 septembre 2014 * * @author slehuta * @version $Revision: 1545 $ * Last update: $Date: 9 septembre 2014 $ * by : $Author: slehuta $ */ public class InitContext_ScenariosDEFIPEL extends AbstractRule { /** to use log facility, just put in your code: log.info("..."); */ private static Log log = LogFactory.getLog(InitContext_ScenariosDEFIPEL.class); protected String[] necessaryResult = { // put here all necessary result for this rule // example: // ResultName.MATRIX_BIOMASS, // ResultName.MATRIX_NET_VALUE_OF_LANDINGS_PER_STRATEGY_MET, }; public String[] getNecessaryResult() { return this.necessaryResult; } /** * Permet d'afficher a l'utilisateur une aide sur la regle. * @return L'aide ou la description de la regle */ public String getDescription() throws Exception { // TODO return "TODO description rule"; } /** * @param name le nom de l'element a recuperer */ protected void tagToContext(SimulationContext context, String name) throws Exception { if(context.getSimulationStorage().getParameter().getTagValue().get(name) != null){ String valString = context.getSimulationStorage().getParameter().getTagValue().get(name); int valInt = Integer.parseInt(valString); context.setValue(name, valInt); } } /** * Appelé au démarrage de la simulation, cette méthode permet d'initialiser * des valeurs. * * @param context la simulation pour lequel on utilise cette regle */ public void init(SimulationContext context) throws Exception { tagToContext(context,"startingYear"); tagToContext(context,"Scenario_princ"); tagToContext(context,"ScenarioDeb"); tagToContext(context,"Scenario_priceSardine"); tagToContext(context,"Scenario_growthANE"); tagToContext(context,"Scenario_qSardine"); tagToContext(context,"Scenario_qAnchois"); tagToContext(context,"Scenario_nbNav"); tagToContext(context,"Scenario_mnatSardine"); tagToContext(context,"Scenario_recPIL"); tagToContext(context,"Scenario_priceChinch"); tagToContext(context,"Scenario_priceChinchMed"); tagToContext(context,"Scenario_priceMaq"); tagToContext(context,"Scenario_abMAQ"); tagToContext(context,"Scenario_tacMAQ"); tagToContext(context,"Scenario_abHOM"); tagToContext(context,"Scenario_tacHOM"); tagToContext(context,"Scenario_tacHOMHMM"); tagToContext(context,"Scenario_abALB"); tagToContext(context,"Scenario_abBFT"); tagToContext(context,"Scenario_selPIL"); } /** * La condition qui doit etre vrai pour faire les actions. * * @param context la simulation pour lequel on utilise cette regle * @param step le pas de temps courant * @param metier le metier concerné * @return vrai si on souhaite que les actions soit faites */ public boolean condition(SimulationContext context, TimeStep step, Metier metier) throws Exception { // TODO return false; } /** * Si la condition est vrai alors cette action est executee avant le pas * de temps de la simulation. * * @param context la simulation pour lequel on utilise cette regle * @param step le pas de temps courant * @param metier le metier concerné */ public void preAction(SimulationContext context, TimeStep step, Metier metier) throws Exception { // TODO } /** * Si la condition est vrai alors cette action est executée apres le pas * de temps de la simulation. * * @param context La simulation pour lequel on utilise cette regle * @param step le pas de temps courant * @param metier le metier concerné */ public void postAction(SimulationContext context, TimeStep step, Metier metier) throws Exception { // TODO } }