Skip to main content

ProGlove Documentation

Command queueing in Insight Mobile

When setting screens, triggering feedback sequences, or performing any other action on a scanner, the Insight Mobile app queues the commands it will send to the device.

For example, if you quickly call, setScreen 3 times successively, the 3 screens will be displayed one after another.

You can cancel all commands currently waiting in the queue and place the next command as the first one to be executed.

Figure 1. Queueing behavior without replace-queue
Queueing behavior without replace-queue


Figure 2. Queueing behavior with replace-queue
Queueing behavior with replace-queue


Legend

Cx

A command triggered via SDK or Intent

Rx

A response (error or result object) to the Cx command

RCx

A command with the replace-queue flag active

ERx

An error response to Cx command

This queue is currently limited to 5 commands. If a command is triggered and there are already 5 commands waiting in the queue, the response is immediate and indicates a full queue.

If the latest (6th) command has the replace queue flag enabled, it is not rejected, but the queue is cleared and the 6th command becomes the new head of the queue.

Intent

To trigger the command with the replace queue flag, add a Boolean valued extra com.proglove.api.extra.REPLACE_QUEUE to the Intent.

Below, you can find an example on how to trigger feedback immediately, cancelling all queued commands:

val intent = Intent()
intent.setAction("com.proglove.api.PLAY_FEEDBACK")
intent.putExtra("com.proglove.api.extra.FEEDBACK_SEQUENCE_ID", 1)
intent.putExtra("com.proglove.api.extra.REPLACE_QUEUE", true)
sendBroadcast(intent)

Commands cancelled by the replace-queue flag will result in errors in the logs.

SDK

When using the SDK, every command is sent to Insight Mobile via a PgCommand object, which holds the necessary command data and can hold a PgCommandParams object.

The PgCommandParams object holds the data on how this command should be processed inside the Insight Mobile app.

To trigger the command with the replace queue flag, add a PgCommandParams object with replaceQueue set to true to the PgCommand.

This can be done by using the constructor of PgCommand or the convenience function .toCommand() of the data object for the command.

All commands cancelled while waiting in the queue for execution will result in a call back of the error called CANCELED_BY_COMMAND_QUEUE_REPLACE.

Use the examples below to trigger feedback immediately, cancelling all queued commands:

val feedbackId = PgPredefinedFeedback.SPECIAL_1
 pgManager.triggerFeedback(feedbackId.toCommand(PgCommandParams(true)), object : IPgFeedbackCallback {
    override fun onSuccess() {
    // everything worked
    }

    override fun onError(error: PgError) {
    // handle the error
    }
})

or:

val feedbackId = PgPredefinedFeedback.SPECIAL_1
 pgManager.triggerFeedback(PgCommand(feedbackId, PgCommandParams(true)), object : IPgFeedbackCallback {
    override fun onSuccess() {
    // everything worked
    }

    override fun onError(error: PgError) {
    // handle the error
    }
})