Class ProcessEventBus

java.lang.Object
neqsim.process.util.event.ProcessEventBus
All Implemented Interfaces:
Serializable

public class ProcessEventBus extends Object implements Serializable
Event bus for publishing and subscribing to process events.

Provides a publish-subscribe mechanism for process simulation events, enabling loose coupling between simulation components and external systems (like AI optimization platforms).

Supports:

  • Type-based filtering
  • Severity-based filtering
  • Synchronous and asynchronous event delivery
  • Event history for late subscribers
Version:
1.0
Author:
ESOL
See Also:
  • Field Details

  • Constructor Details

    • ProcessEventBus

      public ProcessEventBus()
      Creates a new event bus (for non-singleton use).
  • Method Details

    • getInstance

      public static ProcessEventBus getInstance()
      Gets the singleton event bus instance.
      Returns:
      event bus instance
    • subscribe

      public void subscribe(ProcessEventListener listener)
      Subscribes to all events.
      Parameters:
      listener - event listener
    • subscribe

      public void subscribe(ProcessEvent.EventType type, ProcessEventListener listener)
      Subscribes to events of a specific type.
      Parameters:
      type - event type
      listener - event listener
    • unsubscribe

      public void unsubscribe(ProcessEventListener listener)
      Unsubscribes from all events.
      Parameters:
      listener - listener to remove
    • unsubscribe

      public void unsubscribe(ProcessEvent.EventType type, ProcessEventListener listener)
      Unsubscribes from a specific event type.
      Parameters:
      type - event type
      listener - listener to remove
    • publish

      public void publish(ProcessEvent event)
      Publishes an event to all subscribers.
      Parameters:
      event - event to publish
    • publishInfo

      public void publishInfo(String source, String description)
      Publishes an info event.
      Parameters:
      source - event source
      description - description
    • publishWarning

      public void publishWarning(String source, String description)
      Publishes a warning event.
      Parameters:
      source - event source
      description - description
    • publishAlarm

      public void publishAlarm(String source, String description)
      Publishes an alarm event.
      Parameters:
      source - event source
      description - description
    • deliverSync

      private void deliverSync(ProcessEvent event)
    • deliverAsync

      private void deliverAsync(ProcessEvent event)
    • setAsyncDelivery

      public void setAsyncDelivery(boolean async)
      Enables or disables asynchronous delivery.
      Parameters:
      async - true for async delivery
    • setMaxHistorySize

      public void setMaxHistorySize(int size)
      Sets the maximum history size.
      Parameters:
      size - maximum events to retain
    • getRecentEvents

      public List<ProcessEvent> getRecentEvents(int count)
      Gets recent events from history.
      Parameters:
      count - number of events to retrieve
      Returns:
      list of recent events
    • getEventsByType

      public List<ProcessEvent> getEventsByType(ProcessEvent.EventType type, int count)
      Gets events by type from history.
      Parameters:
      type - event type
      count - maximum events to retrieve
      Returns:
      list of events
    • getEventsBySeverity

      public List<ProcessEvent> getEventsBySeverity(ProcessEvent.Severity minSeverity, int count)
      Gets events by severity from history.
      Parameters:
      minSeverity - minimum severity level
      count - maximum events to retrieve
      Returns:
      list of events
    • clearHistory

      public void clearHistory()
      Clears event history.
    • getHistorySize

      public int getHistorySize()
      Gets the total event count in history.
      Returns:
      event count
    • shutdown

      public void shutdown()
      Shuts down the event bus.
    • resetInstance

      public static void resetInstance()
      Resets the singleton instance (for testing).