User Level¶
The User Level regroups the features that have an impact on the user experience.
The Socket Barcode Scanners provide ways to notify the user when the barcode read is correct or incorrect without the need for the user to check the screen of the host.
The Scanner has 3 types of feedback: Sound, LED and Vibrate.
For example, depending on the environment, you may want to turn off the sound and use only the vibration.
Here are some examples on how to use these feedback mechanisms.
Turning off the Sound¶
Turning off the good read sound is a simple 2 step process. Since this setting is
persistent on the scanner, it is best to first read this setting when the
scanner connects and depending on its state, either change it or
just continue on.
Let’s imagine we would like to offer to the user a button in the UI to turn
on or off the beep when scanning a barcode. The DeviceArrival
handler is
used to request the actual state of the scanner to display the button to turn
on the beep or to turn it off. The code might look like this:
async void CaptureDeviceArrival(object sender, CaptureHelper.DeviceArgs e)
{
// ask for the device decode action
CaptureHelperDevice.DecodeActionResult resultDecodeAction =
await e.CaptureDevice.GetDecodeActionAsync();
if (resultDecodeAction.IsSuccessful())
{
OriginalFlash = resultDecodeAction.Flash;
OriginalVibrate = resultDecodeAction.Rumble;
if (resultDecodeAction.Beep)
{
buttonBeepOnOff.Text = "Beep Off";
buttonBeepOnOff.Tag = 0;
}
else
{
buttonBeepOnOff.Text = "Beep On";
buttonBeepOnOff.Tag = 1;
}
}
else
{
buttonBeepOnOff.Enabled = false;
}
}
Then the handler of the button is in charge of turning off or on the beep when the scanner reads a barcode and the code could look like this:
private async void buttonBeepOnOff_Click(object sender, EventArgs e)
{
bool beep = false;
buttonBeepOnOff.Enabled = false;
if((int)buttonBeepOnOff.Tag == 1){
beep = true;
}
CaptureHelper.AsyncResult result =
await Device.SetDecodeActionAsync(beep, OriginalFlash, OriginalVibrate);
if (result.IsSuccessful())
{
if (beep)
{
buttonBeepOnOff.Text = "Beep Off";
buttonBeepOnOff.Tag = 0;
}
else
{
buttonBeepOnOff.Text = "Beep On";
buttonBeepOnOff.Tag = 1;
}
}
else
{
MessageBox.Show(
"Unable to change the Decode Action: " + result.Result,
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
buttonBeepOnOff.Enabled = true;
}
Locate the Scanner¶
‘’Locate the Scanner’’ might be a nice feature to help the user identify which scanner is theirs in a situation where more than one scanner is is in the area. This feature could be implemented with a repeated action of sending a Data Confirmation to the scanner to cause the scanner to beep or flash or vibrate. Here is code example of a command that would need to be in a timer handler:
int beep = ICaptureProperty.Values.DataConfirmation.kBeepGood;
int led = ICaptureProperty.Values.DataConfirmation.kLedGreen;
int rumble = ICaptureProperty.Values.DataConfirmation.kRumbleGood;
CaptureHelper.AsyncResult result = await Device.SetDataConfirmationAsync(beep, led, rumble);
if (!result.IsSuccessful())
{
MessageBox.Show(
"Unable to Send Data Confirmation: " + result.Result,
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
Note
Triggering the scanner remotely shows the scanner aiming light which could also help to find or identify the connected scanner. This use requires caution though because it might scan a barcode.
Wrong barcode indication¶
Wrong barcode indication can be useful when a user scans a barcode but that barcode was not expected at that moment in the application or is not the expected symbology or format. Of course the application UI could display a user friendly error, but maybe the user is scanning a bunch of barcodes without looking at the screen. So sending back to the user an indication that something is wrong after having scanning a barcode might be useful.
Here is an example of code that can be invoked when such a condition occurs in the application:
int beep = ICaptureProperty.Values.DataConfirmation.kBeepBad;
int led = ICaptureProperty.Values.DataConfirmation.kLedRed;
int rumble = ICaptureProperty.Values.DataConfirmation.kRumbleBad;
CaptureHelper.AsyncResult result =
await Device.SetDataConfirmationAsync(beep, led, rumble);
if (!result.IsSuccessful())
{
MessageBox.Show(
"Unable to Send Data Confirmation: " + result.Result,
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
The Device in this code is a CaptureHelperDevice
object instance.