system.mes.oee.importOeeAlarmsFromJson
Description
Imports OEE Alarm configurations from a JSON file provided as raw bytes. The service layer will parse the JSON content and create or update OEE alarm entities.
Large imports are automatically detected and processed asynchronously in batches. The function returns an ImportResponseDTO object wrapped in ApiResponse with import progress information.
Recommended to export at least one pre-existing OEE Alarm to JSON using the Export Oee Alarms to JSON functionality to ensure the correct format of the JSON file.
Syntax
system.mes.oee.importOeeAlarmsFromJson(bytes)
Permissions
This method requires the OEE.WRITE.SAVE permission.
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
bytes | byte[] | False | The JSON content as raw bytes. |
Returns
An ApiResponse object where data is an ImportResponseDTO object containing:
numRowsProcessed(Integer) - Number of rows processednumRowsQueued(Integer) - Number of rows queued for processingbatchFlushDelayMillis(Integer) - Delay between batch flushesbatchSize(Integer) - Size of processing batchesestimatedTimeRemainingMillis(Integer) - Estimated time to complete
Code Examples
import system.file
# Path to the JSON file
filePath = "C:/path/to/oee_alarms.json"
try:
# Read the file content as bytes
jsonBytes = system.file.readFileAsBytes(filePath)
# Import the alarms
result = system.mes.oee.importOeeAlarmsFromJson(jsonBytes)
if result.get('success'):
print "Successfully imported {} OEE alarms.".format(result.get('data'))
else:
print "Import failed: {}".format(result.get('message'))
except Exception as e:
print "An error occurred: {}".format(str(e))