在此Wiki页面中,我们将解释如何将CMBSDK槽Cordova插件用作ITME Project中的自定义小部件
打开ITME工作室并创建新项目
设置项目解决
进入项目资源管理器的全局部分,打开项目标签 - > DataSheet视图和插入我们将使用的项目标签。我们将在本节稍后解释每个标签
All tags are local and change to the tag value affects only the station on which the change was made.
Go back in Graphics section, right click on Screens category and click Insert
设置屏幕属性,然后按OK。
Design your header screen and name it as header.
在这里,我们有标题文本,标签,我们将在其中显示读取器设备电池级别和智能消息对象,以显示当前的读取器设备连接状态。
在标题屏幕中,我们将添加您的BarcoDereader自定义小部件。
单击自定义小部件图标
单击导入并查找您的barcodereader.cwp文件。Barcodereader应显示为可用的小部件。选择它,然后单击“确定”。
barodereader自定义小部件添加在标题屏幕中
打开barcodereader属性并进入小部件成员
来自带有项目标签的自定义小部件的映射属性,并设置操作集+get和设置脚本,您要在回调事件中执行。
然后打开标头屏幕脚本并调用setPreviewContainerPositionandSizeeventTrigger和LoadScanner方法打开标题屏幕时。还打开另一个屏幕(主)。
现在创建另一个屏幕并将其命名为主。
在此屏幕中,我们有矩形,在其中显示扫描结果,按钮开始/停止扫描和按钮以清除显示结果。
Later right click on Screen Group category and create StartUp screen group.
Open Project properties and set this group as Startup screen.
Because we want to deploy this application as HTML web interface and interact from mobile devices we need to open Mobile Access menu at least ones and save changes on close. Also, for better communication with custom widget, set Process Values at minimum value which is 100.
当我们完成屏幕和配置验证项目时。
并将所有屏幕保存为HTML以供Web访问
通过所有这些步骤,我们完成了ITME项目。
导航到ITME Web应用程序物理路径。如果您使用本地IIS服务器,通常此路径为C:\ Inetpub \ wwwroot \ itme81并复制您已下载的Bar CodereaderServerFiles。
These cordova files that will be hosted on server will help us to use native features trough custom widgets. Later open index.html and reference these scripts:
当我们导航到服务器URL时,我们添加了我们在查询字符串中使用的属性的平台。
使用barcodereader.js,我们检查此属性以了解要加载哪些Cordova文件(iOS或Android)。
现在打开IIS管理器右键单击您的ITME81应用程序,然后单击“添加虚拟目录:
将“ CustomWidget”设置为别名,并将其作为物理PAT设置为ITME项目(C:\ Users \ Marko \ Documents \ Intouch Machine Edition V8.1 Projection \ CMBSDKSample在我们的情况下)
确保与有权选择路径的用户建立连接。
在移动设备上运行Cognex包装器应用程序。在服务器URL输入框中,插入您的服务器URL,在查询字符串中发送屏幕和访客属性。单击导航按钮,您将被重定向到服务器URL(htttp://192.168.1.103/itme81?screen = header&guestuser = 1在我们的情况下)。当您单击“导航”按钮时,应用程序将自动添加Query String中的平台作为属性。
请注意,在从Cognex包装器应用程序导航到服务器URL之前,您必须运行ITME项目。
使用此属性,我们调用LoadScanner(deviceType,sdk_key)方法,这是我们为使用阅读器设备而需要做的第一件事
Has two input parameters. First one should be 0 if we want to use MX Device to perform scanning or 1 if we will use Mobile Device for scanning. Second input parameter is sdk_key which is optional. We need to set our sdk license key only if we use Mobile Device for scanning barcodes. Otherwise we will have asterisks in barcode reader result.
此事件的结果在LoadScannerOutputdata属性中返回,LoadScanner事件称为回调函数
例子:
'对于MX设备$ loadScannereVentTrigger =“ loadScanner(0)”'对于移动设备$ loadScannereVentTrigger =“ loadScanner(1,sdk_key)”
智慧h this property we call connect() method to connect with our reader device and should be called after we load reader device.
此事件的结果将在ConnectOutputData属性中返回,Connect事件称为回调函数。
例子:
$ connecteventtrigger =“ connect()”
使用此属性,我们将Disconnect()方法称为从阅读器设备发布连接
此事件的结果将在DisconnectOutputData属性中返回,并将Disconnect事件称为回调函数。
例子:
$ disconnecteventtrigger =“ disconnect()”
使用此属性,我们调用SetPreviewContainerPositionAndSize(StartPointX,StartPointy,width,Height)方法,该方法具有4个输入参数。StartPointX,StartPointy,宽度和高度,它们以%为单位进行测量。
这应该在LoadScanner方法之前调用,我们使用它放置移动设备预览容器。
例子:
'预览容器位于0,0(左,顶部)右100%和30%的底部。$ setPreviewContainerPositionandssizeeventTrigger =“ setPreviewContainerPositionandSize(0,0,100,30)”
智慧h this property we call toggleScanner() method to start/stop scanning process.
例子:
$ togglescannereventtrigger =“ togglescanner()”
为了启用/禁用符号,我们使用该属性触发SetSymbologyEnabled(P1,P2,P3 ..)方法。作为输入参数,我们设置符号学和状态。我们可以在一个呼叫中启用/禁用一个或多个符号。
List of symbols: UNKNOWN, DATAMATRIX, QR, C128, UPC-EAN, C11, C39, C93, I2O5, CODABAR, EAN-UCC, PHARMACODE, MAXICODE, PDF417, MICROPDF417, DATABAR, POSTNET, PLANET, 4STATE-JAP, 4STATE-AUS, 4STATE-UPU, 4STATE-IMB, VERICODE, RPC, MSI, AZTECCODE, DOTCODE, C25, C39-CONVERT-TO-C32, OCR, 4STATE-RMC.
此事件的结果在SetSymbologyEnabledoutputdata属性中返回,SetSymbologyEnabled Event称为回调函数。
例子:
$ setSymbologyEnabledEventTrigger =“ setSymbologyEnabled(datamatrix on,c128 off)””
当我们通过触发Setlightson(P1)方法开始使用此属性扫描时,默认情况下,我们可以设置光线以启用/禁用。作为输入参数,如果我们要启用并关闭,如果要默认情况下禁用光,我们将设置。
Result from this event is returned in setLightsOnOutputData property and setLightsOn event is called as callback function.
例子:
$ setlightsoneventtrigger =“ setlightson(on)”
To check if light is enabled by default we trigger isLightsOn() method
此事件的结果将在IslightSonOutputdata属性中返回,Islightson事件称为回调函数。
例子:
$ islightsoneventtrigger =“ islightson()”
智慧h this property we call sendCommand(p1, p2, p3…) method that executes DMC commands which are set as input parameters. We can set one or more dmc commands as input parameters.
此事件的结果将在sendCommandOutputdata属性中返回,而sendCommand事件称为回调函数
例子:
$ sendcommandeventtrigger =“ sendcommand(get Battery.Charge)”
代表当前读取器连接状态的整数属性。有四个状态:
0 -Connection_state_disconnected
1 -Connection_state_connecting
2 -Connection_state_connected
3 - CONNECTION_STATE_DISCONNECTING
包含最后扫描结果的字符串属性
Boolean property that is true if our reader device is available or false if reader device is unavailable.
布尔属性将在停止扫描时进行扫描或虚假时为真。
When loadScanner method is executed it return success message or error message if reader device can’t be loaded.
执行连接方法时,如果连接成功或错误消息,则返回true,如果连接无法完成
执行断开方法时,如果我们执行此方法时有问题,则返回成功消息或错误消息
在此属性中,我们从Issymbology -Enabled方法返回。结果将打开,如果启用了某些符号学,如果禁用了某些符号或错误消息,如果我们执行此方法时出现了一些错误。由于Issymbology -Enabled方法可以具有多个参数,因此我们将返回以“”分离的符号状态。例如,如果我们调用$ issymbologyEnabledEventTrigger =“ IssymbologyEnabled(Datamatrix,c128)”结果将“ on on,on”,如果启用了两个符号。
请注意,默认情况下,如果我们使用移动设备,则没有启用符号。
Result from isLightsOn method that can be ON if light is enabled, OFF if is disabled or error message if something wrong happened while this command is executed
String property that represent result from sendCommand() method. If there is more than one DMC commands as input parameters result from every command will be separated with “,”.
例如,如果我们调用$ sendcommandeventtrigger =“ sendcommand(获取电池。
如果启用了光线,则可以在Setlightson方法中产生,如果执行此命令时发生错误的问题,请关闭或错误消息。
In this property we return result from setSymbologyEnabled method. Result will be ON if certain symbology is enabled, OFF if is disabled or error message if there is some error thrown while we execute this method. Since setSymbologyEnabled method can have more than one parameter we will return symbology status separated with “,”. For example if we call $setSymbologyEnabledEventTrigger = "setSymbologyEnabled(DataMatrix, C128)" result will be “ON,ON” if both symbologies are enabled.
触发和完成sendcommand方法时将执行此回调事件:$ sendcommandeventtrigger =“ sendcommand(p1,p2,p3,p3 ...)”
当Islightson方法触发和完成时,将执行此回调事件:$ iSlightSonteventTrigger =“ islightson()”
触发和完成Setlightson方法时将执行此回调事件:$ setlightsoneventtrigger =“ setlightson(p1)”
触发和完成IssymbologyEnabled方法时将执行此回调事件:$ issymbologyEnabledeventtrigger =“ IssymbologyEnabled(P1,P2,P3,P3,.....)”
触发和完成SetSymbologyEnabled方法时将执行此回调事件:$ SETSYMBOLOCYENABEDTRIGGER =“ SetSymbologyEnabled(P1,P2,P2,P3,.....)”
触发并完成disconnect方法时将执行此回调事件:$ disconnecteventtrigger =“ disconnect()”
触发连接方法并完成时将执行此回调事件:$ connecteventtrigger =“ connect()”
触发和完成LoadScanner方法时将执行此回调事件:$ loadScannereVentTrigger =“ LoadScanner(0)”
'This callback event will be executed when toggleScanner method is triggered and finished: $toggleScannerEventTrigger = "toggleScanner()"
当更改MX设备的可用性时,将执行此回调事件。
When barcode is scanned this callback event will be executed
当更改阅读器设备的连接状态时,将执行此回调事件