Class FWLoopProcessor

java.lang.Object
net.simplace.pipe.control.FWProcessor
net.simplace.pipe.control.FWLoopProcessor
Direct Known Subclasses:
CreateSessionProcessor, LoopCounterProcessor, LoopSimModelRunProcessor, LoopSystemscenarioProcessor

public abstract class FWLoopProcessor extends FWProcessor
Base class of looping processors, which run a given pipeline ${PipeID} (default counterPipe) several times, once per entry of a loop list or map.

Within the looped pipeline the following parameters are set:

  • runCount - total number of runs
  • Count and <looplist>.count - number of the current run, starting at ${startIndex} (default 1)
  • <looplist>.loop - the current list entry (map key)
  • <looplist>.loopvalue - for maps, the current map value
  • threadNumber - number of the thread running the pipeline
The loop list may also be given as string: comma-separated for lists ("first,next,last") or comma-separated with = in braces for maps ("{first=firstvalue,next=nextvalue}").

Further parameters:

  • separateLoops (true|false) - if true, every run works on its own copy of the parameters; otherwise the parameters created in a run are passed to the next run and finally to the output
  • threadCount - number of parallel threads (default 1); more than one forces separate runs
  • parameterlist - comma-separated names of parameters written to the output after the loop
Author:
Andreas Enders
  • Field Details

    • iLoopCount

      protected int iLoopCount
      Number of loops, from parameter runCount (default 1).
    • iLoopPipeId

      protected String iLoopPipeId
      ID of the pipeline to be looped.
    • iSeparateRuns

      protected boolean iSeparateRuns
      If true, every run works on its own copy of the parameters.
    • iLoopMap

      protected Map iLoopMap
      Map to loop over (key = loop entry, value = loop value).
  • Constructor Details

    • FWLoopProcessor

      public FWLoopProcessor()
  • Method Details

    • clone

      public FWProcessor clone()
      Description copied from class: FWProcessor
      Creates a new instance of the same class with the same container, configuration, if-expression and end-of-pipe flag. The list of progress tasks and the map of initial parameters are shared with the original on purpose: the progress view adds one task per clone to the shared list (FWProcessor.getNewProgressTask()), and each clone uses its task by its loop count; access to the list is synchronized. The initial parameters are not changed after the pipeline is created.
      Overrides:
      clone in class FWProcessor
    • runLoop

      protected final net.simplace.core.FWObservable runLoop(String aLoopListParam, Map<?,Object> aLoopObjectMap, net.simplace.core.FWObservable aObservable) throws PipeLineException
      Runs the loop pipeline once per entry of aLoopObjectMap, sequentially or in threadCount parallel threads, and writes the results to the output (see class description). To be called by subclasses from FWProcessor.process().
      Parameters:
      aLoopListParam - name of the loop list parameter, used as prefix for .loop, .loopvalue and .count
      aLoopObjectMap - entries to loop over (key = loop entry, value = loop value or null)
      aObservable - the incoming parameters
      Returns:
      the resulting parameters (for non separated runs those of the last run)
      Throws:
      PipeLineException - if the loop pipeline is not found or a run fails
    • interveneRunLoop

      protected boolean interveneRunLoop(net.simplace.core.FWObservable observable)
      Can be overridden to change the parameters of a run before it is started.
      Parameters:
      observable - the parameters of the run
      Returns:
      true to run the pipeline, false to skip this run; the default returns true
    • checkInParameterMap

      protected boolean checkInParameterMap()
      Checks that the loop pipeline (PipeID, default counterPipe) exists.
      Overrides:
      checkInParameterMap in class FWProcessor
      Returns:
      true if the pipeline exists
    • checkOutParameterMap

      protected boolean checkOutParameterMap()
      Description copied from class: FWProcessor
      Can be overridden to perform semantic checks on the output after FWProcessor.process().
      Overrides:
      checkOutParameterMap in class FWProcessor
      Returns:
      true if the output is valid; the default returns true
    • getLoopCount

      public int getLoopCount()
      Returns:
      the number of loops (parameter runCount)
    • getLoopPipeID

      public String getLoopPipeID()
      Returns:
      the id of the loop pipeline: the initial parameter PipeID if such a pipeline exists, otherwise counterPipe if it exists, otherwise null
    • initLoop

      public void initLoop(Map<String,Object> aParameterMap)
      Initialises the loop count (from runCount, with parameter tokens replaced) and the separateLoops flag. Called when the processor is created.
      Parameters:
      aParameterMap - parameters of the container plus the initial parameters of the processor
    • getLoopMap

      public Map getLoopMap()
      Returns:
      the map to loop over