system.mes.oee.getStateRecordsForPeriod
Description
Retrieves the OEE state records that overlap the given time period across one or more locations, clipped to that
period: a record that started before startDate is returned starting at startDate, and a record that ends
after endDate (or is still open) is returned ending at endDate, with its duration recomputed accordingly.
Unlike getStateRecordTimeline (single location, optional micro-stop merge), this
performs no micro-stop consolidation and works across multiple locations: the locationPath accepts a
wildcard, so a parent or line path returns the records for every matching child location, each tagged with its
locationName. Records are sorted ascending by start date.
This is the data provider for the Status Chart report component, which renders one ribbon row per location.
Permissions
This method requires the OEE.READ.GET permission.
Syntax
system.mes.oee.getStateRecordsForPeriod(locationPath, startDate, endDate=None)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
locationPath | String | False | The MES location path to search. Supports * and % as a wildcard, so a parent/line path matches all children. |
startDate | Date | False | The start time for the period. Records are clipped to start no earlier than this. |
endDate | Date | True | The end time for the period. Records are clipped to end no later than this. If omitted, the current time is used. |
Returns
A list of JSON representations of OeeStateRecordDTO objects, each representing a recorded OEE state event.
Each object has the following properties:
| Name | Type | Nullable | Description | Default Value |
|---|---|---|---|---|
id | String | True | The id of the OEE State Record | null |
code | Integer | False | Integer state number | null |
locationId | String | False | Identifier of the associated location where this state record was recorded | null |
locationName | String | True | Name of the associated location | null |
locationPath | String | True | Path of the location where this state record was recorded | null |
name | String | False | Name of the recorded state | null |
calculationType | OeeStateCalculationType | False | Specifies how this state contributes to OEE calculations | DOWNTIME |
color | String | False | Hex color code representing the state visually | "#000000" |
status | Status | False | Status of the OEE record (e.g., running, faulted, canceled, complete) | UNKNOWN |
startDate | Instant | False | Start date and time of the state record | Instant.now() |
endDate | Instant | True | End date and time of the state record | null |
duration | Double | False | Duration of the state record in seconds | 0.0 |
downtimeReasonId | String | True | Identifier of the associated downtime reason, if applicable | null |
downtimeReason | String | True | Title of the downtime reason. (Name - Code) For display purposes only | null |
downtimeReasonPath | String | True | Path to the current downtime reason | null |
interruptionLocationId | String | True | Location id that caused the blocked/starved state on the machine | null |
interruptionLocationName | String | True | Name of the interruption location that caused the blocked/starved state | null |
interruptionLocationPath | String | True | Location path that caused the blocked/starved state on the machine | null |
acknowledged | Boolean | False | Boolean indicating whether the state record has been acknowledged | false |
acknowledgedBy | String | True | Acknowledged By. This is the user who acknowledged the state record | null |
acknowledgedDate | Instant | True | Acknowledged Date. This is the date when the state record was acknowledged | null |
modeRecordId | String | True | Identifier of the associated mode record | null |
rootCauseStateRecordId | String | True | Identifier of the root cause state record, if applicable | null |
primaryAlarmRecordId | String | True | Identifier of the associated OEE Alarm Record, if applicable | null |
primaryAlarmName | String | True | Primary alarm name, if applicable | null |
primaryAlarmDisplayPath | String | True | Primary alarm display path, if applicable | null |
primaryAlarmLabel | String | True | Primary alarm display name, if applicable | null |
Code Examples
from java.util import Date
from java.util.concurrent import TimeUnit
# Get every state record for all machines on a line over the last 8 hours.
linePath = "Enterprise/Site/Area/Line1/%"
endTime = Date()
startTime = Date(endTime.getTime() - TimeUnit.HOURS.toMillis(8))
records = system.mes.oee.getStateRecordsForPeriod(
locationPath=linePath,
startDate=startTime,
endDate=endTime
)
# Group by location to build one ribbon row per machine.
byLocation = {}
for record in records:
byLocation.setdefault(record['locationName'], []).append(record)
for locationName, states in byLocation.items():
print locationName, "->", len(states), "states"