Class FWSimOutputAdapter

java.lang.Object
net.simplace.sim.io.FWSimIOAdapter
net.simplace.sim.io.output.FWSimOutputAdapter
All Implemented Interfaces:
FWSimFieldContainer
Direct Known Subclasses:
CacheOutputAdapter, CSVOutputAdapter, DatabaseOutputAdapter, NetCDFOutputAdapter

public abstract class FWSimOutputAdapter extends FWSimIOAdapter
Abstract implementation for the IO-Adapter for only writing output data This abstract implementation is FWSimIOAdapter. It additionally implements a blocking queue ArrayBlockingQueue that makes it possible to divide the model output from writing the output to the different interfaces. Cache size is the number of elements that can be cached in the queue before the queue will also stop to take elements from the model output. !!IMPORTANT!! Before finalizing the application it has to be checked, if all output is written to the FWSimInterfaces resp. the blocking queue is empty. reads general information from the xml-structure given as
Author:
Andreas Enders
  • Field Details

    • iQueue

      Queue that temporarily stores output data until the writer is accessible
    • iCacheSize

      protected int iCacheSize
      size of the temporary output cache
  • Constructor Details

    • FWSimOutputAdapter

      protected FWSimOutputAdapter(org.jdom2.Element aOutputElement, int aOrderNumber, FWSimVarMap aVarMap)
      should be called from implementations while constructing.
      Parameters:
      aOutputElement -
      aOrderNumber -
      aVarMap -
    • FWSimOutputAdapter

      protected FWSimOutputAdapter(FWSimOutputAdapter aOutputAdapter, FWSimInterface<?> aInterface)
      should be called from implementations while constructing an updated adapter.
      Parameters:
      aOutputAdapter -
      aInterface -
    • FWSimOutputAdapter

      public FWSimOutputAdapter(String aName, org.jdom2.Element aOutputElement, FWSimInterface<?> aInterface, FWSimIOAdapter.FREQUENCE aFrequence, int aOrderNumber, String aCacheSize, ProcessTime aProcessTime, FWSimSession aSession)
      called from the graph panel while creating output adaptor.
      Parameters:
      aName -
      aOutputElement -
      aInterface -
      aFrequence -
      aOrderNumber -
      aCacheSize -
      aProcessTime -
      aSession -
      aVarMap -
  • Method Details

    • initialize

      public void initialize(FWSimVarMap aVarMap)
      Parameters:
      aVarMap -
    • init

      protected abstract void init(FWSimVarMap aVarMap)
      Parameters:
      aVarMap -
    • receiveData

      public void receiveData(FWSimQueueObjectMap aQueueObjectMap)
      Outputter should write the data to this method - writing is done automatically in another thread.
      Parameters:
      aQueueObjectMap -
    • writeData

      public void writeData()
      method called by different thread actually writing the data to the given media in SimInterface
    • writeData

      protected abstract void writeData(FWSimQueueObjectMap aObjectToWrite)
      writes data to the interface - has to be implemented for each adapter individually
      Parameters:
      aSimulationID -
      aObjectToWrite -
    • createAdapter

      public static FWSimOutputAdapter createAdapter(org.jdom2.Element aOutputElement, int aOrderNumber, FWSimVarMap aVarMap) throws MissingSimResourceException
      Parameters:
      aOutputElement -
      aOrderNumber -
      aVarMap -
      Returns:
      the output Adapter to be created
      Throws:
      MissingSimResourceException
    • updateAdapter

      public static FWSimOutputAdapter updateAdapter(FWSimOutputAdapter aAdapter, FWSimInterface<?> aInterface) throws MissingSimResourceException
      Parameters:
      aAdapter -
      aInterface -
      Returns:
      updated FWSimOutputAdapter
      Throws:
      MissingSimResourceException
    • createOutputFromObservable

      public static FWSimOutputAdapter createOutputFromObservable(FWObservable aObservable, int aOrderNumber) throws MissingSimResourceException
      Parameters:
      aObservable -
      aOrderNumber -
      Returns:
      the output Adapter to be created
      Throws:
      MissingSimResourceException
    • getOutputVariables

      public Collection<FWSimVariable<?>> getOutputVariables()
      always returns empty list. No Output expected from this adapter
      Returns:
      FWSimVarables filtered - only output Variables
      See Also:
    • getInputVariables

      public Collection<FWSimVariable<?>> getInputVariables()
      returns list of the input variables given as header information
      Returns:
      FWSimVarables filtered - only input Variables
      See Also:
    • getResetScript

      public String getResetScript()
      Returns:
      the rule
    • getContentType

      public FWSimVariable.CONTENT_TYPE getContentType()
      Returns:
      number in the order of Components
      See Also:
    • getQueueLenth

      public int getQueueLenth()
      Returns:
      length of the current queue
    • isActive

      public boolean isActive()
      Returns:
      if the Queue is actively running
    • getInterface

      public FWSimInterface<?> getInterface()
      Overrides:
      getInterface in class FWSimIOAdapter
      Returns:
      the connected interface
    • getVarMap

      public FWSimVarMap getVarMap()
      Returns:
      number in the order of Components
    • hasStatistics

      public boolean hasStatistics()
      Returns:
      if the adapter has statistics
    • getStatisticsHeaderVariables

      public LinkedHashMap<String,FWSimVariable<?>> getStatisticsHeaderVariables()
      Returns:
      the statistics header variable
    • getStatistics

      public LinkedList<FWSimStatisticVariable> getStatistics()
      Returns:
      the statistics
    • getStatisticsResultCache

      public FWSimResultCache getStatisticsResultCache(String aSimulationID)
      Parameters:
      aSimulationID -
      Returns:
      the statisticsResultCache
    • getStatisticsAdapter

      public FWSimOutputAdapter getStatisticsAdapter()
      Returns:
      the statisticsAdapter
    • toXML

      public org.jdom2.Element toXML()
      Returns:
      a xml element with all the settings of this component()
      See Also:
    • toHTMLTablestring

      public String toHTMLTablestring()
      creates HTML Documentation form of the Output Adaptor
      Returns:
      the generated HTMLString
    • isWriting

      public boolean isWriting()
      for synchronization purposes checks, if the writing method is still active, even if the queue is empty
      Returns:
      true if the writing process is still active