SDK API - Worker Feedback
PLEASE NOTE: USAGE OF THIS FEATURES IS RESTRICTED AND AVAILABLE AS CLOSED BETA THROUGH OUR EARLY ACCESS PROGRAM. PLEASE FILL OUT THE REGISTRATION FORM IN ORDER TO APPLY FOR THE PROGRAM
Worker Feedback enables you to trigger the MARK feedback system profiles asynchronously to inform your worker about an event.
Worker Feedback commands, like all commands that trigger an action on MARK, will by default be queued in ProGlove Connect.
By providing a special flag in PgCommandParams
, this behaviour can be changed to replace the queue with this new command.
For more Information about the queueing behaviour click here
Disable the Default Scan Feedback on MARK
By default, MARK will play a positive feedback when a barcode-transmission is started.
This can be turned off using the Api Call pgManager.setScannerConfig
. The call takes a PgScannerConfig
object and an
IPgConfigCallback
callback object as parameter.
The PgScannerConfig
object can be used to change the behavior of MARK - in this case, to disable the default scanning feedback.
(Code in Kotlin)
val config = PgScannerConfig(isDefaultScanAckEnabled = false)
pgManager.setScannerConfig(config, object : IPgConfigCallback {
override fun onScannerConfigSuccess(config: PgScannerConfig) {
// everything worked
}
override fun onError(error: PgError) {
// handle the error
}
})
Trigger Feedback
To trigger a custom feedback, use the API pgManager.triggerFeedback
. The function takes a
predefined feedback ID (PgPredefinedFeedback
) wrapped in a PgCommand
and an implementation of the IPgFeedbackCallback
callback as arguments.
After the feedback was played successfully on MARK (or in case of any errors) the IPgFeedbackCallback
will be called with the relevant information.
The PgPredefinedFeedback
ID defines the Feedback Sequence to be played (see below).
The convenience function PgPredefinedFeedback.toComamnd()
used here to wrap the PgPredefinedFeedback
optionally takes a PgCommandParams
object,
which gives additional control over how the command should be executed. For now we only support the replaceQueue
flag here,
which if set to true cancels all the commands currently in the queue and adds itself as the first element. More information can be found here
val feedbackId = PgPredefinedFeedback.SPECIAL_1
pgManager.triggerFeedback(feedbackId.toCommand(), object : IPgFeedbackCallback {
override fun onSuccess() {
// everything worked
}
override fun onError(error: PgError) {
// handle the error
}
})
Possible Feedback IDs are:
- PgPredefinedFeedback.SUCCESS - Positive Feedback (ACK) - green
- PgPredefinedFeedback.ERROR - Negative Feedback (NACK) - red
- PgPredefinedFeedback.SPECIAL_1 - Special Feedback 1, yellow lights
Callback for Pressed Buttons and Double Presses
The ProGlove Connect app will send out a button press event for any physical button press an a connected Device.
Additionally it will also send out a button press if the MARK trigger is pressed twice in quick succession, like a double click on a computer mouse.
To get this, call the pgManager.subscribeToButtonPresses()
function and implement the IButtonOutput
interface.
For example, in the same onCreate
of our sample app we subscribe to the display info.
And we unsubscribe in the onDestroy
function.
override fun onCreate(savedInstanceState: Bundle?) {
//...
pgManager.subscribeToButtonPresses(this)
//...
}
override fun onDestroy() {
super.onDestroy()
pgManager.unsubscribeFromButtonPresses(this)
}
To do this, our Activity needs to implement the IButtonOutput
interface:
//
// -- IButtonOutput --
//
override fun onButtonPressed(buttonPressed: ButtonPress) {
// the button presses will come on background threads, make sure to execute this on the UI Thread
runOnUiThread {
Toast.makeText(this, "Got a button Press: ${buttonPressed.id}", Toast.LENGTH_SHORT).show()
}
}