Pepperl+Fuchs OHV300 Javascript Programming Manual Download Page 1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

FACTORY AUTOMATION

 

MANUAL

 

J

AVA

S

CRIPT 

P

ROGRAMMING 

G

UIDE

 

Summary of Contents for OHV300

Page 1: ...FACTORY AUTOMATION MANUAL JAVASCRIPT PROGRAMMING GUIDE...

Page 2: ...eneral Terms of Delivery for Products and Services of the Electrical Industry published by the Central Association of the Electrical Industry Zentralverband Elektrotechnik und Elektroindustrie ZVEI e...

Page 3: ...plication 12 2 3 Security 12 2 4 Debugging 13 3 Programming Concepts 14 3 1 Simplicity 14 3 2 The OHV300 gui Object 15 3 2 1 Softkey Implementation 16 3 2 2 Forms 16 3 2 3 Menus 17 3 2 4 Text 19 3 3 E...

Page 4: ...1 1 Properties 31 4 1 1 1 data 31 4 1 1 2 symbology 31 4 1 1 3 symbology_ex 32 4 1 1 4 symbologyModifier 32 4 1 1 5 symbologyModifier_ex 32 4 1 1 6 symbologyIdentifier 32 4 1 1 7 x 32 4 1 1 8 y 32 4 1...

Page 5: ...41 4 2 1 10 showSubMenu 42 4 2 1 11 splash and clearSplash 42 4 2 1 12 sync 43 4 2 2 Properties 43 4 2 2 1 inputMode 43 4 2 2 2 key 44 4 2 2 3 leftSoftkey 44 4 2 2 4 rightSoftkey 44 4 2 2 5 statusText...

Page 6: ...ol 57 4 2 5 2 prepend control 58 4 2 5 3 setActiveChild control 58 4 2 6 Form and Menu Common Properties 58 4 2 6 1 caption 58 4 2 6 2 onKey 59 4 3 reader 59 4 3 1 Methods 59 4 3 1 1 beep 59 4 3 1 2 d...

Page 7: ...3 2 6 onStandby 69 4 3 2 7 batteryLevel 70 4 3 2 8 red 70 4 3 2 9 green 70 4 3 2 10 amber 70 4 3 2 11 none 70 4 3 2 12 cabled 71 4 3 2 13 charging 71 4 3 2 14 hardwareVersion 71 4 3 2 15 oemId 71 4 3...

Page 8: ...t 77 4 5 comm 77 4 5 1 Methods 77 4 5 1 1 connect 77 4 5 1 2 disconnect 77 4 5 1 3 sendPacket 77 4 5 1 4 sendText 78 4 5 2 Properties 78 4 5 2 1 isConnected 79 4 6 Functions 79 4 6 1 Dialog 79 4 6 1 1...

Page 9: ...9 JavaScript Programming Guide 7 Format Specifiers 86 8 Supported JavaScript Core 87 9 Symbology ID Modifier Information 89...

Page 10: ...and describes how to use this document Section 2 Programming Environment identifies tools used to create and load application software into reader Section 3 Programming Concepts discusses how to acco...

Page 11: ...11 Introduction 1 4 Related Utility Vision Configurator Example Visit http www pepperl fuchs com to obtain this application...

Page 12: ...0 The menu driven application has features for changing configuration settings and for defining the applications that run on the reader JavaScript developers can make use of the following keywords in...

Page 13: ...lename lineNumber If there are many error codes in the error log send the command to clear the log and repeat the steps to create the error leaving only one entry in the log Example X ap gerror log st...

Page 14: ...ns A script can be made the default application using the configuration utility or it may be run from the configuration utility without making it the default Note The default application allows script...

Page 15: ...UI Display The standard display consists of a status bar a display area and labels for the left and right software programmable keys softkeys at the top of the OHV300 key pad see Figure 6 The scroll b...

Page 16: ...ncel sendEscape See section 0 gui object for more information 3 2 2 Forms Forms are the building blocks of your application Each form represents a set of actions you want to present to the user on scr...

Page 17: ...6 to define the menus for your application Use the gui MenuItem constructor to define the controls in the menu Each control has an associated onClick property that defines the function of the OHV300 T...

Page 18: ...ui MenuItem Stock onStock position the controls on the menus myMenu append separator myMenu append inventoryApp myMenu append timeCardApp subMenu append capital subMenu append stock Specify a child to...

Page 19: ...menus or forms 3 3 Event The JavaScript environment is event driven The reader firmware waits for an event such as a pressed key The application gains control of an event by setting an object s event...

Page 20: ...es decode events Example var numDecodes 0 var numDecodesProcessed 0 reader onDecodeAttempt function count numDecodes count numDecodesProcessed 0 reader onDecode function decode if numDecodesProcessed...

Page 21: ...re 6 OHV300 Keypad 1 Left Softkey 2 Right Softkey 3 Clear Escape Button 4 Enter Button Table 1 Keys to Event Mapping Key Object Event Handler Property Enter button located in the center of the arrow k...

Page 22: ...on Document defines the configuration items and the values that can be set for each item The application developer can dynamically change the active settings by using the reader writeSetting method Th...

Page 23: ...ere are four basic options for decoding scanned data Process the data in the script such as fill in form fields and return null Let the data be further processed by the handheld firmware typically for...

Page 24: ...if data matches employee badge format loginForm employeeField text decode data loginForm pinField text gui showForm loginForm return null else if data matches part number format stockForm partField te...

Page 25: ...codes common data items may be present in different locations within the decode depending on the encoding symbology In the example line 5 checks the value of decode symbology and transforms the decode...

Page 26: ...null else if data matches part number format stockForm partField text decode data gui showForm stockForm return null else if data matches shelf number format stockForm shelfField text decode data gui...

Page 27: ...commands or communication events While the event handler is running the main application is held idle until the event handler returns If the event handler is waiting for the user to finish with alert...

Page 28: ...bounds array has four elements that can be used to give the coordinates of the four corners of the code the origin is the center of the decode field decode bounds 0 x decode bounds 0 y coordinates of...

Page 29: ...vironment defines a host communication comm object section 4 4 2 3 to support communications with a host resident application For example Vision Configurator section 1 4 is a host resident utility tha...

Page 30: ...storage object section 4 3 2 18 Data is maintained in storage as named objects called files Vision Configurator can transfer host data into a handheld reader file The handheld application can also sto...

Page 31: ...a read write value representing the payload of the barcode that has just been decoded This data may also include data processing checksum information or data formatting based on settings made by the...

Page 32: ...symbologyModifier_ex are defined in 9 This property is seldom used but is used in the same way as symbologyModifier 4 1 1 6 symbologyIdentifier The decode symbologyIdentifier property is a read only p...

Page 33: ...cation ISO IEC 18004 This property is only defined if the decode symbology is QR Code 4 1 1 13 qrParity The decode qrParity property is a read only property that gives parity information for QR Code i...

Page 34: ...A decode decoderType value of 1 indicates that the decoder decoded the last barcode A value of 0 indicates that the decoder is unknown Other values may be introduced at any time 4 1 1 18 aimSymbology...

Page 35: ...tomatic Identification Mobility web site http www aimglobal org 4 1 1 20 decodeOutputFormat The decode decodeOutputFormat property is a read only property that gives the type of output the JavaScript...

Page 36: ...standard GUI display Do not call this function within onDecode and onCommand event handlers Format gui alert func text title Where func function name function to be called after displaying the alert T...

Page 37: ...function does not take any arguments and returns void text string text to display for confirmation title string text to display in the gui object status bar defaults to Confirm leftSoftkeyLabel strin...

Page 38: ...key or the left softkey defined as OK null if the prompt receives the right softkey defined as Cancel text string text to display as a label above a gui Edit control initial string the initial string...

Page 39: ...od allows graphical boxes to be painted to the display Format gui putBox x y xEnd yEnd backgroundColor type Where x defines the starting x coordinate y defines the starting y coordinate xEnd defines t...

Page 40: ...tring to the OHV300 gui object as though it had been entered from the keypad Format result gui sendText text Where text string the text to send result Boolean false if all specified text could not be...

Page 41: ...tkey yourSoftkey in which case gui showForm will use your softkey By default the right software programmable key is set to gui cancelSoftkey section 4 2 4 2 You may also define a custom rightSoftkey f...

Page 42: ...1 and sets the menu object s onCancel property to a function that shows the parent menu 4 2 1 11 splash and clearSplash The gui splash method displays an image on the OHV300 screen The gui splash fun...

Page 43: ...ly its native format which uses the extension img The image must be 128x128 pixels for splash screen only Images are not cropped they will either display in their entirety or will not display at all 4...

Page 44: ...y object See the example in section 0 Setting gui leftSoftkey to null disassociates the softkey object from the property removing the event handler and the softkey label When menus and forms are shown...

Page 45: ...form The onClick event handler is called when the enter key on the OHV300 keypad is pressed and the button control is active Program the function to return Boolean true if the control s default proce...

Page 46: ...hod to set the communications mode setting to RS232 Note The active control is highlighted 4 2 3 2 gui Edit The gui Edit constructor creates an edit control for a GUI form The OHV300 operator can ente...

Page 47: ...s form append new gui Edit Num any gui inputMode numeric form append new gui Edit CAP any gui inputMode caps form append new gui Edit Num only gui inputMode numeric gui inputMode numeric form append n...

Page 48: ...identifies the default input mode of the control and the modes which are enabled for the shift key 4 2 3 3 gui Form The gui Form constructor creates a Form object for the OHV300 GUI The gui Form const...

Page 49: ...by the active control section 4 2 6 2 To add a label to the form in the status area set the form s caption property to a string containing the label Example See section 3 2 2 4 2 3 4 gui Image The gui...

Page 50: ...MenuItem gui Separator gui ToggleButton Menu controls must be appended section 4 2 5 1 or prepended section 4 2 5 2 to the menu object Format var menu_name new gui Menu onOk onCancel onKey Where menu...

Page 51: ...d Example See section 3 2 3 4 2 3 8 gui MultiLineEdit The gui MultiLineEdit constructor creates a multiple line edit control for the GUI screen The OHV300 operator can enter data into the multiple lin...

Page 52: ...insert into multiLineEdit control Example var main new gui Menu main append new gui Button Notes function gui showDialog captureNotes gui showMenu main storage write saveNotes txt var captureNotes new...

Page 53: ...er of the separator space as shown in Figure 12 Figure 12 gui Separator Lines Example See the menu example in section 3 2 3 4 2 3 10 gui Softkey The gui Softkey object provides processing control of t...

Page 54: ...own arrow keys Format var text_name new gui Text text onOk onCancel onKey Where text_name program provided text control text string text data to display on the OHV300 GUI To display multi line text in...

Page 55: ...ly displayed or suppressed Format var togglebutton_name new gui ToggleButton text initiallyChecked onToggle Where togglebutton_name program provided toggle button control text string a label for the t...

Page 56: ...false toggleOnClick position the controls on the form myForm append toggle Place text on the status bar myForm caption toggle demo show the form gui showForm myForm Initially shows the form in Figure...

Page 57: ...gui cancelSoftkey 4 2 4 3 okSoftkey The gui okSoftkey object defines a softkey object It labels the softkey OK and sends the enter key when the softkey is clicked Format gui leftSoftkey gui okSoftkey...

Page 58: ...d is optional Format MenuOrForm_name setActiveChild control Where control the control to select when the menu is displayed Example See forms example in section 3 2 2 Note You must show the form menu a...

Page 59: ...and firmware Use the methods and properties of the reader object to command the behavior of the handheld such as Executing commands on the handheld Running a JavaScript on the handheld Reading and ch...

Page 60: ...nfiguration purchased 4 3 1 3 getKeyboardStatus The getKeyboardStatus method takes no arguments and returns a read only Integer bitmapped value containing the keyboard state of the handheld hardware P...

Page 61: ...nt type read near and far fields to the handheld firmware 4 3 1 5 readSetting The readSetting method returns the current value of the specified configuration setting Format value reader readSetting se...

Page 62: ...to access a time card application 4 3 1 7 saveSettings The saveSettings method writes the current values of the handheld configuration settings into flash memory Operational setting values are loaded...

Page 63: ...l The clearInterval method removes the instance of setInterval that has the handle intervalId Format reader clearInterval intervalId Where intervalId program provided interval ID 4 3 1 11 setTimeout T...

Page 64: ...ncoded as Unicode Example myUnicodeString reader shiftJisToUnicode myString Sets myUnicodeString to the Unicode encoded equivalent of myString 4 3 1 14 writeSetting The writeSetting method changes the...

Page 65: ...documents the properties defined for the handheld s reader object 4 3 2 1 onCommand The onCommand property of the handheld calls the specified function when the reader Receives a configuration command...

Page 66: ...ndType print Erasing Error Log reader onCommand notifyErase Sends a debugging message to the host to show that the erase command was detected 4 3 2 2 onCommandFinish The onCommandFinish property of th...

Page 67: ...nction in your script and return a code as follows null the decode has been consumed by the JavaScript application there should be no further processing of it by the handheld firmware false invalidate...

Page 68: ...e application program at the completion of a decode action before any of the decoded symbols are passed to reader onDecode Format function onDecodeAttempt count processing statements reader onDecodeAt...

Page 69: ...such as button presses are active or queued This event is posted when the JavaScript has nothing else queued and is not related to the handheld active time setting hex 32 Format function onIdle proces...

Page 70: ...e levels are reader green not low reader amber somewhat low reader red very low Example batteryLevel reader batteryLevel 4 3 2 8 red The red property of the reader object contains a read only constant...

Page 71: ...erty of the reader object contains a read only string containing the version number of the handheld hardware Example hwVersion reader hardwareVersion 4 3 2 15 oemId The oemId property of the reader ob...

Page 72: ...ncodes Unicode characters in one or more bytes each 4 4 1 Methods The following section documents the methods defined for the handheld storage object In this section the examples use elements of a tim...

Page 73: ...ored objects name string the name of the first matching file name is null if no file matches the expression Example name storage findFirst TimeCard Sets name to the name of the first time card record...

Page 74: ...d Example ok storage rename oldName newName Where oldName string the name of a file to rename newName string the name of the file after rename ok bool success or failure of the renaming Sets ok to tru...

Page 75: ...the command in the Interface Configuration Document Example name storage findFirst TimeCard while name if storage upload name alert name upload failed name storage findNext Uploads all time card reco...

Page 76: ...e the last decode to determine the origin and bounding box within the last image and save the rotated box defined by the offset point width and height to filename The function will return a bool indic...

Page 77: ...at result comm connect try_until_timeout Where try_until_timeout Boolean if true the reader will attempt to try connecting for the number of seconds defined in connectionTime_sec register 0xd9 If fals...

Page 78: ...text which may include NULL characters to be sent via the active communication port the text will be sent raw regardless of the reader comm mode settings This method buffers the data until the USB pa...

Page 79: ...tion in the GUI status bar and the text associated with the function and then waits until a key is pressed The following subsections describe the operation of each function in the OHV300 environment S...

Page 80: ...t softkey This function does not take any arguments and returns void noFunc function name function to be called when the confirm receives right softkey This function does not take any arguments and re...

Page 81: ...key The function takes one argument named result and returns void text string text to display as a label above a gui Edit control default string a default string to display as the contents of edit con...

Page 82: ...ronment This function is processor intensive so its use can degrade performance Format gc 4 6 2 2 include The include function executes the included script inline Format result include scriptName Wher...

Page 83: ...Long processes may require the firmware watchdog to be petted during the operation If the watchdog times out during a processor intensive operation the reader will reboot and an error will be logged i...

Page 84: ...dard 1 D and 2 D codes with LC display and keyboard RF Radio Frequency Code Data Data resulting from the decode process after data capture or bar code read Smart Quote Previously formatted quotation m...

Page 85: ...for the OHV300 keypad The modes are described in Table 2 Table 2 Keypad Input Modes inputMode characters numeric 0123456789 caps A Z 0 9 and all ASCII non alphanumeric symbols _ lower a z 0 9 and all...

Page 86: ...wercase scientific notation E uppercase scientific notation f floating point decimal g uses e or f whichever is shorter G uses E or f whichever is shorter o unsigned octal s character string u unsigne...

Page 87: ...isFinite isNaN NaN Number parseFloat parseInt String undefined Statements break const continue do while export for for in function if else import label return switch throw try catch var while with Ope...

Page 88: ...88 Supported JavaScript Core delete function in instanceof new this typeof void...

Page 89: ...symbologyModifier_ex Extended Symbology Modifier Mod_EX where this value is blank in the table below no Extended Symbology Modifier is defined decode decoder Which decoder was used in the decode proce...

Page 90: ...e ITF 14 17 0 48 Code39 Full symbol decoded 18 0 48 0 Code39 Partial left half symbol issued 18 0 48 1 add one to existing value Code39 Partial right half symbol issued 18 0 48 2 add two to existing v...

Page 91: ...op 32 N A N A Straight_2_of_5_3_Bar_Start_Stop 33 0 48 Japan Post 34 0 49 KIX 35 0 53 MSI_Plessey 36 0 48 Maxi 37 0 49 PDF417 38 0 48 0 Micro PDF417 38 0 48 1 PLANET 39 0 51 POSTNET 40 0 48 QR 41 0 49...

Page 92: ...of 5 Checksum checked and stripped from output string 0 1 52 NEC 2 of 5 checksum not checked 0 4 53 NEC 2 of 5 Checksum checked and included in output string 0 4 54 NEC 2 of 5 Checksum checked and st...

Page 93: ...93 Symbology ID Modifier Information...

Page 94: ...TDOCT 4981_ENG 11 2015...

Reviews: