Skip to main content

system.mes.oee.saveState

Description

Creates or updates an OEE State in the system. To create a new state, first generate a new object with system.mes.oee.newOeeState.

Permissions

This method requires the OEE.WRITE.SAVE permission.

Syntax

system.mes.oee.saveState(**stateData)

Parameters

An unpacked dictionary of OeeStateDTO fields.

ParameterTypeNullableDescriptionDefault Value
idStringTrueThe id of the OEE Statenull
locationIdStringFalseIdentifier of the associated locationnull
locationPathStringTruePath of the associated locationnull
codeIntegerFalseInteger state number, which must be unique for a given locationnull
nameStringFalseName of the statenull
calculationTypeOeeStateCalculationTypeFalseSpecifies how this state contributes to OEE calculationsDOWNTIME
colorStringFalseHex color code representing the state visually"#000000"
autoAcknowledgeBooleanFalseWhether to automatically acknowledge the state record when it is createdfalse
interruptionLocationIdStringTrueImmediate interruption location that caused a blocked/starved statenull
interruptionLocationPathStringTruePath to the location that caused a blocked/starved statenull
maxRootCauseDelaySecondsIntegerTrueMaximum delay in seconds for looking back at historical state records when resolving root cause for blocked/starved states0
notesStringTrueNotes associated with the OEE Statenull
enabledbooleanTrueIndicates whether the OEE State is enabledtrue
spare1StringTrueExtra field 1null
spare2StringTrueExtra field 2null
spare3StringTrueExtra field 3null

Returns

A JSON representation of the saved OeeStateDTO object.

Code Examples

# Create a new OEE state object
newState = system.mes.oee.newOeeState()

# Set attributes for the new state
newState['locationId'] = '01JCH3ENEB-SV2X8B3W-NFY8WZNK'
newState['name'] = 'Running'
newState['calculationType'] = 'RUNNING'
newState['enabled'] = True

# Save the new state
savedState = system.mes.oee.saveState(**newState)

print "Saved OEE State with ID:", savedState['id']

# To update an existing state, include its ID
# updatedStateData = system.mes.oee.getState(savedState['id'])
# updatedStateData['name'] = 'Production Running'
# system.mes.oee.saveState(**updatedStateData)