intouch machine edition (v2.2.x) - cognex
TRANSCRIPT
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 1/28
InTouchMachineEdition(v2.2.x)
Introduct ion
InthiswikipageswewillexplainhowtouseourcmbSDKtroughcordovapluginascustomwidgetinITMEproject
Gett ingStarted
OpenITMEStudioandcreatenewproject
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 2/28
Setyourprojectresolution
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 3/28
Project Tags
GoinGlobalsectionofProjectExplorer,openProjectTags->DatasheetViewandinsertprojecttagsthatwewilluse.Wewillexplaineverytaglaterinthissection
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 4/28
Alltagsarelocalandchangetothetagvalueaffectsonlythestationonwhichthechangewasmade.
BarcodeWidget
Howthiswidgetisworking?Thereistriggerpropertiesthatcallapimethodsfromcordovaplugin.Thereisoutputpropertieswherewereturnresultsfromapimethodsandthereiseventslikecallbackfunctionsthatarecalledwhenapimethodisexecuted.Onthislinkyoucanreadabouteverypropertyandhereaboutevents.
Project screens
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 5/28
GobackinGraphicssection,rightclickonScreenscategoryandclickInsert
SetscreenattributesandpressOK.
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 6/28
Designyourheaderscreenandnameitasheader.
Herewehaveheadertext,labelwherewewillshowreaderdevicebatterylevelandsmartmessageobjectthatshowcurrentreaderdeviceconnectionstatus.
InheaderscreenwewilladdourbarcodeReadercustomwidget.
ClickonCustomWidgeticon
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 7/28
ClickimportandfindyourbarcodeReader.cwpfile .barcodeReadershouldbeshownasavailablewidget.SelectitandclickOK.
barcodeReadercustomwidgetisaddedinheaderscreen
OpenbarcodeReaderpropertiesandgoinwidgetmembers
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 8/28
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 9/28
MappropertiesfromcustomwidgetwithprojecttagsandsetactionSet+Getandsetscriptthatyouwanttoexecuteincallbackevents.
ThenopenheaderscreenscriptandcallsetPreviewContainerPositionAndSizeEventTriggerandloadScannermethodswhenheaderscreenisopened.Alsoopenanotherscreen(main)whilethisoneisopening.
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 10/28
Nowcreateanotherscreenandnameitmain.
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 11/28
Inthisscreenwehaverectanglewherewedisplayscannedresults,buttontostart/stopscanningandbuttontocleardisplayedresults.
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 12/28
LaterrightclickonScreenGroupcategoryandcreateStartUpscreengroup.
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 13/28
OpenProjectpropertiesandsetthisgroupasStartupscreen.
BecausewewanttodeploythisapplicationasHTMLwebinterfaceandinteractfrommobiledevicesweneedtoopenMobileAccessmenuatleastonesandsavechangesonclose.Also,forbettercommunicationwithcustomwidget,setProcessValuesatminimumvaluewhichis100.
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 14/28
WhenwefinishwithourscreensandconfigurationsVerifyproject.
andSaveallscreensasHTMLforwebaccess
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 15/28
WithallthesestepswefinishedourITMEproject.
Serverconfigurat ion
NavigatetoyourITMEwebapplicationphysicalpath.IfyouuselocalIISserverusuallythispathisC:\inetpub\wwwroot\ITME81andcopybarcodeReaderServerFilesthatyou'vedownload.
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 16/28
Thesecordovafilesthatwillbehostedonserverwillhelpustousenativefeaturestroughcustomwidgets.Lateropenindex.htmlandreferencethesescripts:
WhenwenavigatetoserverURLweaddplatformthatweareusingasattributeinquerystring.
WithbarcodeReader.jswecheckthisattributetoknowwhichcordovafilestoload(iOSor
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 17/28
android).
NowopenIISmanagerrightclickonyourITME81applicationandclickAddVirtualDirectory:
Set“CustomWidget”asAliasandasphysicalpatsetpathtoyourITMEproject(C:\Users\Marko\Documents\InTouchMachineEditionv8.1Projects\cmbSdkSampleinourcase)
Besurethatyoumakeconnectionwithuserthathaveauthorizationtoselectedpath.
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 18/28
CognexWrapperApplicat ion
RunCognexWrapperApplicationonyourmobiledevice.InServerURLinputboxinsertyourserverURLandinquerystringsendscreenandguestuserattributes.ClickNavigatebuttonandyouwillberedirectedtoyourserverURL(htttp://192.168.1.103/ITME81?screen=header&guestuser=1inourcase).WhenyouclickNavigatebuttonapplicationautomaticallyaddplatforminquerystringasattribute.
NotethatyoumusttorunyourITMEprojectbeforeyounavigatetoserverURLfromCognexWrapperApp.
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 19/28
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 20/28
BarcodeWidget Propert ies
loadScannerEventTrigger
$loadScannerEventTrigger="loadScanner(deviceType,sdk_key)"
WiththispropertywecallloadScanner(deviceType,sdk_key)methodwhichisthefirstthingweneedtodotoinordertousereaderdevice
Hastwoinputparameters.Firstoneshouldbe0ifwewanttouseMXDevicetoperform
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 21/28
scanningor1ifwewilluseMobileDeviceforscanning.Secondinputparameterissdk_keywhichisoptional.WeneedtosetoursdklicensekeyonlyifweuseMobileDeviceforscanningbarcodes.Otherwisewewillhaveasterisksinbarcodereaderresult.
ResultfromthiseventisreturnedinloadScannerOutputDatapropertyandloadScannereventiscalledascallbackfunction
Example:
'ForMXDevice$loadScannerEventTrigger="loadScanner(0)"'ForMobileDevice$loadScannerEventTrigger="loadScanner(1,SDK_KEY)"
connectEventTrigger
$connectEventTrigger="connect()"
Withthispropertywecallconnect()methodtoconnectwithourreaderdeviceandshouldbecalledafterweloadreaderdevice.
ResultfromthiseventisreturnedinconnectOutputDatapropertyandconnecteventiscalledascallbackfunction.
Example:
$connectEventTrigger="connect()"
disconnectEventTrigger
$disconnectEventTrigger="disconnect()"
Withthispropertywecalldisconnect()methodtoreleaseconnectionfromreaderdevice
ResultfromthiseventisreturnedindisconnectOutputDatapropertyanddisconnecteventiscalledascallbackfunction.
Example:
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 22/28
$disconnectEventTrigger="disconnect()"
setPreviewContainerPosit ionAndSizeEventTrigger
$setPreviewContainerPositionAndSizeEventTrigger=setPreviewContainerPositionAndSize(startPointX,startPointY,width,height)
WiththispropertywecallsetPreviewContainerPositionAndSize(startPointX,startPointY,width,height)methodwhichhas4inputparameters.startPointX,startPointY,widthandheightandtheyaremeasuredin%.
ThisshouldbecalledbeforeloadScannermethodandweuseittoplaceMobileDevicepreviewcontainer.
Example:
'PreviewContainerpositionedon0,0(left,top)100%rightand30%bottom.$setPreviewContainerPositionAndSizeEventTrigger="setPreviewContainerPositionAndSize(0,0,100,30)"
toggleScannerEventTrigger
$toggleScannerEventTrigger=“toggleScanner()”
WiththispropertywecalltoggleScanner()methodtostart/stopscanningprocess.
Example:
$toggleScannerEventTrigger=“toggleScanner()”
setSymbologyEnabledEventTrigger
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 23/28
$setSymbologyEnabledEventTrigger=setSymbologyEnabled(p1,p2,p3..)
Toenable/disablesymbologiesweusethispropertywhichtriggersetSymbologyEnabled(p1,p2,p3..)method.Asinputparameterswesetsymbologyandstatus.Wecanenable/disableoneormoresymbologiesinonecall.
Listofsymbols: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.
ResultfromthiseventisreturnedinsetSymbologyEnabledOutputDatapropertyandsetSymbologyEnabledeventiscalledascallbackfunction.
Example:
$setSymbologyEnabledEventTrigger="setSymbologyEnabled(DataMatrixON,C128OFF)"
setLightsOnEventTrigger
$setLightsOnEventTrigger=“setLightsOn(p1)”
Wecansetlighttobeenabled/disabledbydefaultwhenwestartscanningwiththispropertybytriggeringsetLightsOn(p1)method.AsinputparameterwesetONifwewanttoenableandOFFifwewanttodisablelightbydefault.
ResultfromthiseventisreturnedinsetLightsOnOutputDatapropertyandsetLightsOneventiscalledascallbackfunction.
Example:
$setLightsOnEventTrigger=“setLightsOn(ON)”
isLightsOnEventTrigger
$isLightsOnEventTrigger=“isLightsOn()”
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 24/28
TocheckiflightisenabledbydefaultwetriggerisLightsOn()method
ResultfromthiseventisreturnedinisLightsOnOutputDatapropertyandisLightsOneventiscalledascallbackfunction.
Example:
$isLightsOnEventTrigger=“isLightsOn()”
sendCommandEventTrigger
$sendCommandEventTrigger=“sendCommand(p1,p2,p3…)"
WiththispropertywecallsendCommand(p1,p2,p3…)methodthatexecutesDMCcommandswhicharesetasinputparameters.Wecansetoneormoredmccommandsasinputparameters.
ResultfromthiseventisreturnedinsendCommandOutputDatapropertyandsendCommandeventiscalledascallbackfunction
Example:
$sendCommandEventTrigger=“sendCommand(GETBATTERY.CHARGE)”
connect ionStateDidChangeOfReaderCallbackOutputData
Integerpropertythatrepresentcurrentreaderconnectionstate.Thereisfourstate:
0-CONNECTION_STATE_DISCONNECTED
1-CONNECTION_STATE_CONNECTING
2-CONNECTION_STATE_CONNECTED
3-CONNECTION_STATE_DISCONNECTING
resultCallbackOutputData
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 25/28
Stringpropertythatcontainlastscannedresult
availabilityCallbackOutputData
Booleanpropertythatistrueifourreaderdeviceisavailableorfalseifreaderdeviceisunavailable.
act iveStartScanningCallbackOutputData
Booleanpropertywhichwillbetruewhenscanningisactiveorfalsewhenscanningisstopped.
loadScannerOutputData
WhenloadScannermethodisexecuteditreturnsuccessmessageorerrormessageifreaderdevicecan’tbeloaded.
connectOutputData
Whenconnectmethodisexecuteditreturntrueifconnectionissuccessfulorerrormessageifconnectioncan’tbecompleted
disconnectOutputData
Whendisconnectmethodisexecuteditreturnsuccessmessageorerrormessageifthereisproblemwhileweexecutethismethod
isSymbologyEnabledOutputData
InthispropertywereturnresultfromisSymbologyEnabledmethod.ResultwillbeONifcertainsymbologyisenabled,OFFifisdisabledorerrormessageifthereissomeerrorthrownwhileweexecutethismethod.SinceisSymbologyEnabledmethodcanhavemorethanoneparameterwewillreturnsymbologystatusseparatedwith“,”.Forexampleifwecall$isSymbologyEnabledEventTrigger="isSymbologyEnabled(DataMatrix,C128)"resultwillbe“ON,ON”ifbothsymbologiesareenabled.
NotethatbydefaultifweuseMobileDevicethereisnosymbologiesenabled.
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 26/28
isLightsOnOutputData
ResultfromisLightsOnmethodthatcanbeONiflightisenabled,OFFifisdisabledorerrormessageifsomethingwronghappenedwhilethiscommandisexecuted
sendCommandOutputData
StringpropertythatrepresentresultfromsendCommand()method.IfthereismorethanoneDMCcommandsasinputparametersresultfromeverycommandwillbeseparatedwith“,”.
Forexample,ifwecall$sendCommandEventTrigger=“sendCommand(GETBATTERY.CHARGE,GETLIGHT.INTERNAL-ENABLE)”resultwillbe“50,OFF”
setLightsOnOutputData
ResultfromsetLightsOnmethodthatcanbeONiflightisenabled,OFFifisdisabledorerrormessageifsomethingwronghappenedwhilethiscommandisexecuted
setSymbologyEnabledOutputData
InthispropertywereturnresultfromsetSymbologyEnabledmethod.ResultwillbeONifcertainsymbologyisenabled,OFFifisdisabledorerrormessageifthereissomeerrorthrownwhileweexecutethismethod.SincesetSymbologyEnabledmethodcanhavemorethanoneparameterwewillreturnsymbologystatusseparatedwith“,”.Forexampleifwecall$setSymbologyEnabledEventTrigger="setSymbologyEnabled(DataMatrix,C128)"resultwillbe“ON,ON”ifbothsymbologiesareenabled.
BarcodeWidget Events
sendCommand
ThiscallbackeventwillbeexecutedwhensendCommandmethodistriggeredandfinished:$sendCommandEventTrigger="sendCommand(p1,p2,p3...)"
isLightsOn
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 27/28
ThiscallbackeventwillbeexecutedwhenisLightsOnmethodistriggeredandfinished:$isLightsOntEventTrigger="isLightsOn()"
setLightsOn
ThiscallbackeventwillbeexecutedwhensetLightsOnmethodistriggeredandfinished:$setLightsOnEventTrigger="setLightsOn(p1)"
isSymbologyEnabled
ThiscallbackeventwillbeexecutedwhenisSymbologyEnabledmethodistriggeredandfinished:$isSymbologyEnabledEventTrigger="isSymbologyEnabled(p1,p2,p3,.....)"
setSymbologyEnabled
ThiscallbackeventwillbeexecutedwhensetSymbologyEnabledmethodistriggeredandfinished:$setSymbologyEnabledTrigger="setSymbologyEnabled(p1,p2,p3,.....)"
disconnect
Thiscallbackeventwillbeexecutedwhendisconnectmethodistriggeredandfinished:$disconnectEventTrigger="disconnect()"
connect
Thiscallbackeventwillbeexecutedwhenconnectmethodistriggeredandfinished:$connectEventTrigger="connect()"
loadScanner
ThiscallbackeventwillbeexecutedwhenloadScannermethodistriggeredandfinished:$loadScannerEventTrigger="loadScanner(0)"
setAct iveStartScanningCallback
t it le:InTouchMachineEdit ion(v2.2.x);ver:2.6.x 28/28
'ThiscallbackeventwillbeexecutedwhentoggleScannermethodistriggeredandfinished:$toggleScannerEventTrigger="toggleScanner()"
setAvailabilityCallback
ThiscallbackeventwillbeexecutedwhenavailabilityofMXDeviceischanged.
setResultCallback
Whenbarcodeisscannedthiscallbackeventwillbeexecuted
setConnect ionStateDidChangeOfReaderCallback
Thiscallbackeventwillbeexecutedwhenconnectionstateofreaderdeviceischanged