Skip to main content

mes.spGetAssetStateEventByShiftSummary

Description

Generates a summarized report of asset state events, grouped by shift, state name, category, and type. This procedure internally uses `spGetAssetStateEventByShift` and rolls up event durations to provide a shift-level overview.

Syntax

mes.spGetAssetStateEventByShiftSummary @assetId, @rangeStart, @rangeEnd, @durationSecs, @showChanged, @showDowntimeOnly

Parameters:
@assetId (int): ID of the asset to analyze.
@rangeStart (datetime): Start of the time range.
@rangeEnd (datetime): End of the time range.
@durationSecs (int): Minimum duration in seconds for a state event to be included.
@showChanged (bit): Whether to include changed state events (1 = include, 0 = exclude).
@showDowntimeOnly (bit): Whether to include only downtime state events (1 = yes, 0 = no).

Returns:
- assetId: ID of the asset.
- assetName: Name of the asset.
- assetPath: Full path of the asset in the hierarchy.
- stateName: Display name of the state.
- stateCategoryName: Optional grouping category of the state.
- stateTypeName: Logical classification of the state.
- stateColor: Color associated with the state.
- stateTypeColor: Color representing the state type.
- shiftName: Name of the associated shift.
- stateDurationSecs: Total duration in seconds spent in the state.
- stateDurationMins: Total duration in minutes spent in the state.

Code Example

-- Get summarized shift-based state events for asset 2070 in July
EXEC mes.spGetAssetStateEventByShiftSummary
@assetId = 2070,
@rangeStart = '2025-07-01',
@rangeEnd = '2025-07-31',
@durationSecs = 90,
@showChanged = 0,
@showDowntimeOnly = 1;