system.mes.oee.getAlarmRecordsFiltered
Description
Retrieves one detailed OEE Alarm Record per alarm that is linked to an OEE State Record, for the state records under a location path.
Each result (an OeeAlarmRecordDetailedDTO) carries the alarm, its parent state record, and that state record's root cause state record as nested OeeStateRecordDTO objects (the same shape as the OEE State Record), so tables and timelines can be built from a single call.
An alarm is included when its own active period overlaps the range: activeDate < endDate and (clearedDate is null or clearedDate > startDate). Alarms not linked to a state record, and alarms whose parent state record has a FAULTED status, are excluded.
Limits
The call is rejected with an error when startDate is not before endDate, when the range is longer than oee.alarms.query.max_range_days (default 31 days), or when more than oee.alarms.query.max_rows (default 5000) alarm records match. Narrow the location or time range and retry. See the properties guide.
Permissions
This method requires the OEE.READ.GET permission.
Syntax
system.mes.oee.getAlarmRecordsFiltered(locationPath, startDate, endDate, eventTypes=None)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
locationPath | String | False | The path of the location to search. It is matched against the location of the parent state record, and includes the location subtree (Line1 matches Line1 and its children, not Line10). * is a wildcard; * alone matches all. |
startDate | Date | False | The start of the time range. |
endDate | Date | False | The end of the time range. |
eventTypes | String[] | True | Parent state calculation types to include (for example DOWNTIME, BLOCKED, STARVED). Default is all. |
Returns
Returns a list of JSON objects, ordered by alarm activeDate descending. Each object is an OeeAlarmRecordDetailedDTO, which extends OeeAlarmRecordDTO: it carries every property of the standard alarm record (for example ignitionAlarmId, shelvedDate, lastEventState, oeeStateRecordId, oeeStateRecordCode, downtimeReasonCodeOverride, stateCodeOverride) in addition to the following properties:
| Name | Type | Nullable | Description |
|---|---|---|---|
id | String | False | The id of the alarm record |
name | String | False | The alarm name as configured in Ignition |
label | String | False | The human-readable display name for the alarm |
displayPath | String | False | The hierarchical display path of the alarm |
priority | String | True | The alarm priority (enum name) |
state | String | False | The alarm state (enum name) |
source | String | False | The tag path or source that generated the alarm |
activeDate | Instant | False | When the alarm became active |
clearedDate | Instant | True | When the alarm cleared |
acknowledgedDate | Instant | True | When the alarm was acknowledged |
durationMs | Long | True | clearedDate minus activeDate in milliseconds, null while the alarm is still active |
locationId | String | False | Id of the location the alarm was captured at |
locationPath | String | False | Path of the location the alarm was captured at |
isPrimary | boolean | False | true when this alarm is the primary alarm of the parent state record |
stateRecord | OeeStateRecordDTO | False | The parent state record of the alarm. See OEE State Record for its properties (for example name, code, calculationType, color, startDate, endDate, locationId, locationName, locationPath, downtimeReason, interruptionLocationId, interruptionLocationName, interruptionLocationPath, rootCauseStateRecordId, primaryAlarmRecordId) |
rootCauseStateRecord | OeeStateRecordDTO | True | The raw root cause state record of the parent state record, null when it has none. It is not substituted for DOWNTIME parents |
Root resolution
The "root" of an alarm row is not a separate property, derive it from the two nested records:
- If
stateRecord.calculationTypeisDOWNTIME, the state record is its own root: the root location is the state record's own location (stateRecord.locationId,locationName,locationPath) and the root state isstateRecord. - Otherwise the root location is the interruption location of the state record (
stateRecord.interruptionLocationId,interruptionLocationName,interruptionLocationPath) and the root state isrootCauseStateRecord. Both arenullwhen the state record has none.
Code Examples
# All alarms in the last 8 hours under a line, for downtime and blocked states
end = system.date.now()
start = system.date.addHours(end, -8)
rows = system.mes.oee.getAlarmRecordsFiltered('Enterprise/Site/Area/Line1', start, end, eventTypes=['DOWNTIME', 'BLOCKED'])
for row in rows:
state = row['stateRecord']
if state['calculationType'] == 'DOWNTIME':
rootLocationPath = state['locationPath']
rootState = state
else:
rootLocationPath = state['interruptionLocationPath']
rootState = row['rootCauseStateRecord']
rootName = rootState['name'] if rootState else None
print row['label'], row['priority'], row['durationMs'], rootLocationPath, rootName