Shipment
Vending Machine Shipment and Shipment Status Query
Shipment Command
Vending Machine Shipment
Channels List, row is 10, column is 10 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Layer 1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Layer 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
Layer 3 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
Layer 4 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
Layer 5 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
Layer 6 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
Layer 7 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
Layer 8 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
Layer 9 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 |
Layer 10 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
The list of channels for the physical vending machine is shown in the image.
kotlin
// serial driver
private lateinit var driver: UBoard
fun your_method() {
SReplyPara(
addr,
no % 100,
type,
check,
lift,
).apply {
driver.Shipment(this)
}.apply {
if (!this.isOK) {
throw Exception("shipping failed")
}
}
}
SReplyPara Attribute Description
Attribute | Type | Default Value | Description |
---|---|---|---|
addr | int | Slave address. | |
no | int | Channel number, where 00 corresponds to the motor of the first channel in the first row and first column. | |
type | int | Channel type: | |
1 — Spring motor | |||
2 — Electromagnetic lock | |||
3 — Conveyor belt channel | |||
4 — Motor timing control | |||
0 — Auto recognition (not recommended) | |||
check | bool | Whether to enable drop detection. | |
lift | bool | Whether to enable the elevator. |
Note: The slave addr, by default is 1. If you have a vending machine is combo type, the addr may vary.
If the number of combinations is greater than 1, the address of the second machine will be 2, with a maximum support for 8 machines.
GetShipmentStatus
Query the shipment status of the driver board.
kotlin
val para = SSReplyPara(
addr
).apply {
driver.GetShipmentStatus(this)
}.apply {
if (!this.isOK) {
throw Exception("get shipment status failed")
}
}
println("runStatus: ${para.runStatus}")
println("faultCode: ${para.faultCode}")
argument | type | default value | description |
---|---|---|---|
addr | int | Slave address. |
SSReplyPara Attribute Description
Attribute | Type | Default Value | Description |
---|---|---|---|
runStatus | int | 0 - Idle | |
1 - Dispensing (Busy) | |||
2 - Dispensing Complete (Success) | |||
3 - Fault Status (Failure) | |||
faultCode | Fault code (refer to the fault code table) | ||
0 — No error |
Fault code table
Fault codes and descriptions.
Code | Name | Description |
---|---|---|
0 | Normal | No error |
1 | Invalid Function Code | The slave received a function code that cannot be executed. After issuing a query command, this code indicates no program functionality. |
2 | Invalid Data Address | The received data address is not allowed by the slave. |
3 | Invalid Data | The queried value in the data area is not allowed by the slave. |
4 | Checksum Error | Checksum error, the master should resend the data request as per the slave's requirement. |
6 | Slave Device Busy | The slave is busy processing a long-duration command. The master should send the request when the slave is idle. |
7 | Slave Device Fault | An unrecoverable error occurred while the slave was executing the master's requested action. |
8 | Acknowledgement | The slave has received the request and is processing the data, but it requires more time. To prevent a timeout error on the master, this acknowledgment response is sent. The master can then send a "query program completion" to determine if the slave has finished processing. |