Cognex Browser has a variety of settings allowing you to configure it to perform the best for your website.
You can define several different Configurations in Cognex Browser and assign these configurations when you bookmark a webpage. This way Cognex Browser works differently depending on which site you are. Of course it is possible to keep only one Configuration (Default one) and assign this to all bookmarked sites.
Settings within this group are disabled if "Keyboard wedge mode" is turned on.
Cognex Browser allows you to configure how you want to navigate through the input fields of your web sites. If you enable keyboard wedge mode these settings are ignored.
Defining input types
You can define which type of input fields may be focused on when the browser is processing successful read result. This configuration can be done in "Define input types" from the "Navigation" group. Supported types are(bold ones are set by default): hidden, email, number, password, search, tel, text, textarea, url.
Scanner focus
There are many settings for fine-tuning how focus changes after a successful read. When you first open the web page the scanner focus is on the first input field that is enabled in the "Define input types" setting by default. That means this input field will be the first to receive a scan result when scanning a bar code with a Cognex reader. If there are no such input fields on the page or all input types are disabled, the scanned bar code will be copied on your devices clipboard.
It is always possible to read a code into address bar of Cognex Browser.
The initially focused field can be changed by going in the Cognex Browser settings and selecting "Initially focused input field":
It is also possible to define where the focus should move after a successful read was performed in "Move focus after read" settings:
When tapping on an input field on the web page, if that input fields type is enabled in the "Define input types" setting, by default the scanner focus will move to that input field. This can be changed in the Cognex Browser settings by changing the "Allow focus on touch or from JS" switch. When this setting is disabled, the scanner focus changes will happen only as it is defined by the "Initially focused input" and "Move focus after read" settings. Keep in mind, if this setting is enabled and you select an input field that's type is disabled in the "Define input types" setting, the scanner focus will not go into that input field even though a cursor will appear there. This allows you to type something into that input field, but you cannot scan a bar code, and have the result inserted since that type is disabled.
Automatically submit HTML forms
Cognex Browser can automatically submit an HTML form. To enable this feature you have to change the "Automatically submit forms" switch. When this setting is enabled, the form will be automatically submitted in two cases:
To prevent accidental form submissions, right below the "Automatically submit forms" setting you will find the "Confirm auto-submit forms" setting. If this is enabled, then a confirmation is displayed every time before automatically submitting the form.
It is possible to interact with a Cognex reader from Cognex Browser using JavaScript on you webpage. There are two events that caught from JavaScript code: "readResultReceived" and "connectionStateChanged".
The "readResultReceived" event is triggered when the Cognex reader is triggered and "Send event on read result received" is enabled. The read result that is sent to that event has the following format:
{
"readResults" : [
{
"goodRead" : 1,
"readString" : "2112345678900",
"symbology" : 4,
"symbologyString" : "UPC-EAN",
"xml" : "...",
}
],
"subReadResults" : [
],
"xml" : "...",
}
The main readResult object contains three key-value pairs:
To listen for "readResultReceived" event on your website, add the JavaScript event listener like in the example below:
document.addEventListener('readResultReceived', function(barcode_result){
alert(JSON.stringify(barcode_result.detail));
});
The "connectionStateChanged" event is triggered when the Cognex device changes its connection state and "Send event if connection status changed" is enabled. The attached object has a number representing the new connection state:
0 - Disconnected, the readerDevice is not connected to any remote system.
1 - Connecting, the readerDevice is in the process of establishing a connection to a remote system.
2 - Connected, the readerDevice is connected to a remote system.
3 - Disconnecting, the readerDevice is in the process of disconnecting from a remote system.
4 - Unknown, the readerDevices connection state is unavailable.
To listen for "connectionStateChanged" event on your website, add the following JavaScript event listener:
document.addEventListener('connectionStateChanged', function(connection_state){
alert(JSON.stringify(connection_state.detail));
});
The Cognex Browser allows communication from the web site to the Cognex reader. An object named as "cmbSDK" is available from Javascript after the web page has been loaded. By using this object it is possible to:
All you have to do is add the following functions to your web site and call them whenever you need (using timer, on button press, etc.).
function startScanning() {
cmbSDK.triggerStartScan();
}
function stopScanning() {
cmbSDK.triggerStopScan();
}
function triggerUserEvent1() {
cmbSDK.triggerUserEvent1();
}
function triggerUserEvent2() {
cmbSDK.triggerUserEvent2();
}
Cognex Browser provides possibility to push configuration via MDM and prevent that the end user may change settings.
Important to know that in this case you are not able to modify any setting on the configured device (so does your end users).
<dict>
<key>configurationURL</key>
<string>https://myserver.com/firmwares/firmware_file_name</string>
</dict>
Important to know that in this case you are not able to modify any setting on the configured device (so does your end users).