Skip to content

Alarm Calculation Jobs

The JobAlarmCalc class is a job instance that performs alarm calculations for specified objects and alarms. It uses the AlarmCalcThreshold class to perform the actual calculations and handles complex dependency ordering between alarms. This class is defined in the job_instance_alarm_calc.py file and inherits from the JobInstance base class.

Overview

This job automates the calculation of multiple alarms across multiple objects, ensuring that alarm dependencies are respected through topological sorting. The job creates individual steps for each object-alarm combination and executes them in the correct order based on alarm dependencies.

Required Parameters

  • object_names: A list of object names (strings) to calculate the alarms for. These must be valid object instance names that exist in the performance database.

  • alarm_ids: A list of alarm manufacturer IDs (integers) to calculate. These are based on the manufacturer_id column in the alarms table, not the database id field.

  • start: The start datetime of the calculation period in the format YYYY-MM-DD HH:MM:SS (string).

  • end: The end datetime of the calculation period in the format YYYY-MM-DD HH:MM:SS (string).

Parameter Validation

The job performs several validation checks during initialization:

  • Object Validation: Verifies that all specified objects exist in the database. Raises JobStepError if any objects are missing.
  • Alarm Validation: Checks that all specified alarm IDs exist for the object models being processed. Raises JobStepError if any alarms are not found for the relevant object models.
  • Model Compatibility: Ensures alarms are available for the specific object models of the target objects.

Job Steps Creation and Ordering

The job steps are created with sophisticated dependency management:

Step Creation Process

  1. Object Grouping: Objects are grouped by their model type for efficient processing.
  2. Alarm Filtering: Only alarms compatible with each object model are included.
  3. Dependency Analysis: Uses NetworkX library to analyze alarm dependencies from the non_overlapping_alarms column.
  4. Topological Sorting: Applies topological sorting to ensure dependent alarms are calculated in the correct order.
  5. Step Generation: Creates individual steps for each object-alarm combination.

Execution Order

Steps are ordered by:

  1. Object Name: Alphabetical order of object names
  2. Dependency Order: Within each object, alarms are ordered based on their dependencies using topological sorting
  3. Sequential Numbering: Each step receives a unique sequential execution order number

Dependency Handling

Alarms that are dependencies of other alarms (specified in the non_overlapping_alarms column) are automatically calculated first. This ensures that:

  • Prerequisite alarm results are available when needed
  • No circular dependencies cause calculation failures
  • Complex alarm hierarchies are handled correctly

Step Execution

Each step executes the following process:

  1. Retrieves step parameters from the database
  2. Creates an AlarmCalcThreshold instance for the specific object-alarm combination
  3. Runs the calculation for the specified time period
  4. Utilizes cached data to improve performance across related calculations
  5. Handles and reports any calculation errors appropriately