Skip to main content

mes.spGetAssetStateDataSummary

Description

Returns a summarized breakdown of state durations for a given asset over a specified time range. Each row represents time spent in a specific state, categorized by state type, color, and label. Adjusts the start of the range to capture partial states that began prior to the provided window.

Syntax

mes.spGetAssetStateDataSummary @assetId, @rangeStart, @rangeEnd

Parameters:
@assetId (int): Asset whose state data is being summarized.
@rangeStart (datetime): Lower bound of the time window to analyze.
@rangeEnd (datetime): Upper bound of the time window to analyze.

Returns:
- assetPath: Full hierarchical path of the asset.
- assetName: Name of the asset.
- stateName: Name of the state, optionally prefixed with asset name for cross-asset references.
- stateTypeName: Logical category of the state (e.g., Running, Planned Downtime).
- stateTypeColor: Hex color representing the state type.
- durationSecs: Total seconds spent in this state across the range.

Code Example

-- Get a breakdown of state durations by state type for asset 3010
EXEC mes.spGetAssetStateDataSummary
@assetId = 3010,
@rangeStart = '2025-06-01',
@rangeEnd = '2025-06-30';