Skip to main content

system.mes.oee.validateMode

Description

Validates an OEE Mode object against the system's business rules without saving it. This is useful for checking if a mode is valid before attempting to save it.

Permissions

This method requires the OEE.READ.VALIDATE permission.

Syntax

system.mes.oee.validateMode(**modeData)

Parameters

An unpacked dictionary of OeeModeDTO fields.

ParameterTypeNullableDescriptionDefault Value
idStringTrueThe id of the OEE Modenull
locationIdStringFalseIdentifier of the associated locationnull
locationPathStringTruePath to the associated locationnull
codeIntegerFalseInteger value representing the modenull
nameStringFalseName of the modenull
calculationTypeOeeModeCalculationTypeFalseSpecifies how this mode should be factored into OEE calculationsSCHEDULED_PRODUCTION
expectedDurationSourceOeeModeExpectedDurationSourceFalseDefines the source used to determine the expected duration of a scheduled downtime eventSTATIC
expectedDurationExpressionStringTrueIgnition expression to dynamically calculate the expected duration of the mode in secondsnull
expectedDurationDoubleTrueExpected duration of the mode in seconds0.0
colorStringFalseHex color code representing the mode visually"#000000"
notesStringTrueNotes associated with the OEE Modenull
enabledbooleanTrueIndicates whether the OEE Mode is enabledtrue
spare1StringTrueExtra field 1null
spare2StringTrueExtra field 2null
spare3StringTrueExtra field 3null

Returns

A JSON object containing validation results. If the object is empty, validation passed. If it contains entries, the keys are the field names and the values are lists of validation error messages.

Code Examples

# Create a new OEE mode object
newMode = system.mes.oee.newOeeMode()

# Set some attributes (leaving required fields blank to trigger validation errors)
newMode['enabled'] = True

# Validate the mode
validationErrors = system.mes.oee.validateMode(**new_mode)

if not validation_errors:
print "Validation passed. Mode is valid."
else:
print "Validation failed. Errors:"
for field, errors in validationErrors.items():
print " - {}: {}".format(field, ", ".join(errors))

# Example of a valid mode
validMode = system.mes.oee.newOeeMode()
validMode['locationId'] = 'some-location-id'
validMode['name'] = 'Production'
validMode['code'] = 1
validMode['calculationType'] = 'SCHEDULED_PRODUCTION'
# ... other required fields ...

errors = system.mes.oee.validateMode(**validMode)
if not errors:
print "\nThe second mode is valid."