Skip to main content

system.kanoa.tooling.mount(mountInfo, userId)

Mounts a tool on an asset, or in a pocket of another tool, and snapshots its positions. Tools in the tool's pockets come with it. Refused (nothing changes) when the tool is already mounted, disabled or not a tool; when the start time overlaps its history or is in the future; when the tool belongs to a site and the asset (or the pocket's tool) is not in it; when the asset doesn't use tooling or already has another tool with output positions; when the pocket isn't an empty pocket of the parent or the parent is inside the tool; and when the tool's compatibility rules don't allow the parent. Warnings: the tool is over a limit, or the site's validation hook (the core.config values toolingValidationProject and toolingValidationFunction name a project library function, e.g. 'myProject' and 'tooling.validateMount') returns warnings. The hook gets the proposed mount as a dict (action, toolingAssetId, toolingName, assetId, hostAssetId, parentToolingAssetId, parentPositionId, startDate, workOrderId, source, userId, assembly, positions) and returns {'errors': [...], 'warnings': [...]} or None; its errors refuse the mount. A hook that fails or takes over 10 seconds becomes a warning.


Parameters​

mountInfo Dictionary

- toolingAssetIdIntegerRequired
- assetIdIntegerMount on this asset, or
- parentToolingAssetIdIntegerand parentPositionId (Integer): mount in this pocket of another tool
- workOrderIdInteger
- sourceString'user', 'tag', 'workOrder', 'migration' or 'correction'. Defaults to 'user'
- startDateDateDefaults to now. Can be earlier, but not before the tool's last unmount
- acceptWarningsBooleanMount despite warnings. Defaults to False, which refuses a mount with warnings with a message starting 'Needs confirmation:' (warnings separated by ' | '); mount again with True to accept them, and they are kept on the assignment's note

userId Integer: The user making the change


Returns​

(toolingAssignmentId, message)


Example​

mountInfo = {'toolingAssetId': 1, 'assetId': 1, 'parentToolingAssetId': 1, 'workOrderId': 1, 'source': 'user'}
userId = 5
toolingAssignmentId, message = system.kanoa.tooling.mount(mountInfo, userId)