Knowledge base

Message Processing Engine - Detailed Processing Overview

Overview

The Message Processing Engine is responsible for processing messages from multiple presses, grouping them into shifts, and calculating statistics for each shift. It ensures that messages are categorized correctly, calculates event durations, and tracks downtime events when applicable.

Processing Workflow

The engine operates in a structured sequence, ensuring that all messages are processed in an orderly manner. The process consists of two major phases:

  • Processing Messages Per Press
  • Processing Batches (Shifts)

Phase 1: Processing Messages Per Press

For each press:

  • Query the Database: Retrieve all unprocessed messages (see Message Schema) that have not yet been processed.
  • Identify Start and Stop Messages:
    • Extract all messages that indicate the beginning (start messages) and end (stop messages) of a shift.
  • Group Messages Into Shifts:
    • Batch messages based on timestamps, associating them with the appropriate shift by aligning with identified start and stop messages.
  • Sort Messages:
    • Ensure all messages are ordered chronologically in ascending order to maintain correct processing sequence.

Phase 2: Processing Each Batch (Shift)

Each shift batch undergoes the following detailed processing:

Check for a Shift-End Message:

If no shift-end message exists in the batch, the shift is not ready for processing and will be skipped for later processing.

Iterate Through Messages One by One:

For each message in the batch:

  • Retrieve its corresponding Message Type object (see Message Type Schema).
  • If the message type is missing, log an error and halt processing for this event.
  • Determine whether the message is an event start message.

Calculate Event Duration:

If the message does indicate the start of an event (IsEventStart == false), compute the duration of the event as follows:

Find the End Message:

  • Search through subsequent messages in the batch to find the first instance of the correct EndMessageTypeId.
  • If EndMessageTypeId is not explicitly set, default to Message Type ID 1002.
  • If another event begins before finding the expected end message, log an error and stop processing for this event.

Compute Duration:

  • Calculate the time span between the start message timestamp and end message timestamp.
  • Store the duration in the list of durations for the shift.

Track Downtime Events:

If the current message's Message Type is classified as a Downtime Event, record this event separately for downtime tracking purposes.

Error Handling

The engine incorporates the following error-handling measures:

  • Missing Message Type: If a message type cannot be retrieved, log the issue and stop processing the shift.
  • Invalid End Message: If another event starts before finding the correct end message, report an error and discard this event.
  • Shift Without an End: If a shift does not contain a valid end message, defer processing until a complete shift is available.

Final Data Storage & Processing

Once all messages in a shift have been processed:

  • Store Calculated Durations:
    • Save each computed event duration to the database.
  • Update Shift Statistics:
    • Aggregate all event durations to generate total downtime and activity statistics for the shift.
  • Mark Messages as Processed:
    • Update the status of messages in the database to indicate they have been processed and should not be reprocessed.

Key Features

  • Improved shift detection with robust start/stop message identification.
  • More precise event duration tracking by enforcing correct message sequencing.
  • Downtime tracking integration for improved machine efficiency analysis.
  • Enhanced error handling to prevent incorrect data processing.