Package eas.plugins.standard.eaPlugin

Source Code of eas.plugins.standard.eaPlugin.ZusatzinfoPlugin

/*
* File name:        ZusatzinfoPlugin.java (package eas.plugins.standard.ea)
* Author(s):        Lukas König
* Java version:     6.0
* Generation date:  12.08.2011 (13:38:26)
*
* (c) This file and the EAS (Easy Agent Simulation) framework containing it
* is protected by Creative Commons by-nc-sa license. Any altered or
* further developed versions of this file have to meet the agreements
* stated by the license conditions.
*
* In a nutshell
* -------------
* You are free:
* - to Share -- to copy, distribute and transmit the work
* - to Remix -- to adapt the work
*
* Under the following conditions:
* - Attribution -- You must attribute the work in the manner specified by the
*   author or licensor (but not in any way that suggests that they endorse
*   you or your use of the work).
* - Noncommercial -- You may not use this work for commercial purposes.
* - Share Alike -- If you alter, transform, or build upon this work, you may
*   distribute the resulting work only under the same or a similar license to
*   this one.
*
* + Detailed license conditions (Germany):
*   http://creativecommons.org/licenses/by-nc-sa/3.0/de/
* + Detailed license conditions (unported):
*   http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en
*
* This header must be placed in the beginning of any version of this file.
*/

package eas.plugins.standard.eaPlugin;

import java.util.LinkedList;
import java.util.List;

import eas.miscellaneous.StaticMethods;
import eas.plugins.AbstractDefaultPlugin;
import eas.plugins.standard.eaPlugin.xmlRecording.XMLAufnahmePlugin;
import eas.simulation.Wink;
import eas.simulation.event.EASEvent;
import eas.simulation.spatial.sim2D.marbSimulation.EnvironmentEA;
import eas.simulation.spatial.sim2D.marbSimulation.endlAutomat.GlobaleMARBVariablen;
import eas.startSetup.ParCollection;
import eas.startSetup.SingleParameter;
import eas.startSetup.parameterDatatypes.Datatypes;

/**
* @author Lukas König
*
*/
public class ZusatzinfoPlugin extends AbstractDefaultPlugin<EnvironmentEA> {

    /**
     *
     */
    private static final long serialVersionUID = -5130881404413350233L;

    private ParCollection pars;
   
    private long intervall;
   
    @Override
    public List<String> getRequiredPlugins() {
        LinkedList<String> list = new LinkedList<String>();
        list.add(new XMLAufnahmePlugin().id());
        return list;
    }

    @Override
    public List<SingleParameter> getParameters() {
        LinkedList<SingleParameter> liste = new LinkedList<SingleParameter>();
        liste.add(new SingleParameter(
                "ZusatzInfoIntervall",
                Datatypes.LONG,
                100l,
                "Speichert die Zusatzinformationen in diesem Intervall.",
                this.id().toUpperCase()));
        return liste;
    }

    @Override
    public String id() {
        return "Zusatz_Info_Plugin";
    }

    @Override
    public void runBeforeSimulation(EnvironmentEA env, ParCollection params) {
        this.pars = params;
        this.intervall = this.pars.getParValueLong("ZusatzInfoIntervall");
        this.zusatzListe = new LinkedList<String>();
        StaticMethods.logOutput(this.id().toUpperCase() + " -- initialisiert.", params);
    }

    @Override
    public void runAfterSimulation(EnvironmentEA env, ParCollection params) {
        StaticMethods.logOutput(this.id().toUpperCase() + " -- beendet.", params);
    }

    private LinkedList<String> zusatzListe;
   
    @Override
    public void runDuringSimulation(
            EnvironmentEA env,
            Wink simZyk,
            ParCollection params) {
        if (simZyk.getLastTick() % this.intervall == this.intervall - 1) {
            this.zusatzListe.add(GlobaleMARBVariablen.getGateCount() + ";"
                    + GlobaleMARBVariablen.getCollCount() + ";"
                    + GlobaleMARBVariablen.getRichtigeDrehRicht());
            GlobaleMARBVariablen.setCollCount(0);
            GlobaleMARBVariablen.setGateCount(0);
            GlobaleMARBVariablen.setRichtigeDrehRicht(0);
           
            try {
                StaticMethods.speichereTextAusArray(
                        params.getStdDirectory(),
                        params.getParValueString("xmlaufnahmedatei") + "-zusatz.txt",
                        this.zusatzListe,
                        params);
            } catch (Exception e) {
                StaticMethods.logInfo(
                    "Fehler beim Speichern der Datei: " + e.getMessage(),
                    params);
            }
        }
    }

    @Override
    public void handleEvent(
            EASEvent e,
            EnvironmentEA env,
            Wink lastTimeStep,
            ParCollection params) {
        StaticMethods.logWarning(this.id().toUpperCase() + " -- kann nicht auf Events reagieren (" + e + ").", params);
    }

    @Override
    public List<String> getSupportedPlugins() {
        return null;
    }

    @Override
    public void onSimulationResumed(EnvironmentEA env, Wink resumeTime,
            ParCollection params) {
       
    }
}
TOP

Related Classes of eas.plugins.standard.eaPlugin.ZusatzinfoPlugin

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.