driver_actions_register
To manually assign a driver to a unit, end a driver’s assignment, or ignore automatic driver assignment events (mark as false), use the resource/driver_actions_register method. The selected action is stored as a resource message and processed by the resource_drivers event detector, which updates the driver’s assignment events accordingly. To view or delete the registered manual actions, use resource/driver_actions_list or resource/driver_actions_cleanup, respectively.
To get the assignment events affected by the action, load them with events/load using the resource_drivers detector and retrieve them with events/get. To view the current assignment state, use events/get_last.
Depending on the server configuration, the manual actions may not be processed. In this case, the request doesn’t affect the driver assignment events.
In Wialon Local, this method is available starting from version 2604.
Endpoint
svc=resource/driver_actions_register¶ms={
"resourceId": <long>,
"driverId": <long>,
"action": <uint>,
"unitId": <long>,
"time": <uint>,
"timeTo": <uint>,
"ignoreState": <uint>
}
Parameters
The request must contain the resourceId, driverId, and action parameters.
| Parameter | Description |
|---|---|
resourceId |
Resource ID. |
driverId |
Driver ID. |
action |
Action type: 0 for unassignment, 1 for assignment, 2 for ignore. |
unitId |
Unit ID. Required for the assignment action. For the unassignment action, specifies which assignment to end: pass unitId 0 to end the driver’s current assignment. For the ignore action, works as a filter and specifies the unit whose automatic actions should be ignored: pass unitId 0 to ignore the actions on any unit. |
time |
Action start time, UNIX time. The default value is the current time. |
timeTo |
Action end time, UNIX time. Used only for the ignore action. The default value is the same as time. |
ignoreState |
State to ignore: 0 for unassignment, 1 for assignment, or 2 for any state. Used only for the ignore action. If the parameter isn’t specified, 2 (any state) is used. |
For the assignment and unassignment actions, the unit position is saved with the action when it’s available. It’s taken from the unit messages or from the last known position of the unit, depending on the time value. For a private position, the coordinates aren’t saved, and only the privacy flag is stored.
Ignore actions
The ignore action excludes the automatic assignments and unassignments whose time falls within the interval from time to timeTo from the calculation. Use it to mark automatic events as false, for example when an assignment was registered by mistake.
Response
If the request is completed successfully, an empty object is returned:
{}
Otherwise, an error code is returned.
Error codes
| Error code | Description |
|---|---|
| 3 | The required messages can’t be retrieved. |
| 4 | Wrong input parameters, or the specified driver isn’t found in the resource. |
| 6 | The operation can’t be completed. |
| 7 | No Create, edit, and delete drivers access right to the resource, or the resource is unavailable. |
Examples
To assign the driver with ID 9 to the unit with ID 1080 at a specific time, use the following request:
svc=resource/driver_actions_register¶ms={
"resourceId": 1003,
"driverId": 9,
"action": 1,
"time": 1767228670,
"unitId": 1080
}
To mark the automatic assignments of this driver within a time interval as false, register an ignore action with ignoreState 1:
svc=resource/driver_actions_register¶ms={
"resourceId": 1003,
"driverId": 9,
"action": 2,
"time": 1767228670,
"timeTo": 1767232270,
"ignoreState": 1
}
The unitId parameter is omitted, so the action excludes automatic assignments on any unit from the calculation.