Class SequentialFunctionChart

java.lang.Object
neqsim.process.controllerdevice.SequentialFunctionChart
All Implemented Interfaces:
Serializable

public class SequentialFunctionChart extends Object implements Serializable
Sequential Function Chart (SFC) implementation following the IEC 61131-3 standard concept. An SFC models a sequence of discrete steps connected by transitions with guard conditions. Each step can have entry, active, and exit actions. The chart advances when the active step's outgoing transition guard evaluates to true.

Typical usage in NeqSim dynamic simulation:

  • Model startup/shutdown sequences for compressors, separators, columns
  • Implement emergency shutdown (ESD) logic
  • Control batch operations with defined phases
Version:
1.0
Author:
NeqSim
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization version UID.
      See Also:
    • logger

      private static final org.apache.logging.log4j.Logger logger
      Logger instance.
    • name

      private final String name
    • steps

    • transitions

      private final List<SequentialFunctionChart.SfcTransition> transitions
    • activeStepName

      private String activeStepName
    • initialStepName

      private String initialStepName
    • running

      private boolean running
    • elapsedTimeInStep

      private double elapsedTimeInStep
    • totalElapsedTime

      private double totalElapsedTime
    • eventHistory

      private final List<String> eventHistory
  • Constructor Details

    • SequentialFunctionChart

      public SequentialFunctionChart(String name)
      Constructs a new SFC with the given name.
      Parameters:
      name - the chart name
  • Method Details

    • addStep

      public void addStep(SequentialFunctionChart.SfcStep step)
      Adds a step to the SFC.
      Parameters:
      step - the step to add
    • addTransition

      public void addTransition(String fromStep, String toStep, BooleanSupplier guard)
      Adds a transition between two steps.
      Parameters:
      fromStep - source step name
      toStep - target step name
      guard - the boolean condition that must be true to advance
    • addTimedTransition

      public void addTimedTransition(String fromStep, String toStep, double delaySeconds)
      Adds a timed transition that fires after the specified duration in the source step.
      Parameters:
      fromStep - source step name
      toStep - target step name
      delaySeconds - time in seconds the step must be active before transition fires
    • setInitialStep

      public void setInitialStep(String stepName)
      Sets the initial step by name.
      Parameters:
      stepName - the initial step name (must have been added via addStep)
    • start

      public void start()
      Starts or restarts the SFC from the initial step.
    • stop

      public void stop()
      Stops the SFC.
    • runStep

      public void runStep(double dt)
      Advances the SFC by one timestep. Evaluates transitions and executes actions.
      Parameters:
      dt - timestep in seconds
    • advanceTo

      private void advanceTo(String targetStepName)
      Advances from the current step to the target step.
      Parameters:
      targetStepName - target step name
    • getActiveStepName

      public String getActiveStepName()
      Gets the name of the currently active step.
      Returns:
      the active step name, or null if not running
    • isRunning

      public boolean isRunning()
      Returns whether the SFC is currently running.
      Returns:
      true if running
    • getElapsedTimeInStep

      public double getElapsedTimeInStep()
      Gets the time elapsed in the current step.
      Returns:
      elapsed time in seconds
    • getTotalElapsedTime

      public double getTotalElapsedTime()
      Gets the total elapsed time since start.
      Returns:
      total elapsed time in seconds
    • getName

      public String getName()
      Gets the SFC name.
      Returns:
      the name
    • getEventHistory

      public List<String> getEventHistory()
      Gets the event history log.
      Returns:
      list of event strings
    • getStepNames

      public List<String> getStepNames()
      Gets all step names.
      Returns:
      list of step names in insertion order
    • logEvent

      private void logEvent(String message)