Set Device Busy State
Set the busy state of a device to identify whether the device is executing tasks, facilitating device conflict avoidance during multi-script collaboration.
Interface Description
Interface Type
setDeviceBusyParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
deviceId | string | ✅ | Device ID |
state | boolean | ✅ | Busy state, true=busy, false=idle |
Return Value
javascript
true // Returns true on successful operationEvent Notifications
When setting the state, events are triggered and broadcast via WebSocket:
- Triggers
device:busyevent when set to busy - Triggers
device:idleevent when set to idle
Basic Usage
javascript
// Set device to busy state
await apiInvoke('setDeviceBusy', {
deviceId: 'P72578581E07',
state: true
});
// Execute tasks...
// Set to idle state after task completion
await apiInvoke('setDeviceBusy', {
deviceId: 'P72578581E07',
state: false
});Notes
Device Lock
When a device is set to busy state (state: true), the system will automatically lock the corresponding device control panel to prevent interference from accidental operations during script execution.
Tips
- The device's
busyingstate can be obtained through thegetDevicesinterface - It is recommended to promptly restore to idle state after task completion or exception to unlock the control panel