Skip to main content

system.kanoa.event.assetOperationChange

This function requires KanoaOPS module

Description

Call this function whenever the mode on an asset changes. Will set all child assets to the same mode if includeChildren is true.

Syntax

assetOperationChange(assetOperationInfo, userId)
  • Parameters
      assetOperationInfo (dict)
      - assetId (int)
      - modeCode (int)
      - workOrderId (int)
      - itemId (int)
      - standardRate (float): If None, the standardRate for the assetItem will be used. Allows the standardRate to be set say for number of workers on the line
      - tStamp (datetime)
      - includeChildren (bool): Set child assets to this mode if true.
      userId (int)
  • Returns
      modeEventId (int)
      msg (string): None if successful
  • Code Example

    # Example Usage:
    assetOperationInfo = {
    'assetId': 13,
    'modeCode': 1,
    'workOrderId': None,
    'itemId': 3,
    'standardRate': 100.0,
    'modeSourceId': 1,
    'tStamp': system.date.now(),
    'includeChildren': True
    }
    modeEventId, msg = system.kanoa.event.assetOperationChange(assetOperationInfo, userId)
    if msg: system.perspective.sendMessage('showWarningToast', {'message': 'Could not change asset mode. %s'%msg})
    else: system.perspective.sendMessage('showSuccessfulToast', {'message': 'Asset has been set to %s'%values['mode']})