Avery Weigh-Tronix Lua API Reference Manual: Mon Sep 14 2015 13:12:38

Download as pdf or txt
Download as pdf or txt
You are on page 1of 193
At a glance
Powered by AI
The document describes an API reference manual for controlling devices via Lua scripts. It outlines various classes and their member functions for interacting with buttons, displays, and weighing devices.

The main classes described are the buttonCtrl, display and fmtPrint classes. The buttonCtrl class controls button objects, the display class controls the display, and the fmtPrint class is for printing formatted text.

The display class has member functions for controlling the display segments, writing text, setting modes, flashing, and controlling sounds. It allows manipulating the visual output and audio of the device.

Avery Weigh-Tronix Lua API Reference Manual

1.0

Generated by Doxygen 1.8.9.1

Mon Sep 14 2015 13:12:38


Contents

1 The Avery Weigh-Tronix Lua API Reference Manual 1

2 Class Index 3
2.1 Namespace List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

3 Class Documentation 5
3.1 buttonCtrl Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1.2.1 getLocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.2.2 getText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.2.3 getVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.2.4 reSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.2.5 setFont . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.2.6 setLocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.2.7 setText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.2.8 setVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2 display Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.2.1 clrDisplayBusy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.2.2 clrDisplayFlash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2.2.3 clrSegments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2.2.4 doBeep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2.2.5 getBatteryControl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2.2.6 getBuzzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2.2.7 getBuzzerEnable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.2.8 getGraphControl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.2.9 getLabelControl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.2.10 getMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.2.11 getScaleControl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2.2.12 getSetpointControl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
iv CONTENTS

3.2.2.13 setBuzzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2.2.14 setBuzzerEnable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2.2.15 setDisplayBusy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2.2.16 setDisplayFlash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2.2.17 setMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2.2.18 setOneSegment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2.2.19 setSegment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.2.2.20 setSegments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2.2.21 writeLine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.3 fmtPrint Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.3.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3.2.1 get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3.2.2 getRaw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3.2.3 printBuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.3.2.4 registerVarChangeReqEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.3.2.5 set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.3.2.6 unregisterVarChangeReqEvent . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3.2.7 varGet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3.2.8 varSet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.4 graphics Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.4.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.4.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.4.2.1 circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.4.2.2 clearScreen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.4.2.3 clrDisplayBusy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.4.2.4 drawLine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.4.2.5 drawText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.4.2.6 fillCircle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.4.2.7 fillQuadrant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.4.2.8 fillRect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.4.2.9 label.new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.4.2.10 lineTo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.4.2.11 moveTo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.4.2.12 picturebox.new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.4.2.13 putPixel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.4.2.14 quadrant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.4.2.15 rect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.4.2.16 rFillRect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.4.2.17 rRect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
CONTENTS v

3.4.2.18 screens.new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.4.2.19 setActiveScreen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.4.2.20 setDisplayBusy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.4.2.21 setInverted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.4.2.22 setMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.5 hardware Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.5.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.5.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.5.2.1 getInactivityShutdownTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.5.2.2 getMaxOptionBusCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.5.2.3 getMaxOptionCardCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.5.2.4 getShutdownEnable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.5.2.5 getSystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.5.2.6 reboot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.5.2.7 registerShutdownEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.5.2.8 setInactivityShutdownTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.5.2.9 setShutdownEnable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.5.2.10 setShutdownVoltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.5.2.11 unregisterShutdownEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.6 json Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.6.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.6.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.6.2.1 decode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.6.2.2 encode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.7 keypad Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.7.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.7.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.7.2.1 configRpn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.7.2.2 enterCheckWt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.7.2.3 enterCheckWtWithUnits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.7.2.4 enterDate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.7.2.5 enterFloat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.7.2.6 enterInteger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.7.2.7 enterIpAddress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.7.2.8 enterString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.7.2.9 enterTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.7.2.10 enterWeightWithUnits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.7.2.11 getRpnMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.7.2.12 KEY_F1_DOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.7.2.13 KEY_F1_REPEAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
vi CONTENTS

3.7.2.14 KEY_F1_UP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.7.2.15 KEY_NUMERIC_DOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.7.2.16 KEY_NUMERIC_REPEAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.7.2.17 KEY_NUMERIC_UP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.7.2.18 KEY_PRINT_DOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.7.2.19 KEY_PRINT_REPEAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.7.2.20 KEY_PRINT_UP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.7.2.21 KEY_SELECT_DOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.7.2.22 KEY_SELECT_REPEAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.7.2.23 KEY_SELECT_UP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.7.2.24 KEY_TARE_DOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3.7.2.25 KEY_TARE_REPEAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3.7.2.26 KEY_TARE_UP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3.7.2.27 KEY_UNITS_DOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.7.2.28 KEY_UNITS_REPEAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.7.2.29 KEY_UNITS_UP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.7.2.30 KEY_ZERO_DOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.7.2.31 KEY_ZERO_REPEAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.7.2.32 KEY_ZERO_UP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.7.2.33 registerRpnEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.7.2.34 selectList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.7.2.35 setDate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.7.2.36 setRpnMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.7.2.37 setTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.7.2.38 unregisterRpnEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.8 labelCtrl Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.8.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.8.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.8.2.1 getLocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.8.2.2 getText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.8.2.3 getVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.8.2.4 reSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.8.2.5 setFont . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.8.2.6 setLocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.8.2.7 setText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.8.2.8 setVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.9 os Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.9.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.9.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.9.2.1 applicationPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
CONTENTS vii

3.9.2.2 checksumFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.9.2.3 compareDelta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.9.2.4 convertCsvFileToTable_LUA . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.9.2.5 convertTableToCsvFile_LUA . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
3.9.2.6 copyFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
3.9.2.7 cpuIdleFactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.9.2.8 createTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.9.2.9 deleteDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.9.2.10 deleteFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.9.2.11 deleteFolderAndFiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
3.9.2.12 equateDelta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
3.9.2.13 findFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
3.9.2.14 getSealedStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
3.9.2.15 getVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
3.9.2.16 getVersionInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
3.9.2.17 killTimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
3.9.2.18 listDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
3.9.2.19 logThisError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
3.9.2.20 makeDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
3.9.2.21 memoryMaxUsage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
3.9.2.22 memoryTest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
3.9.2.23 moveFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
3.9.2.24 registerFtpFileAddedEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
3.9.2.25 registerFtpFileDeletedEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
3.9.2.26 registerFtpFileReceivedEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
3.9.2.27 registerPasswordEnteredEvent . . . . . . . . . . . . . . . . . . . . . . . . . . 77
3.9.2.28 registerScriptCloseEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.9.2.29 registerUsbDriveMountEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.9.2.30 sleep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
3.9.2.31 stopwatch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
3.9.2.32 systemEvents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
3.9.2.33 unregisterFtpFileAddedEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
3.9.2.34 unregisterFtpFileDeletedEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
3.9.2.35 unregisterFtpFileReceivedEvent . . . . . . . . . . . . . . . . . . . . . . . . . . 80
3.9.2.36 unregisterPasswordEnteredEvent . . . . . . . . . . . . . . . . . . . . . . . . . 80
3.9.2.37 unregisterScriptCloseEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.9.2.38 unregisterUsbDriveMountEvent . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.10 pictureboxCtrl Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.10.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.10.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
viii CONTENTS

3.10.2.1 getLocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.10.2.2 getVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.10.2.3 setLocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.10.2.4 setVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.11 ports Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.11.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.11.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.11.2.1 getInputPollPeriod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.11.2.2 getInputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
3.11.2.3 getOutputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
3.11.2.4 registerSwitchChangeEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
3.11.2.5 setInputPollPeriod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
3.11.2.6 unregisterSwitchChangeEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
3.12 printer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
3.12.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
3.12.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
3.12.2.1 printFmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
3.12.2.2 registerPrinterJobStatusEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
3.12.2.3 registerPrinterStatusEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
3.12.2.4 reportFmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
3.12.2.5 unregisterPrinterJobStatusEvent . . . . . . . . . . . . . . . . . . . . . . . . . 88
3.12.2.6 unregisterPrinterStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
3.13 scaleCtrl Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
3.13.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
3.13.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
3.13.2.1 getLocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
3.13.2.2 getVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
3.13.2.3 setActiveValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
3.13.2.4 setActValVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
3.13.2.5 setLocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
3.13.2.6 setScaleNumVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
3.13.2.7 setUnitsVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
3.13.2.8 setVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
3.14 screensCtrl Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
3.14.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
3.14.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
3.14.2.1 addControl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
3.14.2.2 show . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
3.15 serial Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
3.15.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
CONTENTS ix

3.15.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94


3.15.2.1 close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
3.15.2.2 getConnectString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
3.15.2.3 getEomChar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
3.15.2.4 getMaxPorts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
3.15.2.5 getRx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
3.15.2.6 getRxCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
3.15.2.7 getSMATimeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
3.15.2.8 open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
3.15.2.9 registerEomEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
3.15.2.10 registerSMAOnlineEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
3.15.2.11 send . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
3.15.2.12 setEomChar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
3.15.2.13 setSMATimeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
3.15.2.14 unregisterEomEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
3.16 setpoint Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
3.16.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
3.16.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
3.16.2.1 activate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
3.16.2.2 configure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
3.16.2.3 deactivate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.16.2.4 getInverted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
3.16.2.5 getState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
3.16.2.6 lockOff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
3.16.2.7 lockOn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
3.16.2.8 registerInputEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
3.16.2.9 registerOutputEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
3.16.2.10 setInverted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
3.16.2.11 unlock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
3.16.2.12 unregisterInputEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
3.16.2.13 unregisterOutputEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
3.16.2.14 varGet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
3.16.2.15 varSet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
3.17 socket Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
3.17.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
3.17.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
3.17.2.1 connected . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
3.17.2.2 getEomChar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
3.17.2.3 getMaxSockets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
3.17.2.4 getRx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
x CONTENTS

3.17.2.5 getRxCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114


3.17.2.6 registerEomEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
3.17.2.7 send . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
3.17.2.8 setEomChar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
3.17.2.9 unregisterEomEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
3.18 textboxCtrl Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
3.18.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
3.18.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
3.18.2.1 getLocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
3.18.2.2 getText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
3.18.2.3 getVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
3.18.2.4 reSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
3.18.2.5 setFont . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
3.18.2.6 setLocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
3.18.2.7 setText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
3.18.2.8 setVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
3.19 utf8 Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
3.19.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
3.19.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
3.19.2.1 charToCodePoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
3.19.2.2 isLegalUtf8Char . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
3.19.2.3 isLegalUtf8String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
3.19.2.4 length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
3.19.2.5 toCodePoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
3.19.2.6 toLuaTable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
3.20 variables Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
3.20.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
3.20.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
3.20.2.1 clearTable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
3.20.2.2 createTable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
3.20.2.3 deleteTable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
3.20.2.4 readTable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
3.20.2.5 recall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
3.20.2.6 store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
3.21 weight Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
3.21.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
3.21.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
3.21.2.1 clearInmotion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
3.21.2.2 configureRateOfChange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
3.21.2.3 convertFromInternalCalUnit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
CONTENTS xi

3.21.2.4 convertToInternalCalUnit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131


3.21.2.5 convertWeight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
3.21.2.6 cycleActiveScale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
3.21.2.7 cycleActiveValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
3.21.2.8 cycleUnits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
3.21.2.9 getActiveScale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
3.21.2.10 getActiveValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
3.21.2.11 getCalibWeightUnits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
3.21.2.12 getConfig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
3.21.2.13 getCurrent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
3.21.2.14 getCurrentUnits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
3.21.2.15 getInmotion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
3.21.2.16 getLastPrint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
3.21.2.17 getNumActiveScales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
3.21.2.18 getPieceWeight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
3.21.2.19 getRefreshLastPrint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
3.21.2.20 getSampleSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
3.21.2.21 getTarget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
3.21.2.22 graphEnable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
3.21.2.23 inmotion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
3.21.2.24 registerAccumCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
3.21.2.25 registerHoldCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
3.21.2.26 registerInmotionCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . 151
3.21.2.27 registerInmotionErrorEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
3.21.2.28 registerInmotionStartEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
3.21.2.29 registerPrintCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
3.21.2.30 registerSampleCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . 153
3.21.2.31 registerSelectCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
3.21.2.32 registerTareCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
3.21.2.33 registerUnitsCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
3.21.2.34 registerWeightChangeEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
3.21.2.35 registerZeroCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
3.21.2.36 requestAccum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
3.21.2.37 requestHold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
3.21.2.38 requestKeyboardTare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
3.21.2.39 requestPresetTare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
3.21.2.40 requestPrint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
3.21.2.41 requestSample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
3.21.2.42 requestTare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
3.21.2.43 requestTareClear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
xii CONTENTS

3.21.2.44 requestZero . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161


3.21.2.45 requestZeroCheckWeigh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
3.21.2.46 resetAccum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
3.21.2.47 resetPeakMax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
3.21.2.48 resetPeakMin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
3.21.2.49 scaleEnabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
3.21.2.50 setAccum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
3.21.2.51 setActiveScale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
3.21.2.52 setActiveValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
3.21.2.53 setBar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
3.21.2.54 setCheck . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
3.21.2.55 setConfig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
3.21.2.56 setCurrentUnits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
3.21.2.57 setDisplayVariable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
3.21.2.58 setPieceWeight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
3.21.2.59 setSampleSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
3.21.2.60 setTarget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
3.21.2.61 unitStrToUnitIndex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
3.21.2.62 unregisterAccumCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . 169
3.21.2.63 unregisterHoldCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
3.21.2.64 unregisterInmotionCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . 170
3.21.2.65 unregisterInmotionErrorEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
3.21.2.66 unregisterInmotionStartEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
3.21.2.67 unregisterPrintCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
3.21.2.68 unregisterSampleCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . 170
3.21.2.69 unregisterSelectCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . 171
3.21.2.70 unregisterTareCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
3.21.2.71 unregisterUnitsCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . 171
3.21.2.72 unregisterWeightChangeEvent . . . . . . . . . . . . . . . . . . . . . . . . . . 171
3.21.2.73 unregisterWeightUpdateEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
3.21.2.74 unregisterZeroCompleteEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

Index 173

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
Chapter 1

The Avery Weigh-Tronix Lua API Reference Manual

This is the PDF file for the Avery Weigh-Tronix Lua API functions.
2 The Avery Weigh-Tronix Lua API Reference Manual

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
Chapter 2

Class Index

2.1 Namespace List

Here are the classes, structs, unions and interfaces with brief descriptions:
buttonCtrl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
fmtPrint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
json . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
keypad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
labelCtrl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
os . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
pictureboxCtrl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
printer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
scaleCtrl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
screensCtrl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
serial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
setpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
socket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
textboxCtrl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
utf8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
weight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
4 Class Index

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
Chapter 3

Class Documentation

3.1 buttonCtrl Class Reference

Public Member Functions

• getLocation (checkButton)
getX, getY = buttonCtrl:getLocation(checkButton)

• getText (checkButton)
getText = buttonCtrl:getText(checkButton)

• getVisible (checkButton)
visible = buttonCtrl:getVisible(checkButton)

• reSize (checkButton, getX, getY)


buttonCtrl:reSize(checkButton, getX, getY)

• setFont (checkButton, font)


buttonCtrl:setFont(checkButton, font)

• setLocation (checkButton, getX, getY)


buttonCtrl:setLocation(checkButton, getX, getY)

• setText (checkButton, getText)


buttonCtrl:setText(checkButton, getText)

• setVisible (checkButton, visible)


buttonCtrl:setVisible(checkButton, visible)

3.1.1 Detailed Description

The buttonCtrl namespace deals with the the attributes connected to the buttons that appear on the system. They
handle the button's location, text, visibility, size and font.

3.1.2 Member Function Documentation

3.1.2.1 buttonCtrl:getLocation ( checkButton )


6 Class Documentation

getX, getY = buttonCtrl:getLocation(checkButton)

Parameters
checkButton - (String) The button we want to get the location of.

Returns

getX - (Number) The X-coordinate of the starting point of the button.


getY - (Number) The Y-coordinate of the starting point of the button.

1 -- Gets the location of the button


2 local button = "button1"
3 local getX, getY = buttonCtrl:getLocation(button)
4
5 print(string.format("%s is at location %d, %d", button, getX, getY)) -- Prints to the Lua Console (located
at Ztools -> Zedit -> Output)

This function gets the location of the button on the scale.

3.1.2.2 buttonCtrl:getText ( checkButton )


getText = buttonCtrl:getText(checkButton)

Parameters
checkButton - (String) The button we want to get text for.

Returns

getText - (String) The text that will be applied to the button.

1 -- Gets the text for a picturebox


2 local button = "button1"
3 local getText = buttonCtrl:getText(button)
4
5 print(string.format("The text for %s is: %s", button, getText)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)

This function gets the text for the button on the scale.

3.1.2.3 buttonCtrl:getVisible ( checkButton )


visible = buttonCtrl:getVisible(checkButton)

Parameters
checkButton - (String) The button that we are checking the visibility of.

Returns

visible - (Boolean) Determines the visibility of the button on the scale.

1 -- Get the visibility of the button


2 local button = "button2"
3 local visibility = buttonCtrl:getVisibility(button)
4
5 print(string.format("The visibility of %s is: %c", button, visibility)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function gets the visibility of the button on the scale.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.1 buttonCtrl Class Reference 7

3.1.2.4 buttonCtrl:reSize ( checkButton , getX , getY )


buttonCtrl:reSize(checkButton, getX, getY)

Parameters
checkButton - (String) The button on the scale that we want to resize.
getX - (Number) The X-coordinate of the starting point of the button.
getY - (Number) The Y-coordinate of the starting point of the button.

1 -- Re-size the button


2 local button = "button3"
3 local getX = 12
4 local getY = 15
5
6 buttonCtrl:reSize(button, getX, getY)

This function resizes the button on the scale.

3.1.2.5 buttonCtrl:setFont ( checkButton , font )


buttonCtrl:setFont(checkButton, font)

Parameters
checkButton - (String) The button we want to set the font type to.
font - (Number) Type of font that is being set onto the button.

1 -- Set the font for the button


2 local button = "button3"
3 local fontType = 18 --Number associated with the font type
4
5 buttonCtrl:setFont(button, fontType)

This function sets the font type for on the button on the scale.

3.1.2.6 buttonCtrl:setLocation ( checkButton , getX , getY )


buttonCtrl:setLocation(checkButton, getX, getY)

Parameters
checkButton - (String) Button that is having its location set.
getX - (Number) The X-coordinate of the starting point of the button.
getY - (Number) The Y-coordinate of the starting point of the button.

1 -- Sets the location of the button


2 local button = "button2"
3 local getX = 76
4 local getY = 20
5
6 buttonCtrl:setLocation(button, getX, getY)

This function sets the location of the button on the scale.

3.1.2.7 buttonCtrl:setText ( checkButton , getText )


buttonCtrl:setText(checkButton, getText)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
8 Class Documentation

Parameters
checkButton - (String) The button we will be applying text to.
getText - (String) The text we will be applying to the button.

1 -- Sets the text for the button


2 local button = "button1"
3 local textButton = "Push Me"
4
5 buttonCtrl:setText(button, textButton)

This function sets the text onto the button provided.

3.1.2.8 buttonCtrl:setVisible ( checkButton , visible )


buttonCtrl:setVisible(checkButton, visible)

Parameters
checkButton - (String) The button that we want to set the visibility of.
visible - (Boolean) Determines whether or not the button is visible or not.

1 -- Set the visibility of the button


2 local button = "button3"
3 local visibility = true
4
5 buttonCtrl:setVisible(button, visibility)

This function sets the visibility of the button on the scale.

3.2 display Class Reference

Public Member Functions

• clrDisplayBusy ()
awtx.display.clrDisplayBusy()

• clrDisplayFlash ()
awtx.display.clrDisplayFlash()

• clrSegments (newSegmentHi, newSegmentLo)


awtx.display.clrSegments(newSegmentHi, newSegmentLo)

• doBeep ()
awtx.display.doBeep()

• getBatteryControl ()
awtxControl = awtx.display.getBatteryControl()

• getBuzzer ()
result = awtx.display.getBuzzer()

• getBuzzerEnable ()
result = awtx.display.getBuzzerEnable()

• getGraphControl ()

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.2 display Class Reference 9

awtxGraph = awtx.display.getGraphControl()

• getLabelControl ()
awtxLabel = awtx.display.getLabelControl()

• getMode ()
currentMode = awtx.display.getMode()

• getScaleControl ()
awtxScale = awtx.display.getScaleControl()

• getSetpointControl ()
awtxControl = awtx.display.getSetpointControl()

• setBuzzer (newVal)
awtx.display.setBuzzer(newVal)

• setBuzzerEnable (newVal)
awtx.display.setBuzzerEnable(newVal)

• setDisplayBusy ()
awtx.display.setDisplayBusy()

• setDisplayFlash ()
awtx.display.setDisplayFlash()

• setMode (newMode)
awtx.display.setMode(newMode)

• setOneSegment (newSegmentHi, newSegmentLo)


awtx.display.setOneSegment(newSegmentHi, newSegmentLo)

• setSegment (newSegmentHi, newSegmentLo)


awtx.display.setSegment(newSegmentHi, newSegmentLo)

• setSegments (newSegmentsHi, newSegmentsLo)


awtx.display.setSegments(newSegmentsHi, newSegmentsLo)

• writeLine (message, displayTime)


awtx.display.writeLine(message, displayTime)

3.2.1 Detailed Description

The display namespace handles with the items that will be displayed onto the system's screen. It handles the
segments displayed, whether the display is or is not busy, handles the buzzers and beeps of the system, and other
various attributes that are listed below.

3.2.2 Member Function Documentation

3.2.2.1 awtx.display.clrDisplayBusy ( )
awtx.display.clrDisplayBusy()

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
10 Class Documentation

1 --clear the display


2 awtx.display.clrDisplayBusy()

Clears the display back to normal.

3.2.2.2 awtx.display.clrDisplayFlash ( )
awtx.display.clrDisplayFlash()

1 -- Clears away a display flash from the screen


2 awtx.display.clrDisplayFlash()

Clears off the display flash.

3.2.2.3 awtx.display.clrSegments ( newSegmentHi , newSegmentLo )


awtx.display.clrSegments(newSegmentHi, newSegmentLo)

Parameters
newSegmentHi - (Number) The new segments hi 32 bits.
newSegmentLo - (Number) The new segments lo 32 bits.

1 -- Clear segments from 25 - 30


2 awtx.display.clrSegments(30, 25)

This function uses binary interpretation of the display annunciator to turn off the segments mapped to the high bits
of the two passed integers. The low segments do not change from their current state.
Table for Bit Position and the Annunciator associated with bit:
7 - Preset Tare
12 - Motion
13 - Center Zero
15 - Battery Frame
16 - Battery Segment 1
17 - Battery Segment 2
18 - Battery Segment 3
19 - Dot 1
20 - Dot 2
21 - Dot 3
22 - Dot 4
23 - Dot 5
24 - Bar 1
25 - Bar 2
26 - Bar 3
27 - Bar 4
28 - Bar 5

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.2 display Class Reference 11

29 - Bar 6
36 - Setpoint 1
37 - Setpoint 2
38 - Setpoint 3
In order to have clrSegments function correctly, the display mode must be set to USER. The SCALE display mode
overrides all of the segments except for Dots 2-5.

3.2.2.4 awtx.display.doBeep ( )
awtx.display.doBeep()

1 --Tell the system to beep once number is at or above 10


2 local number = 0
3
4 for i = 1, 10 do
5 if number < 10 then
6 number = number + 1
7 else
8 awtx.display.doBeep()
9 end
10 end
11
12 print(number) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)

This function tells the system to make a beeping sound.

3.2.2.5 awtx.display.getBatteryControl ( )
awtxControl = awtx.display.getBatteryControl()

Returns

awtxControl - (Function) Handler that controls the levels that are stored onto the system to be used to show
the control values.

1 -- Grab the battery control level for the system


2 local awtxControl = awtx.display.getBatteryControl()
3
4 print(string.format("The system’s battery level is %s", awtxControl)) -- Prints to the Lua Console (located
at Ztools -> Zedit -> Output)

This function is designed to grab the battery level of the system and display it on the system's screen.

3.2.2.6 awtx.display.getBuzzer ( )
result = awtx.display.getBuzzer()

Returns

result - (Number) Status of the buzzer value to determine whether or not the buzzer needs to sound. Can be
equal to either 0 for Disabled or 1 for Enabled.

1 --Simple assignment of the buzzer


2
3 local getBuzz = awtx.display.getBuzzer()

Grabs the buzzer (if it has been enabled) to buzz on the system.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
12 Class Documentation

3.2.2.7 awtx.display.getBuzzerEnable ( )
result = awtx.display.getBuzzerEnable()

Returns

result - (Number) Status of the buzzer value to determine whether or not the buzzer has been enabled. Can
be equal to either 0 for Disabled or 1 for Enabled.

1 --Tells the system to get the buzzer ready to be set off.


2 local buzzer = awtx.display.getBuzzerEnable()

This function enables the use of the buzzer for the system.

3.2.2.8 awtx.display.getGraphControl ( )
awtxGraph = awtx.display.getGraphControl()

Returns

awtxGraph - (Function) Handler that controls all of the graphs created to show weight placed onto the scale.

1 -- Grabs the graph and displays it on the screen of the system.


2 local awtxGraph = awtx.display.getGraphControl()
3
4 print(string.format("The graph being displayed is: %d", awtxGraph)) -- Prints to the Lua Console (located
at Ztools -> Zedit -> Output)

This function grabs a graph of the weight that has been placed on the system and displays it on the screen.

3.2.2.9 awtx.display.getLabelControl ( )
awtxLabel = awtx.display.getLabelControl()

Returns

awtxLabel - (Function) Handler that controls all the labeled user data on the system.

1 -- Grabs the label for the user data being inputted


2 local awtxLabel = awtx.display.getLabelControl()
3 print(string.format("The table for the labels is %d", awtxLabel)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)

This function controls the labels being placed onto the user data on the system.

3.2.2.10 awtx.display.getMode ( )
currentMode = awtx.display.getMode()

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.2 display Class Reference 13

Returns

currentMode - (Number) The current display mode.

1 local SCALE_MODE = 0
2 local SCRIPT_MODE = 1
3
4 if (awtx.display.getMode() == SCRIPT_MODE) then
5 print("This Lua script currently controls the display") -- Prints to the Lua Console (located at Ztools
-> Zedit -> Output)
6 else
7 print("The scale currently controls the display.")
8 end

This function gets the current display mode.


The Scale's display can either be controlled by the Lua script or by the Scale itself to show the current weight. This
function returns 0 or 1 to indicate who is currently owning the display.

3.2.2.11 awtx.display.getScaleControl ( )
awtxScale = awtx.display.getScaleControl()

Returns

awtxScale - (Function) Handler that controls the scales that have been used.

1 -- Grabs the current scale in use


2 local awtxScale = awtx.display.getScaleControl()
3
4 print(string.format("The scale currently in use is: %d", awtxScale)) -- Prints to the Lua Console (located
at Ztools -> Zedit -> Output)

This function controls what scale is currently in use.

3.2.2.12 awtx.display.getSetpointControl ( )
awtxControl = awtx.display.getSetpointControl()

Returns

awtxControl - (Function) Handler that controls the levels that are stored onto the system to be used to show
the control values.

1 -- Get the setpoint value


2
3 local awtxControl = awtx.display.getSetpointControl()
4 print(string.format("The setpoint values are %d", awtxControl)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)

This function is in charge of controlling the setpoint values on the system.

3.2.2.13 awtx.display.setBuzzer ( newVal )


awtx.display.setBuzzer(newVal)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
14 Class Documentation

Parameters
newVal - (Boolean) Determines state of buzzer; if 1 buzzer turns on, if 0 buzzer turns off.

1 --Tells the buzzer to either be off or on.


2
3 local goBuzz = 0
4 local noBuzz = 5
5
6 for i = 1, 10 do
7 goBuzz = goBuzz + 1
8 if (goBuzz > noBuzz) then
9 awtx.display.setBuzzer(1)
10 break
11 else
12 awtx.display.setBuzzer(0)
13 end
14 end

Sets up the buzzer (if it has been enabled) to buzz on the system.

3.2.2.14 awtx.display.setBuzzerEnable ( newVal )


awtx.display.setBuzzerEnable(newVal)

Parameters
newVal - (Number) Sets the buzzer's enable status.

1 --Tells the system to set the buzzer off.


2 awtx.display.setBuzzerEnable(1)

Determines if the buzzer is enabled on the system.

3.2.2.15 awtx.display.setDisplayBusy ( )
awtx.display.setDisplayBusy()

1 -- Set the display to ’busy’


2
3 awtx.display.setDisplayBusy()

This function sets the display to 'busy'.

3.2.2.16 awtx.display.setDisplayFlash ( )
awtx.display.setDisplayFlash()

1 -- Makes the display flash.


2
3 local flashScreen = 1
4
5 if (flashScreen > 0) then
6 awtx.display.setDisplayFlash()
7 end

This function sets the display to flash.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.2 display Class Reference 15

3.2.2.17 awtx.display.setMode ( newMode )


awtx.display.setMode(newMode)

Parameters
newMode - (Number) The new display mode

1 local SCALE_MODE = 0
2 local SCRIPT_MODE = 1
3
4 -- Take control of the display but remember the last mode
5 local lastMode = awtx.display.setMode(SCRIPT_MODE)
6
7 awtx.display.writeLine("Hello", 2000)
8
9 -- restore the last mode of the display
10 awtx.display.setMode(lastMode)

This function returns the previous display owner so it can be reset to the previous state after the desired display
operations have completed.
The Scale's display can either be controlled by the Lua script or by the Scale itself to show the current weight. This
function returns 0 or 1 to indicate who is currently owning the display.

3.2.2.18 awtx.display.setOneSegment ( newSegmentHi , newSegmentLo


)
awtx.display.setOneSegment(newSegmentHi, newSegmentLo)

Parameters
newSegmentHi - (Number) The new desired hi segment bit. 0 or 1 are valid inputs.
newSegmentLo - (Number) The new desired lo segment bit. 0 or 1 are valid inputs.

1 -- Create one new segment on the display


2 awtx.display.setOneSegment(1,0)

This function sets the segments to exactly what is transmitted in the high and low fields. The high bits are turned on
and the low bits are turned off.
Table for Bit Position and the Annunciator associated with bit:
7 - Preset Tare
12 - Motion
13 - Center Zero
15 - Battery Frame
16 - Battery Segment 1
17 - Battery Segment 2
18 - Battery Segment 3
19 - Dot 1
20 - Dot 2
21 - Dot 3
22 - Dot 4
23 - Dot 5

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
16 Class Documentation

24 - Bar 1
25 - Bar 2
26 - Bar 3
27 - Bar 4
28 - Bar 5
29 - Bar 6
36 - Setpoint 1
37 - Setpoint 2
38 - Setpoint 3
For setOneSegment to function correctly, the display mode should be set to USER. The SCALE display mode
overrides all segments except for Dots 2-5.

3.2.2.19 awtx.display.setSegment ( newSegmentHi , newSegmentLo )


awtx.display.setSegment(newSegmentHi, newSegmentLo)

Parameters
newSegmentHi - (Number) The new segments hi 32 bits.
newSegmentLo - (Number) The new segments lo 32 bits.

1 -- Sets up a new segment between 24 and 29


2 awtx.display.setSegment(29, 24)

This function uses binary interpretation of the display annunciator segments to illuminate the segments mapped to
the high bits of the two passed in integers. The low segments do not change from their current state during this
process.
Table for Bit Position and the Annunciator associated with bit:
7 - Preset Tare
12 - Motion
13 - Center Zero
15 - Battery Frame
16 - Battery Segment 1
17 - Battery Segment 2
18 - Battery Segment 3
19 - Dot 1
20 - Dot 2
21 - Dot 3
22 - Dot 4
23 - Dot 5
24 - Bar 1
25 - Bar 2
26 - Bar 3
27 - Bar 4
28 - Bar 5

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.2 display Class Reference 17

29 - Bar 6
36 - Setpoint 1
37 - Setpoint 2
38 - Setpoint 3
In order to have setSegment function correctly, the display mode needs to be set to USER. The SCALE display
mode overrides all of the segments except for Dots 2-5.

3.2.2.20 awtx.display.setSegments ( newSegmentsHi , newSegmentsLo


)
awtx.display.setSegments(newSegmentsHi, newSegmentsLo)

Parameters
newSegmentsHi - (Number) The new desired high segment bits. 0 or 1 are valid inputs.
newSegmentsLo - (Number) The new desired low segment bits. 0 or 1 are valid inputs.

1 -- Set up a new segment.


2 awtx.display.setSegments(18,16)

This function uses binary interpretation of the display annunciator segments to illuminate the segments mapped to
the high bits of the two passed in integers. The low segments do not change from their current state.
Table for Bit Position and the Annunciator associated with bit:
7 - Preset Tare
12 - Motion
13 - Center Zero
15 - Battery Frame
16 - Battery Segment 1
17 - Battery Segment 2
18 - Battery Segment 3
19 - Dot 1
20 - Dot 2
21 - Dot 3
22 - Dot 4
23 - Dot 5
24 - Bar 1
25 - Bar 2
26 - Bar 3
27 - Bar 4
28 - Bar 5
29 - Bar 6
36 - Setpoint 1
37 - Setpoint 2
38 - Setpoint 3

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
18 Class Documentation

In order to have setSegments function correctly, the display mode must be set to USER. The SCALE display mode
overrides all of the segments except Dots 2-5.

3.2.2.21 awtx.display.writeLine ( message , displayTime )


awtx.display.writeLine(message, displayTime)

Parameters
message - (String) The message to write on the scale's display.
displayTime - (Number) (Optional) The length of time to display the message in milliseconds.

1 local SCALE_MODE = 0
2 local SCRIPT_MODE = 1
3
4 -- Take control of the display but remember the last mode
5 local lastMode = awtx.display.setMode(SCRIPT_MODE)
6
7 -- Show "Hello" and "World" for 2000ms each (2 seconds)
8 awtx.display.writeLine("Hello", 2000)
9 awtx.display.writeLine("World", 2000)
10
11 -- Show a number for half a second
12 awtx.display.writeLine("1234.56")
13 awtx.os.sleep(500)
14
15 -- restore the last mode of the display
16 awtx.display.setMode(lastMode)

Writes a message to the segment display.


For models with a segmented digit display, message is restricted to use the exiting segments and some of the digits
may not appear as you expect.
The length of the string is also limited to the number of digits on the display.

3.3 fmtPrint Class Reference

Public Member Functions

• get (formatNumber)
formatString = awtx.fmtPrint.get(formatNumber)

• getRaw (formatNumber)
formatString = awtx.fmtPrint.getRaw(formatNumber)

• printBuffer (tempPrintFmt)
returnVal = awtx.fmtPrint.printBuffer(tempPrintFmt)

• registerVarChangeReqEvent (handler)
awtx.fmtPrint.registerVarChangeReqEvent(handler)

• set (formatNum, formatString)


result = awtx.fmtPrint.set(formatNum, formatString)

• unregisterVarChangeReqEvent ()
awtx.fmtPrint.unregisterVarChangeReqEvent()

• varGet (luaVarIndex)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.3 fmtPrint Class Reference 19

value, desc, awtxVarType = awtx.fmtPrint.varGet(luaVarIndex)

• varSet (luaVarIndex, value, desc, awtxVarType)


result = awtx.fmtPrint.varSet(luaVarIndex, value, desc, awtxVarType)

3.3.1 Detailed Description

The fmtPrint namespace handles the output from the system, primarily the formatting of the items being printed
out. It handles the UTF8 codepoints, variable change requests, collects data to be printed out, and other various
functions listed below.

3.3.2 Member Function Documentation

3.3.2.1 awtx.fmtPrint.get ( formatNumber )


formatString = awtx.fmtPrint.get(formatNumber)

Parameters
formatNumber - (Number) The Print format number. This is the print format index for the Print format string,
valid range 1 to 40.

Returns

formatString - (String) Returns the contents of the tokenized print format string currently stored at the specified
print format index.

1 -- Set a Print string with some tokens into print format 1


2 awtx.fmtPrint.set(1, "{T.GWT.1}, {T.UNIT.1}")
3
4 local formatStr = awtx.fmtPrint.get(1) -- Grab print format 1 and display it onto the Lua Console (which
can be found at Ztools -> Zedit -> Output).
5 print(formatStr) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
6
7 local bufferStr = awtx.fmtPrint.printBuffer(formatStr) -- Print off the values in formatStr on startup.
8 print(bufferStr) -- Prints to the output.

This function retrieves the tokenized print format.


There are 40 possible print format slots ranging from 1 to 40. If any tokens are present in the string then this function
will return the string in its expanded tokenized form.

3.3.2.2 awtx.fmtPrint.getRaw ( formatNumber )


formatString = awtx.fmtPrint.getRaw(formatNumber)

Parameters
formatNumber - (Number) The Print format number. This is the storage index for the Print format string, valid
range 1 to 40.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
20 Class Documentation

Returns

formatString - (String) Returns the print format string currently stored at the specified print format index. If for
example the print format string has not been previously defined this function will return a string containing an
error code.

1 -- Set a Print string with some tokens into Print format slot 4
2 local result = awtx.fmtPrint.set(4, "Gross = {T.GWT.1}")
3 -- Get Print format string for slot 4 in codepoint form
4 local prtStr = awtx.fmtPrint.getRaw(4)
5
6 -- Tokens are internally stored in the UTF8 PUA area range, hence we can’t just
7 -- print(prtStr) in the usual way as it would display garbage. (GWT is stored internally as U+F0001)
8 awtx.utf8.toCodePoints(prtStr)
9
10 -- Example output
11 -- 1: U+00047 LATIN CAPITAL LETTER G
12 -- 2: U+00072 LATIN SMALL LETTER r
13 -- 3: U+0006F LATIN SMALL LETTER o
14 -- 4: U+00073 LATIN SMALL LETTER s
15 -- 5: U+00073 LATIN SMALL LETTER s
16 -- 6: U+00020 SPACE
17 -- 7: U+0003D EQUALS SIGN
18 -- 8: U+00020 SPACE
19 -- 9: U+F0001 GWT Print Token (1)
20 --10: U+00031 DIGIT ONE

This function is useful as a debug function to examine the UTF8 codepoints contained in a print string
As this function will return an output string with tokens in the high number UTF8 PUA region, it cannot be printed
out with the usual Lua print() function.

3.3.2.3 awtx.fmtPrint.printBuffer ( tempPrintFmt )


returnVal = awtx.fmtPrint.printBuffer(tempPrintFmt)

Parameters
tempPrintFmt - (String) A temporary print format string to be filled in with current information.

Returns

returnVal - (String) Completed print string based on tempPrintFmt.

1 -- Define a temporary print format to be generated.


2 local tempPrintFmt = "Gross Wt = {T.GWT.1}"
3
4 -- Pass the temporary print format to be processed and filled with current information.
5 local printStr = awtx.fmtPrint.printBuffer(tempPrintFmt)
6
7 -- Display the formatted string on the Lua console (which can be found at Ztools -> Zedit -> Output)
8 print(printStr) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)

Takes a temporary print format string and returns a completed print string filled with current token information.
This function runs the passed in string argument through the same token parser standard print format strings use.
The formatted string is then returned with any tokens filled in with current system information.

3.3.2.4 awtx.fmtPrint.registerVarChangeReqEvent ( handler )


awtx.fmtPrint.registerVarChangeReqEvent(handler)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.3 fmtPrint Class Reference 21

Parameters
handler - (Function) The user-defined callback function to call when a lua variable change is re-
quested.

1 function onLuaVarChangeReq(scaleNum, slotNum, varValue)


2 if printTokens[slotNum].varLabel ~= "Invalid" then
3 if printTokens[slotNum].varFunct ~= "" then
4 -- Verify that the token has been initialized and a function has been assigned,
5 -- then call the function with the new value returned in the event.
6 printTokens[slotNum].varFunct(varValue)
7 end
8 end
9 end
10
11 -- Register the previously defined function to be called when event occurs.
12 awtx.fmtPrint.registerVarChangeReqEvent(onLuaVarChangeReq)

Registers a Lua event handler that will be called when a variable change request is made.
You can use this event handler to validate any change requests that come in from external devices.
Protocols that communicate with an SMA host or a PLC controller have the ability to request making a change to a
print variable that they do not get direct access. They only request a change to prevent a rogue connected device
from mistakenly updating a print variable that the application does not want changed.
As with any event handler, the amount of work done inside the handler function should be minimal.

3.3.2.5 awtx.fmtPrint.set ( formatNum , formatString )


result = awtx.fmtPrint.set(formatNum, formatString)

Parameters
formatNum - (Number) The Print format number. This is the index for the Print format string, valid range
1 to 40.
formatString - (String) The template string to be stored. 0 for Success, Negative number for error.

Returns

result - (Number) The result for the set operation. This function parses the input 'formatString' to check it is
valid.

1 -- Set a Print string with some tokens into Print format slot 4
2 local result = awtx.fmtPrint.set(4, "The Gross Weight is {T.GWT.1} {T.UNIT.1}")
3 print(string.format("Set result is %d", result)) -- Prints to the Lua Console (located at Ztools -> Zedit
-> Output)
4
5 --Example output
6 --Set result is 0

1 -- Set a Print string with a wrong into Print format slot 4


2 local result = awtx.fmtPrint.set(4, "The Gross Weight is {T.GWT.1} {T.UNIT.1}")
3 print(string.format("Set result is %d", result)) -- Prints to the Lua Console (located at Ztools -> Zedit
-> Output)
4
5 if result == 0 then
6 -- The input string is invalid, so print out an error description
7 local prtStr = awtx.fmtPrint.get(4)
8 print(prtStr)
9 end
10
11 --Example output
12 --Set result is -10
13 --String Set Error -10 at index 30

This function stores a Print format template string in the Scale. This string can then be printed out at a later time to
an external port, Serial, Ethernet, USB etc.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
22 Class Documentation

Possible values for result:


0 - PRINT FORMAT STRING IS OK
-1 - PRINT FORMAT NUMBER OUT OF RANGE
-2 - ERROR PARSER NO MEMORY
-3 - ERROR L OR T TOKEN CHAR NOT FOUND
-4 - ERROR END CURLY BRACE DELIM MISSING
-5 - ERROR PRINT TOKEN INVALID RANGE
-6 - ERROR LUA VAR INDEX INVALID RANGE
-7 - ERROR ASPECT DATA INVALID
-8 - ERROR PRINT STRING INVALID UTF8
-9 - ERROR OPTIONS LEFT BRACKET NOT FOUND
-10 - ERROR OPTIONS RIGHT BRACKET NOT FOUND
-11 - ERROR DOT SEPARATOR NOT FOUND
-12 - ERROR TOKEN TAG STRING INVALID
-13 - ERROR UTF8 CODEPOINT TOO LARGE
-14 - ERROR TOKEN TOO LARGE
-15 - ERROR WITHIN OPTIONAL PARAMS
There are 40 possible print format slots that can contain a Print string. If the input string is valid, then it is stored in
non-volatile memory in the indicator.
formatString can contain tokens (ex: {T.GWT.1}) and can contain utf8 foreign language characters.

3.3.2.6 awtx.fmtPrint.unregisterVarChangeReqEvent ( )
awtx.fmtPrint.unregisterVarChangeReqEvent()

1 --Unregisters any existing event handler


2 awtx.fmtPrint.unregisterVarChangeReqEvent()

Unregisters a registered Lua event handler that has already been registered
This function has no effect if there are no registered variable change requests.

3.3.2.7 awtx.fmtPrint.varGet ( luaVarIndex )


value, desc, awtxVarType = awtx.fmtPrint.varGet(luaVarIndex)

Parameters
luaVarIndex - (Number) The Index of the Lua variable to retrieve. Valid range is 1 to 100.

Returns

value - (Variable) The value of the variable stored in the requested slot.
desc - (String) The description of the Lua variable.
awtxVarType - (Number) Number to describe the type of the Lua variable, integer, float, etc.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.3 fmtPrint Class Reference 23

1 -- Similar values to these are predefined in ReqConstants.lua


2 local AWTX_TYPE_UNDEFINED = 0
3 local AWTX_TYPE_WEIGHT = 1
4 local AWTX_TYPE_STRING = 2
5 local AWTX_TYPE_DATE = 3
6 local AWTX_TYPE_TIME = 4
7 local AWTX_TYPE_FLOAT = 5
8 local AWTX_TYPE_INTEGER = 6
9 local AWTX_TYPE_BOOLEAN = 7
10
11 local arraySlot = 5
12 -- Retreive information stored in selected array slot
13 local value, desc, awtxVarType = awtx.fmtPrint.varGet(arraySlot)
14
15 print(string.format("Value held at array slot %d represents %s.", arraySlot, desc)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)
16
17 if awtxVarType == AWTX_TYPE_WEIGHT or
18 awtxVarType == AWTX_TYPE_FLOAT then
19 print(string.format("Value at array slot %d is: %f.", arraySlot, value))
20 else if awtxVarType == AWTX_TYPE_STRING or
21 awtxVarType == AWTX_TYPE_DATE or
22 awtxVarType == AWTX_TYPE_TIME then
23 print(string.format("Value at array slot %d is: %s.", arraySlot, value))
24 else if awtxVarType == AWTX_TYPE_INTEGER then
25 print(string.format("Value at array slot %d is: %d.", arraySlot, value))
26 else if awtxVarType == AWTX_TYPE_BOOLEAN then
27 if value == 1 then
28 print(string.format("Value at array slot %d is true.", arraySlot))
29 else
30 print(string.format("Value at array slot %d is false.", arraySlot))
31 end
32 end

This function retreives a Lua variable from the system array. In this context a 'Lua Variable' is a bit of a misnomer
as it is actually a collection of data, a value, and a verbal description type definition.
where awtxVarType is:
0 = AWTX_TYPE_UNDEFINED
1 = AWTX_TYPE_WEIGHT
2 = AWTX_TYPE_STRING
3 = AWTX_TYPE_DATE
4 = AWTX_TYPE_TIME
5 = AWTX_TYPE_FLOAT
6 = AWTX_TYPE_INTEGER
7 = AWTX_TYPE_BOOLEAN
There are 1 to 100 Lua variables available that the program can set. These Lua variables are used when the
program wishes to pass data through into a Label Print format.

3.3.2.8 awtx.fmtPrint.varSet ( luaVarIndex , value , desc , awtxVarType


)
result = awtx.fmtPrint.varSet(luaVarIndex, value, desc, awtxVarType)

Parameters
luaVarIndex - (Number) The Index of the Lua variable to store some data into. Valid range is 1 to 100.
value - (Number, string, or boolean) This is the value of the Lua variable, this can be a Lua string,
number or boolean dependent on context.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
24 Class Documentation

desc - (String) (Optional) This is an optional description of the Lua variable, this must be a Lua
string.
awtxVarType - (Number) This is an optional number that describes the type of the Lua variable, integer,
float, etc..

Returns

result - (Number) The result code for the awtx.frmPrint.varSet() function

1 local AWTX_TYPE_INTEGER = 6
2 -- Store Lua variable into array slot number 78. An integer of "Widget Count" = 12345
3 local result = awtx.fmtPrint.varSet(78, 12345, "Widget Count", AWX_TYPE_INTEGER)
4
5 -- Variable ’12345’ would be accessed in a Print format with "{A.78.1};"
6 -- Description "Widget Count" would be accessed in a Print format with "{A.78.2};"

1 local result = awtx.fmtPrint.varSet(78, 12345, "Widget Count") -- example with 3 parameters, array slot 78
2
3 local result = awtx.fmtPrint.varSet(25, 12345) -- example with only 2 parameters, slot 25

1 local AWTX_TYPE_STRING = 2
2
3 -- Example that uses all parameters, a Car Registration. Store in array slot 5
4 local result = awtx.fmtPrint.varSet(5, "SKP3 VGK", "Vehicle Registration", AWTX_TYPE_STRING)
5
6 -- Car Reg ’SKP3 VGK’ would be accessed in a Print format with "{A.5.1};"
7 -- Description "Vehicle Registration" would be accessed in a Print format with "{A.5.2};"

This function stores a Lua variable into an array. In this context a 'Lua Variable' is a bit of a misnomer as it is actually
a collection of data, a value, a textual description type definition
where: awtxVarType is
0 = AWTX_TYPE_UNDEFINED
1 = AWTX_TYPE_WEIGHT
2 = AWTX_TYPE_STRING
3 = AWTX_TYPE_DATE
4 = AWTX_TYPE_TIME
5 = AWTX_TYPE_FLOAT
6 = AWTX_TYPE_INTEGER
7 = AWTX_TYPE_BOOLEAN
where: result is
0 = SUCCESS
-1 = Error: Function should take 2 to 4 parameters
-2 = Error: Function Parameter 1 is an invalid Lua type, should be a number
-3 = Error: Function Parameter 1 should be in range 1 to 100
-4 = Error: Function Parameter 4 is an invalid Lua type, should be a Lua number in range 0 to 6
-5 = Error: Function Parameter 3 is an invalid Lua type, its should be a Lua string
-6 = Error: Function Parameter 2 is an invalid Lua type, it should be either Lua string, number or boolean
There are 1 to 100 Lua variables available that the program can set. These Lua variables are used when the
program wishes to pass data through into a Label Print format.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.4 graphics Class Reference 25

3.4 graphics Class Reference

Public Member Functions

• circle (x, y, radius, borderType, color)


awtx.graphics.circle(x, y, radius, borderType, color)

• clearScreen ()
awtx.graphics.clearScreen()

• clrDisplayBusy ()
awtx.graphics.clrDisplayBusy()

• drawLine (x1, y1, x2, y2, lineType, color)


awtx.graphics.drawLine(x1, y1, x2, y2, lineType, color)

• drawText (x, y, text, color)


awtx.graphics.drawText(x, y, text, color)

• fillCircle (x, y, radius, color)


awtx.graphics.fillCircle(x, y, radius, color)

• fillQuadrant (x, y, radius, quadrant, color)


awtx.graphics.fillQuadrant(x, y, radius, quadrant, color)

• fillRect (x, y, width, height, color)


awtx.graphics.fillRect(x, y, width, height, color)

• label.new (labelName)
labelTable = awtx.graphics.label.new(labelName)

• lineTo (x, y, lineType, color)


awtx.graphics.lineTo(x, y, lineType, color)

• moveTo (x, y)
awtx.graphics.moveTo(x, y)

• picturebox.new (pictureName, path)


pictureboxTable = awtx.graphics.picturebox.new(pictureName, path)

• putPixel (x, y, color)


awtx.graphics.putPixel(x, y, color)

• quadrant (x, y, radius, borderType, quadrant, color)


awtx.graphics.quadrant(x, y, radius, borderType, quadrant, color)

• rFillRect (x, y, width, height, radius, color)


awtx.graphics.rFillRect(x, y, width, height, radius, color)

• rRect (x, y, width, height, radius, lineType, color)


awtx.graphics.rRect(x, y, width, height, radius, lineType, color)

• rect (x, y, width, height, lineType, color)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
26 Class Documentation

awtx.graphics.rect(x, y, width, height, lineType, color)

• screens.new (screenName)
screenTable = awtx.graphics.screens.new(screenName)

• setActiveScreen (screenName)
returnVal = awtx.graphics.setActiveScreen(screenName)

• setDisplayBusy ()
awtx.graphics.setDisplayBusy()

• setInverted (invertedState)
awtx.graphics.setInverted(invertedState)

• setMode (newMode)
lastOwner = awtx.graphics.setMode(newMode)

3.4.1 Detailed Description

The display function handles all of the items that appear on the display of the system. Along with the items directly
associated with the display namespace, there are a few namespaces that tie off from the display namespace (such
as buttonCtrl, pictureboxCtrl, screensCtrl and others). The functions directly related to the display namespace are
listed below.

3.4.2 Member Function Documentation

3.4.2.1 awtx.graphics.circle ( x , y , radius , borderType , color )


awtx.graphics.circle(x, y, radius, borderType, color)

Parameters
x - (Number) The X coordinate of the circle center.
y - (Number) The Y coordinate of the circle center.
radius - (Number) The radius of the circle.
borderType - (Number) A thin line or thick border. 0 or 1 respectively.
color - (Number) The color of the border to be drawn. 0 or 1.

1 -- Draws a circle at 75,75 with radius 25


2 awtx.graphics.circle(75, 75, 25, 1, 1)

This function draws a circle centered at coordinates x, y.

3.4.2.2 awtx.graphics.clearScreen ( )
awtx.graphics.clearScreen()

1 -- Clears the screen


2 awtx.graphics.clearScreen()

This function clears all drawings from the screen.


This function only clears the drawn items from the screen such as basic lines or shapes. Any control primitives, like
a label, will be redrawn on the next screen update.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.4 graphics Class Reference 27

3.4.2.3 awtx.graphics.clrDisplayBusy ( )
awtx.graphics.clrDisplayBusy()

1 -- Sets the display to be busy


2 awtx.graphics.setDisplayBusy()
3
4 awtx.os.sleep(3000) -- Wait for 3 seconds
5 -- Set the display back to normal
6 awtx.graphics.clrDisplayBusy()

Clears the display to normal.

3.4.2.4 awtx.graphics.drawLine ( x1 , y1 , x2 , y2 , lineType , color )


awtx.graphics.drawLine(x1, y1, x2, y2, lineType, color)

Parameters
x1 - (Number) The X coordinate to draw from.
y1 - (Number) The Y coordinate to draw from.
x2 - (Number) The X coordinate to draw to.
y2 - (Number) The Y coordinate to draw to.
lineType - (Number) A thin line or thick line. 0 or 1 respectively.
color - (Number) The color of the line to be drawn. 0 or 1.

1 -- Draws a line from 0,0 to 50,50


2 awtx.graphics.drawLine(0, 0, 50, 50, 1, 1)

This function draws a line from coordinates x1, y1 to x2, y2.

3.4.2.5 awtx.graphics.drawText ( x , y , text , color )


awtx.graphics.drawText(x, y, text, color)

Parameters
x - (Number) The X coordinate where the text will be drawn.
y - (Number) The Y coordinate where the text will be drawn.
text - (String) The text to be drawn.
color - (Number) The color of the text to be drawn. 0 or 1.

1 -- Draws the message ’Hello world!’ at 10, 10


2 awtx.graphics.drawText(10, 10, ’Hello world!’, 1)

This function draws a text string at coordinates x, y.

3.4.2.6 awtx.graphics.fillCircle ( x , y , radius , color )


awtx.graphics.fillCircle(x, y, radius, color)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
28 Class Documentation

Parameters
x - (Number) The X coordinate of the circle center.
y - (Number) The Y coordinate of the circle center.
radius - (Number) The radius of the circle.
color - (Number) The color of the border to be drawn. 0 or 1.

1 -- Draws a filed circle at 75, 75 with radius 25


2 awtx.graphics.fillCircle(75, 75, 25, 1)

This function draws a filled circle centered at coordinates x, y.

3.4.2.7 awtx.graphics.fillQuadrant ( x , y , radius , quadrant , color )


awtx.graphics.fillQuadrant(x, y, radius, quadrant, color)

Parameters
x - (Number) The X coordinate of the circle center.
y - (Number) The Y coordinate of the circle center.
radius - (Number) The radius of the circle.
quadrant - (Number) The required quadrant 0 to 3 reading clockwise.
color - (Number) The color of the border to be drawn. 0 or 1.

1 -- Draws the bottom left filled quadrant of a circle at 75, 75 with radius 25
2 awtx.graphics.fillQuadrant(75, 75, 25, 2, 1)

This function draws a filled quadrant of a circle at coordinates x,y

3.4.2.8 awtx.graphics.fillRect ( x , y , width , height , color )


awtx.graphics.fillRect(x, y, width, height, color)

Parameters
x - (Number) The X coordinate of the starting point of the rectangle.
y - (Number) The Y coordinate of the starting point of the rectangle.
width - (Number) The width of the rectangle in pixels.
height - (Number) The height of the rectangle in pixels.
color - (Number) The color of the border to be drawn. Possible values are 0 or 1.

1 -- Draws a 50 by 30 filled rectangle at 10, 10


2 awtx.graphics.fillRect(10, 10, 50, 30, 1)

This function draws a filled rectangle at coordinates x,y.

3.4.2.9 awtx.graphics.label.new ( labelName )


labelTable = awtx.graphics.label.new(labelName)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.4 graphics Class Reference 29

Parameters
labelName - (String) Name of the label we want to create.

Returns

labelTable - (Table) Table of labels that have already been created.

1 -- Creates a new label to be used.


2 local newLabel = "Label 2"
3 -- Add it to the label table to check to see if that name for a label already exists.
4 -- If it doesn’t exist already, it is created.
5 local labelTable = awtx.graphics.label.new(newLabel)
6 print(labelTable) -- Prints out the table to the Lua Console (located at Ztools -> Zedit -> Output)

Creates a new label for the user.


Up to 4 label elements can be created. Attempting to exceed this number of elements will result in an error.

3.4.2.10 awtx.graphics.lineTo ( x , y , lineType , color )


awtx.graphics.lineTo(x, y, lineType, color)

Parameters
x - (Number) The X coordinate to draw to.
y - (Number) The Y coordinate to draw to.
lineType - (Number) A thin line or thick line. 0 or 1 respectively.
color - (Number) The color of the line to be drawn. Possible values are either 0 or 1.

1 -- Set the cursor to 0,0


2 awtx.graphics.moveTo(0,0)
3
4 -- Draws a line from 0,0 to 50,50
5 awtx.graphics.lineTo(50, 50, 1, 1)

This function draws a line from the current cursor position to the specified point.

3.4.2.11 awtx.graphics.moveTo ( x , y )
awtx.graphics.moveTo(x, y)

Parameters
x - (Number) The X coordinate to move to.
y - (Number) The Y coordinate to move to.

1 -- Return the cursor to 0,0


2 awtx.graphics.moveTo(0,0)

This function moves the current cursor position to the specified point.

3.4.2.12 awtx.graphics.picturebox.new ( pictureName , path )


pictureboxTable = awtx.graphics.picturebox.new(pictureName, path)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
30 Class Documentation

Parameters
pictureName - (String) The name of the picturebox which is being created.
path - (String) The pathway in which we want the picturebox to be set up in.

Returns

pictureboxTable - (Table) Table in which the names of the pictureboxes are stored.

1 -- Create a new picturebox


2 local newPicture = "PictureBox4"
3 local picturePath = "/picture/path/location"
4 -- Add it to the picturebox table to check to see if that name for a label already exists.
5 -- If it doesn’t already exist already, it is created.
6 local pictureTable = awtx.graphics.picturebox.new(newPicture, picturePath)
7 print(pictureTable) -- Prints out the table to the Lua Console (located at Ztools -> Zedit -> Output)

This function constructs a new picturebox.


Up to 5 picturebox elements can be created. Attempting to exceed this number of elements will result in an error.

3.4.2.13 awtx.graphics.putPixel ( x , y , color )


awtx.graphics.putPixel(x, y, color)

Parameters
x - (Number) The X coordinate where the pixel will be drawn.
y - (Number) The Y coordinate where the pixel will be drawn.
color - (Number) The color of the pixel. 0 or 1.

1 -- Draw a single pixel at 1,1


2 awtx.graphics.putPixel(1,1)

This function draws a single pixel at coordinates x,y.

3.4.2.14 awtx.graphics.quadrant ( x , y , radius , borderType , quadrant


, color )
awtx.graphics.quadrant(x, y, radius, borderType, quadrant, color)

Parameters
x - (Number) The X coordinate of the circle center.
y - (Number) The Y coordinate of the circle center.
radius - (Number) The radius of the circle.
borderType - (Number) A thin line or thick border. 0 or 1 respectively.
quadrant - (Number) The required quadrant 0 to 3 reading clockwise.
color - (Number) The color of the border to be drawn. 0 or 1.

1 -- Draws the bottom left quadrant of a circle at 75,75 with radius 25


2 awtx.graphics.quadrant(75, 75, 25, 1, 2, 1)

This function draws an open quadrant of a circle at coordinates x, y

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.4 graphics Class Reference 31

3.4.2.15 awtx.graphics.rect ( x , y , width , height , lineType , color )


awtx.graphics.rect(x, y, width, height, lineType, color)

Parameters
x - (Number) The X coordinate of the top left corner of the rectangle.
y - (Number) The Y coordinate of the top left corner of the rectangle.
width - (Number) The width of the rectangle in pixels.
height - (Number) The height of the rectangle in pixels.
lineType - (Number) A thin line or thick border. 0 or 1 respectively.
color - (Number) The color of the border to be drawn. Can be either 0 or 1.

1 -- Draws a 50 by 30 rectangle at 10;10


2 awtx.graphics.rect(10, 10, 50, 30, 1, 1)

This function draws an open rectangle at coordinates x,y.

3.4.2.16 awtx.graphics.rFillRect ( x , y , width , height , radius , color


)
awtx.graphics.rFillRect(x, y, width, height, radius, color)

Parameters
x - (Number) The X coordinate of the top left corner of the rectangle.
y - (Number) The Y coordinate of the top left corner of the rectangle.
width - (Number) The width of the rectangle in pixels.
height - (Number) The height of the rectangle in pixels.
radius - (Number) The radius of the rounded corner of the rectangle.
color - (Number) The color of the border to be drawn. 0 or 1.

1 -- Draws a 50 by 30 filled rectangle at 10, 10 with a radius of 5


2 awtx.graphics.rFillRect(10, 10, 50, 30, 5, 1)

This function draws a rounded filled rectangle at coordinates x, y.

3.4.2.17 awtx.graphics.rRect ( x , y , width , height , radius , lineType ,


color )
awtx.graphics.rRect(x, y, width, height, radius, lineType, color)

Parameters
x - (Number) The X coordinate of the top left corner of the rectangle.
y - (Number) The Y coordinate of the top left corner of the rectangle.
width - (Number) The width of the rectangle in pixels.
height - (Number) The height of the rectangle in pixels.
radius - (Number) The radius of the rounded corner of the rectangle.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
32 Class Documentation

lineType - (Number) A thin line or a thick line. 0 or 1 respectively.


color - (Number) The color of the border to be drawn. 0 or 1.

1 -- Draws a 50 by 30 rectangle at 10,10 with a radius of 5


2 awtx.graphics.rRect(10, 10, 50, 30, 5, 1, 1)

This function draws a rounded rectangle at coordinates x,y.

3.4.2.18 awtx.graphics.screens.new ( screenName )


screenTable = awtx.graphics.screens.new(screenName)

Parameters
screenName - (String) Name of the screen you want to create.

Returns

screenTable - (Table) Table that consists of all of the created screens.

1 -- Creates a new screen to be used


2 local newScreen = "Display 3"
3 -- Add it to the screen table to check to see if that name for a screen already exists.
4 -- If it doesn’t already exist, it is created.
5 local screenTable = awtx.graphics.screens.new(newScreen)
6 print(screenTable) -- Print out the table to the Lua Console (located at Ztools -> Zedit -> Output)

This function creates a new screen for the system.

3.4.2.19 awtx.graphics.setActiveScreen ( screenName )


returnVal = awtx.graphics.setActiveScreen(screenName)

Parameters
screenName - (String) The name of the screen to activate.

Returns

returnVal - (Number) 0 if no error, -1 if the name is not found or other error occurred.

1 -- Set up a test screen


2 local screenName = "Screen1"
3 local Screen1 = awtx.graphics.screens.new(screenName)
4
5 -- Set the test screen as active
6 local returnVal = awtx.graphics.setActiveScreen(screenName)
7
8 if returnVal ~= 0 then
9 print(string.format("%s not found in screens table.", screenName)) -- Prints to the Lua Console (located
at Ztools -> Zedit -> Output)
10 end

This function sets the active displayed screen on the system.


This function is used to activate a previously defined screen. When created, a screen name is specified as a function
argument. To activate the screen, the same name string used during creation is used to select it for activation.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.5 hardware Class Reference 33

3.4.2.20 awtx.graphics.setDisplayBusy ( )
awtx.graphics.setDisplayBusy()

1 -- Sets the display to be busy


2 awtx.graphics.setDisplayBusy()

Sets the display to busy.

3.4.2.21 awtx.graphics.setInverted ( invertedState )


awtx.graphics.setInverted(invertedState)

Parameters
invertedState - (Number) Whether the display should be inverted or not. 1 for inverted, 0 for non-inverted.

1 -- Sets the display state to inverted


2 awtx.graphics.setInverted(1)
3
4 -- Sets the display state to non-inverted
5 awtx.graphics.setInverted(0)

Sets the inverted state of the dot-matrix display.

3.4.2.22 awtx.graphics.setMode ( newMode )


lastOwner = awtx.graphics.setMode(newMode)

Parameters
newMode - (Number) The new desired screen type.

Returns

lastOwner - (Number) Returns the last owner's mode number or is -1 for input parameter error.

1 -- Sets up a mode for the screen


2 local newMode = 2 -- Number associated with screen type desired.
3 local setNewMode= awtx.graphics.setMode(newMode)
4 --Print out to confirm the mode has been set and displays the mode.
5 print(string.format("The mode for the screen is %d", setNewMode)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)

This function sets the display to the mode that was inputted by the user.
Added to allow the active screen to be changed by an app not using the display namespace.

3.5 hardware Class Reference

Public Member Functions

• getInactivityShutdownTime ()
timeInMinutes = awtx.hardware.getInactivityShutdownTime()

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
34 Class Documentation

• getMaxOptionBusCount ()
result = awtx.hardware.getMaxOptionBusCount()

• getMaxOptionCardCount ()
result = awtx.hardware.getMaxOptionCardCount()

• getShutdownEnable ()
result = awtx.hardware.getShutdownEnable()

• getSystem (scaleNumber)
sysTable = awtx.hardware.getSystem(scaleNumber)

• reboot ()
awtx.hardware.reboot()

• registerShutdownEvent (callbackFunction)
awtx.hardware.registerShutdownEvent(callbackFunction)

• setInactivityShutdownTime (timeInMinutes)
result = awtx.hardware.setInactivityShutdownTime(timeInMinutes)

• setShutdownEnable (newState)
result = awtx.hardware.setShutdownEnable(newState)

• setShutdownVoltage (voltVal)
result = awtx.hardware.setShutdownVoltage(voltVal)

• unregisterShutdownEvent ()
awtx.hardware.unregisterShutdownEvent()

3.5.1 Detailed Description

The hardware namespace handles the functionality of the hardware found within the system. It works with setting
battery levels, setting up a shutdown timer, controlling the amount of voltage for certain components, and other
various functions found below.

3.5.2 Member Function Documentation

3.5.2.1 awtx.hardware.getInactivityShutdownTime ( )
timeInMinutes = awtx.hardware.getInactivityShutdownTime()

Returns

timeInMinutes - (Number) This function will get the time period that the Scale is currently using to determine
when it should shutdown due to inactivity.

1 timePeriod = awtx.hardware.getInactivityShutdownTime()
2
3 print(string.format("getInactivityShutdownTime timePeriod = %d", timePeriod)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.5 hardware Class Reference 35

This function will get the time period that the Scale is currently using to determine when it should shutdown due to
inactivity.
The value returned is the time period in minutes. The scale is deemed to be inactive when there is no change of
weight and no key presses.

3.5.2.2 awtx.hardware.getMaxOptionBusCount ( )
result = awtx.hardware.getMaxOptionBusCount()

Returns

result - (Number) The amount of buses that will be allowed.

1 -- Make totalBus equal to max amount of buses.


2 local totalBus = awtx.hardware.getMaxOptionBusCount()

This function grabs the maximum bus count and returns the amount allowed.

3.5.2.3 awtx.hardware.getMaxOptionCardCount ( )
result = awtx.hardware.getMaxOptionCardCount()

Returns

result - (Number) The amount of option cards that will be allowed.

1 -- Get the max card count


2 local result = awtx.hardware.getMaxOptionCardCount()
3 print(string.format("getMaxOptionCardCount()=%2.2f", result)) -- Prints out to the Lua console (Located at
Ztools -> Zedit -> Output)

This function grabs the maximum option card count for the indicator.

3.5.2.4 awtx.hardware.getShutdownEnable ( )
result = awtx.hardware.getShutdownEnable()

Returns

result - (Number) Returns 1 if the shutdown event is currently enabled, else returns 0 if the shutdown event is
disabled.

1 -- Get the state of the shutdown enable flag


2 local result = awtx.hardware.getShutdownEnable()
3 print(string.format("getShutdownEnable() = %d", result)) -- Prints to the Lua Console (located at Ztools
-> Zedit -> Output)

This function will return the current state of the shutdown enable flag. 1 if the shutdown event is enabled, else 0 if
disabled.

3.5.2.5 awtx.hardware.getSystem ( scaleNumber )


sysTable = awtx.hardware.getSystem(scaleNumber)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
36 Class Documentation

Parameters
scaleNumber - (Number) The Scale number for which the system data is required.

Returns

sysTable - (Table) Returns a Lua table containing a number of key, value pairs containing Scale system data.

1 -- Get System info


2 local systemTable = awtx.hardware.getSystem()
3 for k, v in pairs(systemTable) do
4 local modelStr = v
5 print(string.format("Current system model in use is %s", sysName) -- Prints to the Lua Console (located
at Ztools -> Zedit -> Output)
6 end

This is a debug function that gets system related information as a Lua table comprising of a number of key, value
pairs. For example, key = 'modelStr' value = 'ZM401.'
This function returns a Lua table. Currently, the table only contains one field.

1. modelStr
Type: String

Possible values are:


1: ZM401
2: ZM405

3.5.2.6 awtx.hardware.reboot ( )
awtx.hardware.reboot()

1 -- Cause the indicator to reboot


2 awtx.hardware.reboot()

This function will cause the indicator to reboot. This may be necessary if the user program wants to change some
fundamental internal parameters.
This function does not return.

3.5.2.7 awtx.hardware.registerShutdownEvent ( callbackFunction )


awtx.hardware.registerShutdownEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale should call when low battery or inactivity
shutdown event occurs.

1 -- inactivity shutdown notifications are events at a period of 5 seconds


2 -- battery shutdown notifications are events at a period of 60 seconds
3
4 --Print statements output to the Lua Console (located at Ztools -> Zedit -> Output)
5 function shutdownFunc(reason, notifyCount)
6 print(string.format("shutdown called because of %s", reason))
7 print(string.format("notifyCount=%d", notifyCount))
8
9 if (reason == "Low Battery") then

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.5 hardware Class Reference 37

10 if (notifyCount < 3) then


11 print("Battery is low, shutting down soon")
12 else
13 -- could use a relay output to actually power Scale off
14 print("Battery low: shutting down now")
15 end
16 else -- (reason == "Inactivity Timeout")
17 if (notifyCount < 24) then -- wait 2 minutes or so
18 print("Inactivity, shutting down soon")
19 else
20 -- could use a relay output to actually power Scale off
21 print("Inactivity: shutting down now")
22 end
23 end
24 end
25
26 -- Main Program
27 awtx.hardware.setShutdownEnable(1) -- Enable shutdown event
28 awtx.hardware.setInactivityShutdownTime(1) -- Set 1 minute Inactivity trigger
29 awtx.hardware.registerShutdownEvent(shutdownFunc) -- Set handler function

This function sets the callback function the Scale should call when the shutdown event occurs. This event is
triggered by two possible conditions.
a) Shutdown due to inactivity when there is no weight change or key presses within the time period set by the
awtx.hardware.setInactivityShutdownTime()
b) Shutdown due to a low battery voltage. (Nominally 9.0 Volts)
Note 1: If the Scale is running from a battery, the voltage will fall slowly, so the Scale only samples this voltage once
per minute. This means it can take up to one minute before the callback function is called once the voltage falls
below the shutdown threshold.
Note 2: If the Scale detects it is running from mains voltage it does not need to conserve battery life, so it will not
send a shutdown event even if the Scale is inactive.
The Scale itself will not automatically power itself down when a shutdown event occurs, instead it will send a
shutdown event notification to the Lua program so that the user program can control what it wants to do at that
point. The callback function that is called will be passed two arguments, the reason for the shutdown event, and the
notification event count.

3.5.2.8 awtx.hardware.setInactivityShutdownTime ( timeInMinutes )


result = awtx.hardware.setInactivityShutdownTime(timeInMinutes)

Parameters
timeInMinutes - (Number) This function will set the time period that the Scale will use to determine when it
should shutdown due to inactivity. Range should

Returns

result - (Number) The result of the function call. 0 means success, -1 means there was a range error in the
input argument.

1 -- Ignore the return parameter in this example


2 awtx.hardware.setInactivityShutdownTime(10) -- 10 Minutes Inactivity period

This function will set the time period that the Scale will use to determine when it should shutdown due to inactivity.
The Scale itself will not automatically power itself down when this time period is exceeded. Instead, it will send an
inactivity shutdown event notification to the Lua program so that the user can control what it wants to do at that
point.
The scale is deemed to be inactive when there is no change of weight and no key presses.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
38 Class Documentation

3.5.2.9 awtx.hardware.setShutdownEnable ( newState )


result = awtx.hardware.setShutdownEnable(newState)

Parameters
newState - (Number) If 1 this enables the shutdown event, else if 0 this disables the shutdown event.

Returns

result - (Number) Returns 0 if the function was successful, else returns -1 if the newState parameter was not
in range of 0 to 1.

1 -- Sets the state of the shutdown enable flag


2 -- 0 = disbaled, 1 = enabled
3 awtx.hardware.setShutdownEnable(0)

This function enables or disables the Scale's inactivity shutdown event.

3.5.2.10 awtx.hardware.setShutdownVoltage ( voltVal )


result = awtx.hardware.setShutdownVoltage(voltVal)

Parameters
voltVal - (Number) Voltage currently being used.

Returns

result - (Number) Voltage that has been set for the shutdown sequence.

1 -- Set the shutdown voltage to 1.0 Volts.


2
3 awtx.hardware.setShutdownVoltage(1.0)

This function sets the shutdown voltage for the shutdown sequence of the indicator.

3.5.2.11 awtx.hardware.unregisterShutdownEvent ( )
awtx.hardware.unregisterShutdownEvent()

1 -- remove the shutdown function handler


2 awtx.hardware.unregisterShutdownEvent()

This function unregisters a previously set shutdown event callback function.


After this unregister function is called, a low battery voltage or a period of inactivity will no longer generate a call to
the shutdown function.

3.6 json Class Reference

Public Member Functions

• decode (encodedString)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.6 json Class Reference 39

decodedString = awtx.json.decode(encodedString)

• encode (initialString)
encodedString = awtx.json.encode(initialString)

3.6.1 Detailed Description

The json namespace handles anything that is handled by the JavaScript Object Notation. Currently there are only
two functions in this namespace that can be called in Lua: encode and decode.

3.6.2 Member Function Documentation

3.6.2.1 awtx.json.decode ( encodedString )


decodedString = awtx.json.decode(encodedString)

Parameters
encodedString - (String) String to be decoded.

Returns

decodedString - (String) Decoded string.

1 local initialString = "encode this"


2 local encodedString = awtx.json.encode(initialString)
3 local decodedString = awtx.json.decode(encodedString)
4
5 print(string.format("%s has been decoded into: %s", encodedString, decodedString)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

Decodes the encoded string argument and returns the result.


This function is useful for converting formatted text in a json file into a string to be parsed by lua.

3.6.2.2 awtx.json.encode ( initialString )


encodedString = awtx.json.encode(initialString)

Parameters
initialString - (String) String to be encoded.

Returns

encodedString - (String) Encoded string.

1 local initialString = "encode this"


2 local encodedString = json.encode(initialString)
3
4 print(string.format("%s has been encoded into: %s", initialString, encodedString)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

Encodes the string argument and returns the result.


This function is useful for converting lua variables and information into text formatted specifically to be stored in a
json file.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
40 Class Documentation

3.7 keypad Class Reference

Public Member Functions

• KEY_F1_DOWN ()
awtx.keypad.KEY_F1_DOWN()

• KEY_F1_REPEAT ()
awtx.keypad.KEY_F1_REPEAT()

• KEY_F1_UP ()
awtx.keypad.KEY_F1_UP()

• KEY_NUMERIC_DOWN (pressedChar)
awtx.keypad.KEY_NUMERIC_DOWN(pressedChar)

• KEY_NUMERIC_REPEAT (repeatedChar)
awtx.keypad.KEY_NUMERIC_REPEAT(repeatedChar)

• KEY_NUMERIC_UP (releasedChar)
awtx.keypad.KEY_NUMERIC_UP(releasedChar)

• KEY_PRINT_DOWN ()
awtx.keypad.KEY_PRINT_DOWN()

• KEY_PRINT_REPEAT ()
awtx.keypad.KEY_PRINT_REPEAT()

• KEY_PRINT_UP ()
awtx.keypad.KEY_PRINT_UP()

• KEY_SELECT_DOWN ()
awtx.keypad.KEY_SELECT_DOWN()

• KEY_SELECT_REPEAT ()
awtx.keypad.KEY_SELECT_REPEAT()

• KEY_SELECT_UP ()
awtx.keypad.KEY_SELECT_UP()

• KEY_TARE_DOWN ()
awtx.keypad.KEY_TARE_DOWN()

• KEY_TARE_REPEAT ()
awtx.keypad.KEY_TARE_REPEAT()

• KEY_TARE_UP ()
awtx.keypad.KEY_TARE_UP()

• KEY_UNITS_DOWN ()
awtx.keypad.KEY_UNITS_DOWN()

• KEY_UNITS_REPEAT ()

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.7 keypad Class Reference 41

awtx.keypad.KEY_UNITS_REPEAT()

• KEY_UNITS_UP ()
awtx.keypad.KEY_UNITS_UP()

• KEY_ZERO_DOWN ()
awtx.keypad.KEY_ZERO_DOWN()

• KEY_ZERO_REPEAT ()
awtx.keypad.KEY_ZERO_REPEAT()

• KEY_ZERO_UP ()
awtx.keypad.KEY_ZERO_UP()

• configRpn (softKey1, softKey2, softKey3, softKey4, softKey5, titleString, helpString)


awtx.keypad.configRpn(softKey1, softKey2, softKey3, softKey4, softKey5, titleString, helpString)

• enterCheckWt (curValue, minimum, maximum, checkType, separatorChar, editorTimeout, titleStr, helpStr)


newValue, isEnterKey = awtx.keypad.enterCheckWt(curValue, minimum, maximum, checkType, separatorChar,
editorTimeout, titleStr, helpStr)

• enterCheckWtWithUnits (curValue, minimum, maximum, unitStr, checkType, separatorChar, editorTimeout,


editable, titleStr, helpStr)
newValue, isEnterKey = awtx.keypad.enterCheckWtWithUnits(curValue, minimum, maximum, unitStr, checkType,
separatorChar, editorTimeout, editable, titleStr, helpStr)

• enterDate (year, month, day, timeout, titleString, helpString)


entryResult, year, month, day, isEnterKey = awtx.keypad.enterDate(year, month, day, timeout, titleString, helpString)

• enterFloat (value, min, max, separator, timeout, titleString, helpString)


value, isEnterKey = awtx.keypad.enterFloat(value, min, max, separator, timeout, titleString, helpString)

• enterInteger (value, min, max, timeout, titleString, helpString)


value, isEnterKey = awtx.keypad.enterInteger(value, min, max, timeout, titleString, helpString)

• enterIpAddress (value, timeout, titleString, helpString)


enteredValue, isEnterKey = awtx.keypad.enterIpAddress(value, timeout, titleString, helpString)

• enterString (value, maxLen, timeout, titleString, helpString)


value, isEnterKey = awtx.keypad.enterString(value, maxLen, timeout, titleString, helpString)

• enterTime (hours, minutes, seconds, timeout, titleString, helpString)


entryResult, hours, mins, secs, isEnterKey = awtx.keypad.enterTime(hours, minutes, seconds, timeout, titleString,
helpString)

• enterWeightWithUnits (curValue, minimum, maximum, unitStr, separatorChar, editorTimeout, editable, titleStr,


helpStr)
newValue, isEnterKey = awtx.keypad.enterWeightWithUnits(curValue, minimum, maximum, unitStr, separatorChar,
editorTimeout, editable, titleStr, helpStr)

• getRpnMode ()
currentMode = awtx.keypad.getRpnMode()

• registerRpnEvent (handler)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
42 Class Documentation

awtx.keypad.registerRpnEvent(handler)

• selectList (listItems, index, timeout, titleString, helpString)


index, isEnterKey = awtx.keypad.selectList(listItems, index, timeout, titleString, helpString)

• setDate (year, month, day, timeout, titleString, helpString)


entryResult, year, month, day, isEnterKey = awtx.keypad.setDate(year, month, day, timeout, titleString, helpString)

• setRpnMode (lastRpnMode)
newRpnMode = awtx.keypad.setRpnMode(lastRpnMode)

• setTime (hours, minutes, seconds, timeout, titleString, helpString)


entryResult, hours, mins, secs, isEnterKey = awtx.keypad.setTime(hours, minutes, seconds, timeout, titleString,
helpString)

• unregisterRpnEvent ()
awtx.keypad.unregisterRpnEvent()

3.7.1 Detailed Description

The keypad namespace handles all the events that happen on the system's keypad. It handles the key press events,
entering in the date, time, ip address, check weight, and other various tasks listed down below.

3.7.2 Member Function Documentation

3.7.2.1 awtx.keypad.configRpn ( softKey1 , softKey2 , softKey3 ,


softKey4 , softKey5 , titleString , helpString )
awtx.keypad.configRpn(softKey1, softKey2, softKey3, softKey4, softKey5, titleString, helpString)

Parameters
softKey1 - (String) The text of softkey 1.
softKey2 - (String) The text of softkey 2.
softKey3 - (String) The text of softkey 3.
softKey4 - (String) The text of softkey 4.
softKey5 - (String) The text of softkey 5.
titleString - (String) (Optional) The entry title string.
helpString - (String) (Optional) The entry help string.

1 -- Configure the RPN softkeys and title/help strings


2 awtx.keypad.configRpn(’soft1’, ’soft2’, ’soft3’, ’soft4’, ’soft5’, ’Enter’, ’ID’)

Configures the RPN mode functionality

3.7.2.2 awtx.keypad.enterCheckWt ( curValue , minimum , maximum ,


checkType , separatorChar , editorTimeout , titleStr , helpStr )
newValue, isEnterKey = awtx.keypad.enterCheckWt(curValue, minimum, maximum, checkType, separatorChar,
editorTimeout, titleStr, helpStr)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.7 keypad Class Reference 43

Parameters
curValue - (Number) Starting displayed value (current value of variable being edited).
minimum - (Number) Minimum allowed value.
maximum - (Number) Maximum allowed value.
checkType - (Number) Specifies which set of dashes to be flashed during edit.
separatorChar - (Number) 0 to use period decimal, 1 to use comma as decimal.
editorTimeout - (Number) (Optional) The timeout value for the editor; -1 is infinite.
titleStr - (String) (Optional) If available, title to display during entry.
helpStr - (String) (Optional) If available, help message to be displayed during entry.

Returns

newValue - (Number) The new number entered by the user.


isEnterKey - (Number) 1 if user exited the form with Enter, 0 if user pressed Escape to exit (no save).

1 -- Prompt the user for a checkweight entry


2 local curValue = 50 -- Display 50 lb as the initial value
3 local minimum = 0 -- 0 lb minimum entry value
4 local maximum = 100 -- 100 lb maximum entry value
5 local checkType = 2 -- Flash target bar during entry
6 local separatorChar = 0 -- Use period decimal separator
7 local editorTimeout = -1 -- Disable editor timeout
8 local titleStr = "Target"
9 local helpStr = string.format("Min: %f Max: %f", minimum, maximum)
10
11 local newValue, isEnterKey = awtx.keypad.enterCheckWt(curValue, minimum, maximum, checkType, separatorChar,
editorTimeout, titleStr, helpStr)
12
13 if isEnterKey == true then
14 print(string.format("Saved entry. New value is %f.", newValue)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)
15 curValue = newValue
16 else
17 print(string.format("Entry aborted.")) -- Prints to the Lua Console (located at Ztools -> Zedit ->
Output)
18 end

This function handles entered check weight values


Allowed values for checkType are:
1 = under bars flashing
2 = target bar flashing
3 = over bars flashing

3.7.2.3 awtx.keypad.enterCheckWtWithUnits ( curValue , minimum ,


maximum , unitStr , checkType , separatorChar , editorTimeout
, editable , titleStr , helpStr )
newValue, isEnterKey = awtx.keypad.enterCheckWtWithUnits(curValue, minimum, maximum, unitStr, checkType,
separatorChar, editorTimeout, editable, titleStr, helpStr)

Parameters
curValue - (Number) Starting displayed value (current value of variable being edited).
minimum - (Number) Minimum allowed value.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
44 Class Documentation

maximum - (Number) Maximum allowed value.


unitStr - (String) Unit type to be displayed.
checkType - (Number) Specifies which set of dashes to be flashed during edit.
separatorChar - (Number) 0 to use period decimal, 1 to use comma as decimal.
editorTimeout - (Number) (Optional) The timeout value for the editor; -1 is infinite.
editable - (Number) (Optional) 1 if editing is allowed, 0 if value is only to be viewed.
titleStr - (String) (Optional) If available, title to display during entry.
helpStr - (String) (Optional) If available, help message to be displayed during entry.

Returns

newValue - (Number) The new number entered by the user.


isEnterKey - (Number) 1 if user exited the form with Enter, 0 if user pressed Escape to exit (no save).

1 -- Prompt the user for a checkweight entry


2 local curValue = 50 -- Display 50 lb as the initial value
3 local minimum = 0 -- 0 lb minimum entry value
4 local maximum = 100 -- 100 lb maximum entry value
5 local unitStr = "lb" -- Display "lb" unit type
6 local checkType = 2 -- Flash target bar during entry
7 local separatorChar = 0 -- Use period decimal separator
8 local editorTimeout = -1 -- Disable editor timeout
9 local editable = 1 -- Value is editable
10 local titleStr = "Target"
11 local helpStr = string.format("Min: %f Max: %f", minimum, maximum)
12
13 local newValue, isEnterKey = awtx.keypad.enterCheckWtWithUnits(curValue, minimum, maximum, unitStr,
checkType, separatorChar, editorTimeout, editable, titleStr, helpStr)
14
15 if isEnterKey == true then
16 print(string.format("Saved entry. New value is %f.", newValue)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)
17 curValue = newValue
18 else
19 print(string.format("Entry aborted.")) -- Prints to the Lua Console (located at Ztools -> Zedit ->
Output)
20 end

This function works similarly to enterCheckWt but with an additional field to choose displayed units of measure.
Allowed values for unitStr are:
"lb" = pounds
"kg" = kilograms
"g" = grams
"oz" = ounces
"lb-oz" = pounds-ounces
"pc" = pieces
Custom units can be used if the entered string matches whatever string was used when configuring the custom unit.
Allowed values for checkType are:
1 = under bars flashing
2 = target bar flashing
3 = over bars flashing

3.7.2.4 awtx.keypad.enterDate ( year , month , day , timeout ,


titleString , helpString )
entryResult, year, month, day, isEnterKey = awtx.keypad.enterDate(year, month, day, timeout, titleString, help←-
String)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.7 keypad Class Reference 45

Parameters
year - (Number) The starting year value.
month - (Number) The starting month value.
day - (Number) The starting day value.
timeout - (Number) (Optional) The entry timeout in ms, or -1 for no timeout
titleString - (String) (Optional) The entry title string.
helpString - (String) (Optional) The entry help string.

Returns

entryResult - (Number) Result of the date entry, 0 if no error.


year - (Number) The entered year value
month - (Number) The entered month value
day - (Number) The entered day value
isEnterKey - (Boolean) Returns true if a number was entered, or false if the entry was aborted.

1 -- Prompt the user to enter a date value


2 local entryResult, year, month, day, isEnterKey = awtx.keypad.enterDate(2015, 5, 1, -1, ’Enter’, ’Date’)
3 if (isEnterKey) then
4 print(string.format(’The user entered the date: %d%d%d’, month, day, year)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)
5 else
6 print(’The user aborted the entry’) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
7 end

Opens the entry mode for entering a date value


This function internally validates the entered date value. If entryResult is non-zero, then the entry was invalid and
the value should be discarded. If isEnterKey is false, then the entry was aborted and the value should be discarded.

3.7.2.5 awtx.keypad.enterFloat ( value , min , max , separator , timeout


, titleString , helpString )
value, isEnterKey = awtx.keypad.enterFloat(value, min, max, separator, timeout, titleString, helpString)

Parameters
value - (Number) The initial value that is shown when the entry mode opens.
min - (Number) The minimum value that can be entered.
max - (Number) The maximum value that can be entered.
separator - (Number) Specifies what character separator to use for the decimal value.
timeout - (Number) (Optional) The entry timeout in ms, or -1 for no timeout
titleString - (String) (Optional) The entry title string.
helpString - (String) (Optional) The entry help string.

Returns

value - (Number) The entered value.


isEnterKey - (Boolean) Returns true if a number was entered, or false if the entry was aborted.

1 -- Prompt the user to enter a tare value between 0 and 5000 with no timeout
2 local enteredTare, isEnterKey = awtx.keypad.enterFloat(0, 0, 100, 0, -1, ’Enter’, ’Tare’)
3 if (isEnterKey) then
4 print(’The user entere the tare: ’.. enteredTare) -- Prints to the Lua console (Located at Ztools ->
Zedit -> Output)
5 else
6 print(’The user aborted the entry’) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
7 end

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
46 Class Documentation

Opens the entry mode for entering a float value.


Values for separator:
0 = '.'
1 = ','
2 (or greater) = '-'
This function internally checks the bounds of the entered value as specified in the call. The return value is guaran-
teed to be between the min and max values. If isEnterKey is false, then the entry was aborted and the value should
be discarded.

3.7.2.6 awtx.keypad.enterInteger ( value , min , max , timeout ,


titleString , helpString )
value, isEnterKey = awtx.keypad.enterInteger(value, min, max, timeout, titleString, helpString)

Parameters
value - (Number) The initial value that is shown when the entry mode opens.
min - (Number) The minimum value that can be entered.
max - (Number) The maximum value that can be entered.
timeout - (Number) (Optional) The entry timeout in ms, or -1 for no timeout
titleString - (String) (Optional) The entry title string.
helpString - (String) (Optional) The entry help string.

Returns

value - (Number) The entered value.


isEnterKey - (Boolean) Returns true if a number was entered, or false if the entry was aborted.

1 -- Prompt the user to enter an ID between 0 and 100 with no timeout


2 local enteredID, isEnterKey = awtx.keypad.enterInteger(0, 0, 100, -1, ’Enter’, ’ID’)
3 if (isEnterKey) then
4 print(’The user entered the ID: ’.. enteredID) -- Prints to the Lua Console (located at Ztools -> Zedit
-> Output)
5 else
6 print(’The user aborted the entry’) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
7 end

Opens the entry mode for entering an integer value.


This function internally checks the bounds of the entered value as specified in the call. The return value is guaran-
teed to be between the min and max values. If isEnterKey is false, then the entry was aborted and the value should
be discarded.

3.7.2.7 awtx.keypad.enterIpAddress ( value , timeout , titleString ,


helpString )
enteredValue, isEnterKey = awtx.keypad.enterIpAddress(value, timeout, titleString, helpString)

Parameters

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.7 keypad Class Reference 47

value - (String) The initial value that is shown when the entry mode opens.
timeout - (Number) (Optional) The entry timeout in ms, or -1 for no timeout
titleString - (String) (Optional) The entry title string.
helpString - (String) (Optional) The entry help string.

Returns

enteredValue - (String) The entered IP address string (X.X.X.X), subnet, gateway, and port number.
isEnterKey - (Boolean) Returns true if a number was entered, or false if the entry was aborted.

1 -- Prompt the user to enter an IPv4 Address


2 local enteredValue, isEnterKey = awtx.keypad.enterIpAddress(’192.168.1.100’, -1, ’Enter’, ’Addr’)
3 if (isEnterKey) then
4 print(’The user entered the IP Address: ’ .. enteredValue ) -- Prints out to the Lua Console (located at
Ztools -> Zedit -> Output)
5 else
6 print(’The user aborted the entry’) -- Prints out to the Lua Console (located at Ztools -> Zedit ->
Output)
7 end

Opens the entry mode for an IPv4 address


This function internally validates the octets so that the returned string is guaranteed to be a valid IPv4 address,
subnet, gateway and port #. If isEnterKey is false, then the entry was aborted and the value should be discarded.

3.7.2.8 awtx.keypad.enterString ( value , maxLen , timeout , titleString ,


helpString )

value, isEnterKey = awtx.keypad.enterString(value, maxLen, timeout, titleString, helpString)

Parameters
value - (String) The initial value that is shown when the entry mode opens.
maxLen - (Number) The maximum string length that can be entered.
timeout - (Number) (Optional) The entry timeout in ms, or -1 for no timeout.
titleString - (String) (Optional) The entry title string.
helpString - (String) (Optional) The entry help string.

Returns

value - (Number) The entered value.


isEnterKey - (Boolean) Returns true if a number was entered, or false if the entry was aborted.

1 -- Prompt the user to enter a 10 character name with no timeout


2 local enteredName, isEnterKey = awtx.keypad.enterString(’’, 10, -1, ’Name’, ’Enter’)
3 if (isEnterKey) then
4 print(’The user entered the name: ’.. enteredName) -- Prints to the Lua Console (located at Ztools ->
Zedit -> Output)
5 else
6 print(’The user aborted the entry’) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
7 end

This function allows the user to enter in a string using the Indicator keypad.
This function internally checks the length of the entered value as specified in the call. The return value is guaranteed
to be between the min and max values. If isEnterKey is false, then the entry was aborted and the value should be
discarded.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
48 Class Documentation

3.7.2.9 awtx.keypad.enterTime ( hours , minutes , seconds , timeout ,


titleString , helpString )
entryResult, hours, mins, secs, isEnterKey = awtx.keypad.enterTime(hours, minutes, seconds, timeout, titleString,
helpString)

Parameters
hours - (Number) The starting hours value is a 24 hour format.
minutes - (Number) The starting minutes value.
seconds - (Number) The starting seconds value.
timeout - (Number) (Optional) The entry timeout in ms, or -1 for no timeout.
titleString - (String) (Optional) The entry title string.
helpString - (String) (Optional) The entry help string.

Returns

entryResult - (Number) Result of the date entry, 0 if no error.


hours - (Number) The entered hours value.
mins - (Number) The entered minutes value.
secs - (Number) The entered seconds value.
isEnterKey - (Boolean) Returns true if a number was entered, or false if the entry was aborted.

1 -- Prompt the user to enter a time value


2 local entryResult, hours, minutes, seconds, isEnterKey = awtx.keypad.enterTime(12, 15, 0, -1, ’Enter’,
’Time’)
3 if (isEnterKey) then
4 print(string.format(’The user entered the time: %d:%d:%d’, hours, minutes, seconds)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)
5 else
6 print(’The user aborted the entry’) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
7 end

Opens the entry mode for entering a time value


This function internally validates the entered time value. If entryResult is non-zero, then the entry was invalid and
the value should be discarded. If isEnterKey is false, then the entry was aborted and the value should be discarded.

3.7.2.10 awtx.keypad.enterWeightWithUnits ( curValue , minimum ,


maximum , unitStr , separatorChar , editorTimeout , editable ,
titleStr , helpStr )
newValue, isEnterKey = awtx.keypad.enterWeightWithUnits(curValue, minimum, maximum, unitStr, separatorChar,
editorTimeout, editable, titleStr, helpStr)

Parameters
curValue - (Number) Starting displayed value (current value of variable being edited).
minimum - (Number) Minimum allowed value.
maximum - (Number) Maximum allowed value.
unitStr - (String) Unit type to be displayed.
separatorChar - (Number) 0 to use period decimal, 1 to use comma as decimal.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.7 keypad Class Reference 49

editorTimeout - (Number) (Optional) The timeout value for the editor; -1 is infinite.
editable - (Number) (Optional) 1 if editing is allowed, 0 if value is only to be viewed.
titleStr - (String) (Optional) If available, title to display during entry.
helpStr - (String) (Optional) If available, help message to be displayed during entry.

Returns

newValue - (Number) The new number entered by the user.


isEnterKey - (Number) 1 if user exited the form with Enter, 0 if user pressed Escape to exit (no save).

1 -- Prompt the user for a weight entry


2 local curValue = 50 -- Display 50 lb as the initial value
3 local minimum = 0 -- 0 lb minimum entry value
4 local maximum = 100 -- 100 lb maximum entry value
5 local unitStr = "lb" -- Display "lb" unit type
6 local separatorChar = 0 -- Use period decimal separator
7 local editorTimeout = -1 -- Disable editor timeout
8 local editable = 1 -- Value is editable
9 local titleStr = "Weight"
10 local helpStr = string.format("Min: %f Max: %f", minimum, maximum)
11
12 local newValue, isEnterKey = awtx.keypad.enterCheckWtWithUnits(curValue, minimum, maximum, unitStr,
checkType, separatorChar, editorTimeout, editable, titleStr, helpStr)
13
14 if isEnterKey == true then
15 print(string.format("Saved entry. New value is %f.", newValue)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)
16 curValue = newValue
17 else
18 print(string.format("Entry aborted.")) -- Prints to the Lua Console (located at Ztools -> Zedit ->
Output)
19 end

This function prompts the user to enter a weight in the units displayed by the entry screen.
Allowed values for unitStr are:
"lb" = pounds
"kg" = kilograms
"g" = grams
"oz" = ounces
"lb-oz" = pounds-ounces
Custom units can be used if the entered string matches whatever string was used when configuring the custom unit.

3.7.2.11 awtx.keypad.getRpnMode ( )
currentMode = awtx.keypad.getRpnMode()

Returns

currentMode - (Number) The current RPN mode.

1 local currentMode = awtx.keypad.getRpnMode()


2 print(’The current RPN mode is ’ .. currentMode) -- Prints to the Lua Console (located at Ztools -> Zedit
-> Output)

Gets the current state of the system RPN mode.


RPN Modes
0 = Disabled
1 = Enabled

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
50 Class Documentation

3.7.2.12 awtx.keypad.KEY_F1_DOWN ( )
awtx.keypad.KEY_F1_DOWN()

1 -- This function occurs when the F1 key is pressed down.


2 function awtx.keypad.KEY_F1_DOWN()
3 -- F1 key is pressed.
4 print("F1 key down.") -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
5 end

This function is called when the F1 key is pressed. It is an event handler but is registered by lua automatically so no
callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for a down event is awtx.keypad.KEY_NAME_DOWN().
This functionality can be overridden by overriding the specific API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

3.7.2.13 awtx.keypad.KEY_F1_REPEAT ( )
awtx.keypad.KEY_F1_REPEAT()

1 -- This function occurs when the F1 key is held down.


2 function awtx.keypad.KEY_F1_REPEAT()
3 -- F1 key is being held down.
4 print("F1 key repeat.") -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
5 end

This function is called every second while the F1 key is held down. It is an event handler but is registered by lua
automatically so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for a repeat event is awtx.keypad.KEY_NAME_REPEAT().
This functionality can be overridden by overriding the specific API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

3.7.2.14 awtx.keypad.KEY_F1_UP ( )
awtx.keypad.KEY_F1_UP()

1 -- This function occurs when the F1 key is released.


2 function awtx.keypad.KEY_F1_UP()
3 -- F1 key is released.
4 print("F1 key released.") -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
5 end

This function is called when the F1 key is released. It is an event handler but is registered by lua automatically so
no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for an up event is awtx.keypad.KEY_NAME_UP().
This functionality can be overridden by overriding the specific API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.7 keypad Class Reference 51

3.7.2.15 awtx.keypad.KEY_NUMERIC_DOWN ( pressedChar )


awtx.keypad.KEY_NUMERIC_DOWN(pressedChar)

Parameters
pressedChar - (Number) ASCII decimal integer of the character being pressed.

1 -- This function occurs when a numeric key is pressed down.


2 function awtx.keypad.KEY_NUMERIC_DOWN(pressedChar)
3 -- NUMERIC key is pressed down.
4 print(string.format("NUMERIC key %c pressed down.", pressedChar)) -- Prints to the Lua Console (located
at Ztools -> Zedit -> Output)
5 end

This function is called when the NUMERIC key is pressed. It is an event handler but is registered by lua automatically
so no callback function registration is required.
This function handles all numeric keypad keypresses for indicators with a numeric keypad installed.

3.7.2.16 awtx.keypad.KEY_NUMERIC_REPEAT ( repeatedChar )


awtx.keypad.KEY_NUMERIC_REPEAT(repeatedChar)

Parameters
repeatedChar - (Number) ASCII decimal integer of the character being repeated.

1 -- This function occurs when a numeric key is held down.


2 function awtx.keypad.KEY_NUMERIC_REPEAT(repeatedChar)
3 -- NUMERIC key is being held down.
4 print(string.format("NUMERIC key %c repeated.", repeatedChar)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)
5 end

This function is called every second while a NUMERIC key is held down. It is an event handler but is registered by
lua automatically so no callback function registration is required.
This function handles all numeric keypad keypress repeats for indicators with a numeric keypad installed.

3.7.2.17 awtx.keypad.KEY_NUMERIC_UP ( releasedChar )


awtx.keypad.KEY_NUMERIC_UP(releasedChar)

Parameters
releasedChar - (Number) ASCII decimal integer of the character being released.

1 -- This function occurs when a numeric key is released.


2 function awtx.keypad.KEY_NUMERIC_UP(releasedChar)
3 -- NUMERIC key is released.
4 print(string.format("NUMERIC key %c released.", releasedChar)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)
5 end

This function is called when a NUMERIC key is released. It is an event handler but is registered by lua automatically
so no callback function registration is required.
This function handles all numeric keypad keypress releases for indicators with a numeric keypad installed.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
52 Class Documentation

3.7.2.18 awtx.keypad.KEY_PRINT_DOWN ( )
awtx.keypad.KEY_PRINT_DOWN()

1 -- This function occurs when the PRINT key is pressed down.


2 function awtx.keypad.KEY_PRINT_DOWN()
3 -- PRINT key is pressed.
4 print("PRINT key down.") -- Prints to the Lua console (located at Ztools -> Zedit -> Output)
5 end

This function is called when the PRINT key is pressed. It is an event handler but is registered by lua automatically
so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for a down event is awtx.keypad.KEY_NAME_DOWN().
This functionality can be overridden by overriding the specific API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

3.7.2.19 awtx.keypad.KEY_PRINT_REPEAT ( )
awtx.keypad.KEY_PRINT_REPEAT()

1 -- This function occurs when the PRINT key is held down.


2 function awtx.keypad.KEY_PRINT_REPEAT()
3 -- PRINT key is being held down.
4 print("PRINT key repeat.") -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
5 end

This function is called every second while the PRINT key is held down. It is an event handler but is registered by lua
automatically so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for a repeat event is awtx.keypad.KEY_NAME_REPEAT().
This functionality can be overridden by overriding the specific API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

3.7.2.20 awtx.keypad.KEY_PRINT_UP ( )
awtx.keypad.KEY_PRINT_UP()

1 -- This function occurs when the PRINT key is released.


2 function awtx.keypad.KEY_PRINT_UP()
3 -- PRINT key is released.
4 print("PRINT key released.") -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
5 end

This function is called when the PRINT key is released. It is an event handler but is registered by lua automatically
so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for an up event is awtx.keypad.KEY_NAME_UP().
This functionality can be overridden by overriding the specific API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.7 keypad Class Reference 53

3.7.2.21 awtx.keypad.KEY_SELECT_DOWN ( )
awtx.keypad.KEY_SELECT_DOWN()

1 -- This function occurs when the SELECT key is pressed down.


2 function awtx.keypad.KEY_SELECT_DOWN()
3 -- SELECT key is pressed.
4 print("SELECT key down.") -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
5 end

This function is called when the SELECT key is pressed. It is an event handler but is registered by lua automatically
so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for a down event is awtx.keypad.KEY_NAME_DOWN().
This functionality can be overridden by overriding the specific API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

3.7.2.22 awtx.keypad.KEY_SELECT_REPEAT ( )
awtx.keypad.KEY_SELECT_REPEAT()

1 -- This function occurs when the SELECT key is held down.


2 function awtx.keypad.KEY_SELECT_REPEAT()
3 -- SELECT key is being held down.
4 print("SELECT key repeat.") -- Prints to the Lua Console (located in Ztools -> Zedit -> Output)
5 end

This function is called every second while the SELECT key is held down. It is an event handler but is registered by
lua automatically so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for a down event is awtx.keypad.KEY_NAME_REPEAT().
This functionality can be overridden by overriding the specific API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

3.7.2.23 awtx.keypad.KEY_SELECT_UP ( )
awtx.keypad.KEY_SELECT_UP()

1 -- This function occurs when the SELECT key is released.


2 function awtx.keypad.KEY_SELECT_UP()
3 -- SELECT key is released.
4 print("SELECT key released.") -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
5 end

This function is called when the SELECT key is released. It is an event handler but is registered by lua automatically
so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for an up event is awtx.keypad.KEY_NAME_UP().
This functionality can be overridden by overriding the specific API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
54 Class Documentation

3.7.2.24 awtx.keypad.KEY_TARE_DOWN ( )
awtx.keypad.KEY_TARE_DOWN()

1 -- This function occurs when the TARE key is pressed down.


2 function awtx.keypad.KEY_TARE_DOWN()
3 -- TARE key is pressed.
4 print("TARE key down.") -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
5 end

This function is called when the TARE key is pressed. It is an event handler but is registered by lua automatically
so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for a down event is awtx.keypad.KEY_NAME_DOWN().
This functionality can be overridden by overriding the specific API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

3.7.2.25 awtx.keypad.KEY_TARE_REPEAT ( )
awtx.keypad.KEY_TARE_REPEAT()

1 -- This function occurs when the TARE key is held down.


2 function awtx.keypad.KEY_TARE_REPEAT()
3 -- TARE key is being held down.
4 print("TARE key repeat.") -- Prints to the Lua Console (located at Ztools -> Zsim -> Output)
5 end

This function is called every second while the TARE key is held down. It is an event handler but is registered by lua
automatically so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for a repeat event is awtx.keypad.KEY_NAME_REPEAT().
This functionality can be overridden by redefining awtxReq.keypad.onTareKeyRepeat, or by overriding the specific
API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

3.7.2.26 awtx.keypad.KEY_TARE_UP ( )
awtx.keypad.KEY_TARE_UP()

1 -- This function occurs when the TARE key is released.


2 function awtx.keypad.KEY_TARE_UP()
3 -- TARE key is released.
4 print("TARE key released.") -- Prints to the Lua Console (located at Ztools -> Zsim -> Output)
5 end

This function is called when the TARE key is released. It is an event handler but is registered by lua automatically
so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for an up event is awtx.keypad.KEY_NAME_UP().
This functionality can be overridden by redefining awtxReq.keypad.onTareKeyUp, or by overriding the specific API
key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.7 keypad Class Reference 55

3.7.2.27 awtx.keypad.KEY_UNITS_DOWN ( )
awtx.keypad.KEY_UNITS_DOWN()

1 -- This function occurs when the UNITS key is pressed down.


2 function awtx.keypad.KEY_UNITS_DOWN()
3 -- UNITS key is pressed.
4 print("UNITS key down.") -- Prints to the Lua Console (located at Ztools -> Zsim -> Output)
5 end

This function is called when the UNITS key is pressed. It is an event handler but is registered by lua automatically
so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for a down event is awtx.keypad.KEY_NAME_DOWN().
This functionality can be overridden by redefining awtxReq.keypad.onUnitsKeyDown, or by overriding the specific
API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

3.7.2.28 awtx.keypad.KEY_UNITS_REPEAT ( )
awtx.keypad.KEY_UNITS_REPEAT()

1 -- This function occurs when the UNITS key is held down.


2 function awtx.keypad.KEY_UNITS_REPEAT()
3 -- UNITS key is being held down.
4 print("UNITS key repeat.") -- Prints to the Lua Console (located at Ztools -> Zsim -> Output)
5 end

This function is called every second while the UNITS key is held down. It is an event handler but is registered by lua
automatically so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for a repeat event is awtxReq.keypad.onNamedKeyRepeat() or awtx.keypad.KEY_←-
NAME_REPEAT().
This functionality can be overridden by redefining awtxReq.keypad.onUnitsKeyRepeat, or by overriding the specific
API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

3.7.2.29 awtx.keypad.KEY_UNITS_UP ( )
awtx.keypad.KEY_UNITS_UP()

1 -- This function occurs when the UNITS key is released.


2 function awtx.keypad.KEY_UNITS_UP()
3 -- UNITS key is released.
4 print("UNITS key released.") -- Prints to the Lua Console (Ztools -> Zedit -> Output)
5 end

This function is called when the UNITS key is released. It is an event handler but is registered by lua automatically
so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for an up event is awtx.keypad.KEY_NAME_UP().

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
56 Class Documentation

This functionality can be overridden by redefining awtxReq.keypad.onUnitsKeyUp, or by overriding the specific API
key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

3.7.2.30 awtx.keypad.KEY_ZERO_DOWN ( )
awtx.keypad.KEY_ZERO_DOWN()

1 -- This function occurs when the ZERO key is pressed down.


2 function awtx.keypad.KEY_ZERO_DOWN()
3 -- ZERO key is pressed.
4 print("ZERO key down.") -- Prints to the Lua Console (located at Ztools -> Zsim -> Output)
5 end

This function is called when the ZERO key is pressed. It is an event handler but is registered by lua automatically
so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for a down event is awtx.keypad.KEY_NAME_DOWN().
This functionality can be overridden by redefining awtxReq.keypad.onZeroKeyDown, or by overriding the specific
API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

3.7.2.31 awtx.keypad.KEY_ZERO_REPEAT ( )
awtx.keypad.KEY_ZERO_REPEAT()

1 -- This function occurs when the ZERO key is held down.


2 function awtx.keypad.KEY_ZERO_REPEAT()
3 -- ZERO key is being held down.
4 print("ZERO key repeat.") -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
5 end

This function is called every second while the ZERO key is held down. It is an event handler but is registered by lua
automatically so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for a repeat event is awtx.keypad.KEY_NAME_REPEAT().
This functionality can be overridden by redefining awtxReq.keypad.onZeroKeyRepeat, or by overriding the specific
API key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

3.7.2.32 awtx.keypad.KEY_ZERO_UP ( )
awtx.keypad.KEY_ZERO_UP()

1 -- This function occurs when the ZERO key is released.


2 function awtx.keypad.KEY_ZERO_UP()
3 -- ZERO key is released.
4 print("ZERO key released.") -- Print to the Lua Console (located at Ztools -> Zedit -> Output)
5 end

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.7 keypad Class Reference 57

This function is called when the ZERO key is released. It is an event handler but is registered by lua automatically
so no callback function registration is required.
Key event handlers have been predefined.
Generally, the function name for an up event is awtx.keypad.KEY_NAME_UP().
This functionality can be overridden by redefining awtxReq.keypad.onZeroKeyUp, or by overriding the specific API
key handler as shown in the example.
This document only defines a few standard keys, but all scale keys follow this same form.

3.7.2.33 awtx.keypad.registerRpnEvent ( handler )


awtx.keypad.registerRpnEvent(handler)

Parameters
handler - (Function) The event handler that will be called when an RPN event occurs.

1 -- The handler function for the RPN event


2 -- keyName: The name of the key pressed i.e. ZERO, TARE, SELECT
3 -- value: The enetered value
4 local function onRpnEvent(keyName, value)
5 print(keyName .. ’ ’ .. value) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
6 end
7
8 -- Configure the RPN help strings
9 awtx.keypad.configRpn(’’,’’,’’,’’,’’,’Enter’, ’ID’)
10
11 -- Enable RPN mode
12 awtx.keypad.setRpnMode(1)
13
14 -- Register the event handler
15 awtx.keypad.registerRpnEvent(onRpnEvent)

Registers an event handler for an RPN event.


When RPN mode is enabled, an RPN event will be fired when an RPN number is entered.

3.7.2.34 awtx.keypad.selectList ( listItems , index , timeout , titleString


, helpString )
index, isEnterKey = awtx.keypad.selectList(listItems, index, timeout, titleString, helpString)

Parameters
listItems - (String) A comma-delimited string of items to populate the list.
index - (Number) The starting list index.
timeout - (Number) (Optional) The entry timeout in ms, or -1 for no timeout.
titleString - (String) (Optional) The entry title string.
helpString - (String) (Optional) The entry help string.

Returns

index - (Number) The selected index


isEnterKey - (Boolean) Returns true if a selection was made, or false if the entry was aborted.

1 -- Prompt the user to select a grain type


2 local enteredIndex, isEnterKey = awtx.keypad.selectList(’Corn,Beans,Wheat’, 10, -1, ’Select’, ’Grain’)
3 if (isEnterKey) then
4 print(’The user entered the index: ’ .. enteredIndex) -- Prints to the Lua Console (located at Ztools ->
Zedit -> Output)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
58 Class Documentation

5 else
6 print(’The user aborted the entry’) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
7 end

Opens the entry mode for selecting an item from a list.


The function returns an index to indicate which entry was chosen by the user. If isEnterKey is false, then the entry
was aborted and the value should be discarded.
Note: For this selectList function the first item in the list id deemed to be an index of 0 not 1

3.7.2.35 awtx.keypad.setDate ( year , month , day , timeout , titleString


, helpString )
entryResult, year, month, day, isEnterKey = awtx.keypad.setDate(year, month, day, timeout, titleString, helpString)

Parameters
year - (Number) The starting year value.
month - (Number) The starting month value.
day - (Number) The starting day value.
timeout - (Number) (Optional) The entry timeout in ms, or -1 for no timeout.
titleString - (String) (Optional) The entry title string.
helpString - (String) (Optional) The entry help string.

Returns

entryResult - (Number) Result of the date entry, 0 if no error.


year - (Number) The entered year value.
month - (Number) The entered month value.
day - (Number) The entered day value.
isEnterKey - (Boolean) Returns true if a number was entered, or false if the entry was aborted.

1 -- Prompt the user to enter a date value


2 local entryResult, year, month, day, isEnterKey = awtx.keypad.setDate(2015, 5, 1, -1, ’Enter’, ’Date’)
3 if (isEnterKey) then
4 print(string.format(’The user entered the date: %d%d%d’, month, day, year)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)
5 else
6 print(’The user aborted the entry’) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
7 end

Opens the entry mode for setting the system date. This function is the same a awtx.keypad.enterDate except that it
also sets the system date.
This function internally validates the entered date value. If entryResult is non-zero, then the entry was invalid and
the value should be discarded. If isEnterKey is false, then the entry was aborted and the value should be discarded.

3.7.2.36 awtx.keypad.setRpnMode ( lastRpnMode )


newRpnMode = awtx.keypad.setRpnMode(lastRpnMode)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.7 keypad Class Reference 59

Parameters
lastRpnMode - (Number) The previous state of the RPN mode.

Returns

newRpnMode - (Number) The new RPN mode.

1 local lastRpnMode = awtx.keypad.setRpnMode(1)


2 print(’The RPN was set to ’ .. lastRpnMode) -- Prints to the Lua Console (located at Ztools -> Zedit ->
Output)

Gets the current state of the system RPN mode.


RPN Modes
0 = Disabled
1 = Enabled

3.7.2.37 awtx.keypad.setTime ( hours , minutes , seconds , timeout ,


titleString , helpString )
entryResult, hours, mins, secs, isEnterKey = awtx.keypad.setTime(hours, minutes, seconds, timeout, titleString,
helpString)

Parameters
hours - (Number) The starting hours value is a 24 hour format.
minutes - (Number) The starting minutes value.
seconds - (Number) The starting seconds value
timeout - (Number) (Optional) The entry timeout in ms, or -1 for no timeout
titleString - (String) (Optional) The entry title string.
helpString - (String) (Optional) The entry help string.

Returns

entryResult - (Number) Result of the date entry, 0 if no error.


hours - (Number) The entered hours value.
mins - (Number) The entered minutes value.
secs - (Number) The entered seconds value.
isEnterKey - (Boolean) Returns true if a number was entered, or false if the entry was aborted.

1 -- Prompt the user to enter a time value


2 local entryResult, hours, minutes, seconds, isEnterKey = awtx.keypad.setTime(12, 15, 0, -1, ’Enter’,
’Time’)
3 if (isEnterKey) then
4 print(string.format(’The user entered the time: %d:%d:%d’, hours, minutes, seconds)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)
5 else
6 print(’The user aborted the entry’) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
7 end

Opens the entry mode for entering a time value. This function is the same as awtx.keypad.enterTime except that it
also sets the system time.
This function internally validates the entered time value. If entryResult is non-zero, then the entry was invalid and
the value should be discarded. If isEnterKey is false, then the entry was aborted and the value should be discarded.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
60 Class Documentation

3.7.2.38 awtx.keypad.unregisterRpnEvent ( )
awtx.keypad.unregisterRpnEvent()

1 -- The handler function for the RPN event


2 -- keyName: The name of the key pressed i.e. ZERO, TARE, SELECT
3 -- value: The entered value
4 local function onRpnEvent(keyName, value)
5 print(keyName .. ’ ’ .. value) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
6 end
7
8 -- Configure the RPN help strings
9 awtx.keypad.configRpn(’’,’’,’’,’’,’’, ’Enter’, ’ID’)
10
11 -- Enable RPN mode
12 awtx.keypad.setRpnMode(1)
13
14 -- Register the event handler
15 awtx.keypad.registerRpnEvent(onRpnEvent)
16
17 -- Unregisters the event handler
18 awtx.keypad.unregisterRpnEvent()

Unregisters the existing event handler for an RPN event.


When RPN mode is enabled, an RPN event will be fired when an RPN number is entered.

3.8 labelCtrl Class Reference

Public Member Functions

• getLocation (checkLabel)
getX, getY = labelCtrl:getLocation(checkLabel)

• getText (checkLabel)
newText = labelCtrl:getText(checkLabel)

• getVisible (checkLabel)
visible = labelCtrl:getVisible(checkLabel)

• reSize (checkLabel, getX, getY)


labelCtrl:reSize(checkLabel, getX, getY)

• setFont (checkLabel, font)


labelCtrl:setFont(checkLabel, font)

• setLocation (checkLabel, getX, getY)


labelCtrl:setLocation(checkLabel, getX, getY)

• setText (checkLabel, newText)


labelCtrl:setText(checkLabel, newText)

• setVisible (checkLabel, visible)


labelCtrl:setVisible(checkLabel, visible)

3.8.1 Detailed Description

The labelCtrl namespace handles the labels for the data being outputted on the system's screen. They handle the
label's location, text, visibility, size and font.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.8 labelCtrl Class Reference 61

3.8.2 Member Function Documentation

3.8.2.1 labelCtrl:getLocation ( checkLabel )


getX, getY = labelCtrl:getLocation(checkLabel)

Parameters
checkLabel - (String) The label we are getting the starting point for.

Returns

getX - (Number) The X-coordinate of the starting point of the label.


getY - (Number) The Y-coordinate of the starting point of the label.

1 -- Get the location of the label


2 local label = "label1"
3
4 local getX, getY = labelCtrl:getLocation(label)
5 print(string.format("The location of %s is: %d, %d", label, getX, getY)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function gets the location of the label.

3.8.2.2 labelCtrl:getText ( checkLabel )


newText = labelCtrl:getText(checkLabel)

Parameters
checkLabel - (String) The label in which we want to get text for.

Returns

newText - (String) The new text that we are going to add to the label.

1 -- Gets the text for a label.


2 local checkLable = "label 1"
3
4 local newText = labelCtrl:getText(checkLable)
5 print(string.format("This text will be set onto %s: %s", checkLable, newText)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function puts text onto the label that has been inputted.

3.8.2.3 labelCtrl:getVisible ( checkLabel )


visible = labelCtrl:getVisible(checkLabel)

Parameters
checkLabel - (String) Label that is going to be checked to see if it is visible.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
62 Class Documentation

Returns

visible - (Boolean) Determines if it is a visible label or not.

1 -- Get the visibility of the label


2 local label = "label1"
3
4 local visible = labelCtrl:getVisible(label)
5 print(string.format("The visibility of %s is: %c", label, visible)) -- Prints to the Lua Console (located
at Ztools -> Zedit -> Output)

This function grabs the visible labels to display to the user.

3.8.2.4 labelCtrl:reSize ( checkLabel , getX , getY )


labelCtrl:reSize(checkLabel, getX, getY)

Parameters
checkLabel - (String) The name of the label that has been generated for use on the system.
getX - (Number) The X-coordinate of the label's starting point on the display.
getY - (Number) The Y-coordinate of the label's starting point on the display.

1 -- Re-size the label


2 local label = "label1"
3 local getX = 25
4 local getY = 90
5
6 labelCtrl:reSize(label1, getX, getY)

This function resizes the label to a new size.

3.8.2.5 labelCtrl:setFont ( checkLabel , font )


labelCtrl:setFont(checkLabel, font)

Parameters
checkLabel - (String) The label that will have the font get set for.
font - (Number) The type of font that the label will be set as.

1 -- Set the font type for the label


2 local label = "label1"
3 local fontType = 16 -- Number code for the font type being used.
4
5 labelCtrl:setFont(label1, fontType)

This function sets the font type for the text on the label.

3.8.2.6 labelCtrl:setLocation ( checkLabel , getX , getY )


labelCtrl:setLocation(checkLabel, getX, getY)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.9 os Class Reference 63

Parameters
checkLabel - (String) The label that is going to get the location set for.
getX - (Number) The X-coordinate of the location of the label.
getY - (Number) The Y-coordinate of the location of the label.

1 -- Set the location of a label


2 local label = "label1"
3 local getX = 25
4 local getY = 90
5
6 labelCtrl:setLocation(label, getX, getY)

This function sets the location of the label.

3.8.2.7 labelCtrl:setText ( checkLabel , newText )


labelCtrl:setText(checkLabel, newText)

Parameters
checkLabel - (Text) The label that the text will be applied to.
newText - (String) The text that will be applied to the label.

1 -- Set the text onto a label


2 local checkLable = "label 1"
3 --First gets the text for the label
4 local newText = labelCtrl:getText(checkLable)
5 print(string.format("This text will be set onto %s: %s", checkLable, newText)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)
6
7 -- Then sets the label
8 awtx.graphics.labelCtrl:setText(checkLable, newText)

This function sets the text that has been received onto a label.

3.8.2.8 labelCtrl:setVisible ( checkLabel , visible )


labelCtrl:setVisible(checkLabel, visible)

Parameters
checkLabel - (String) The label we are setting to be visible.
visible - (Boolean) Determines if the label is visible or not.

1 -- Set the visibility of the label.


2 local label = "label1"
3 local visible = true
4
5 labelCtrl:setVisible(label, visible)

This function makes the label visible to the user.

3.9 os Class Reference

Public Member Functions

• applicationPath ()

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
64 Class Documentation

pathString = awtx.os.applicationPath()

• checksumFile (filePath)
result, checksum = awtx.os.checksumFile(filePath)

• compareDelta (a, b, delta)


result, result, result = awtx.os.compareDelta(a, b, delta)

• convertCsvFileToTable_LUA (strDatabase, strTableName, strCsvFileName)


result = awtx.os.convertCsvFileToTable_LUA(strDatabase, strTableName, strCsvFileName)

• convertTableToCsvFile_LUA (strDatabase, strTableName, strCsvFileName, strDirectory)


result = awtx.os.convertTableToCsvFile_LUA(strDatabase, strTableName, strCsvFileName, strDirectory)

• copyFile (sourcePath, destPath)


result = awtx.os.copyFile(sourcePath, destPath)

• cpuIdleFactor ()
result = awtx.os.cpuIdleFactor()

• createTimer (callbackFunction, timePeriod)


timerID = awtx.os.createTimer(callbackFunction, timePeriod)

• deleteDirectory (path)
awtx.os.deleteDirectory(path)

• deleteFile (delPath)
result = awtx.os.deleteFile(delPath)

• deleteFolderAndFiles (path)
awtx.os.deleteFolderAndFiles(path)

• equateDelta (a, b, delta)


result = awtx.os.equateDelta(a, b, delta)

• findFile (filePath)
result = awtx.os.findFile(filePath)

• getSealedStatus ()
result = awtx.os.getSealedStatus()

• getVersion (extent)
versionsTable = awtx.os.getVersion(extent)

• getVersionInfo (tempString)
versionTable = awtx.os.getVersionInfo(tempString)

• killTimer (timerID)
result = awtx.os.killTimer(timerID)

• listDirectory (listDirectory)
awtx.os.listDirectory(listDirectory)

• logThisError (strError)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.9 os Class Reference 65

awtx.os.logThisError(strError)

• makeDirectory (path)
result = awtx.os.makeDirectory(path)

• memoryMaxUsage ()
highwaterUsePercent, poolsize = awtx.os.memoryMaxUsage()

• memoryTest ()
reportString = awtx.os.memoryTest()

• moveFile (srcPath, destPath)


result = awtx.os.moveFile(srcPath, destPath)

• registerFtpFileAddedEvent (callbackFunction)
errorCode = awtx.os.registerFtpFileAddedEvent(callbackFunction)

• registerFtpFileDeletedEvent (callbackFunction)
errorCode = awtx.os.registerFtpFileDeletedEvent(callbackFunction)

• registerFtpFileReceivedEvent (callbackFunction)
errorCode = awtx.os.registerFtpFileReceivedEvent(callbackFunction)

• registerPasswordEnteredEvent (callbackFunction)
errorCode = awtx.os.registerPasswordEnteredEvent(callbackFunction)

• registerScriptCloseEvent (callbackFunction)
errorCode = awtx.os.registerScriptCloseEvent(callbackFunction)

• registerUsbDriveMountEvent (callbackFunction)
errorCode = awtx.os.registerUsbDriveMountEvent(callbackFunction)

• sleep (sleep)
awtx.os.sleep(sleep)

• stopwatch ()
msElapsed = awtx.os.stopwatch()

• systemEvents (timePeriod)
awtx.os.systemEvents(timePeriod)

• unregisterFtpFileAddedEvent ()
awtx.os.unregisterFtpFileAddedEvent()

• unregisterFtpFileDeletedEvent ()
awtx.os.unregisterFtpFileDeletedEvent()

• unregisterFtpFileReceivedEvent ()
awtx.os.unregisterFtpFileReceivedEvent()

• unregisterPasswordEnteredEvent ()
awtx.os.unregisterPasswordEnteredEvent()

• unregisterScriptCloseEvent ()

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
66 Class Documentation

awtx.os.unregisterScriptCloseEvent()

• unregisterUsbDriveMountEvent ()
awtx.os.unregisterUsbDriveMountEvent()

3.9.1 Detailed Description

The os namespace handles the system's operating system that is being run. It handles events including copying
and deleting files, USB archive reports, memory tests, creation and deletion of directories in the system, and other
various functions described below.

3.9.2 Member Function Documentation

3.9.2.1 awtx.os.applicationPath ( )
pathString = awtx.os.applicationPath()

Returns

pathString - (String) A Lua string specifying the fully qualified path to the application folder.

1 local pathString = awtx.os.applicationPath()


2 print(string.format("Application path is %s", pathString)) -- Prints to the Lua Console (located at Ztools
-> Zedit -> Output)

This function returns a Lua string specifying the fully qualified path to the Scale's Application folder.
The Application folder is the place where the Scale's Lua files are stored.
Note:
C: Represents the drive letter for the internal flash memory in the Scale
G: Represents the drive letter for an external USB memory stick

3.9.2.2 awtx.os.checksumFile ( filePath )


result, checksum = awtx.os.checksumFile(filePath)

Parameters
filePath - (String) A Lua string specifying a fully qualified filepath

Returns

result - (Number) 0 if the file specified by the filePath was found, else -1.
checksum - (Number) A 16 bit checksum for the specified file.

1 -- Don’t forget for this style of Lua string two \\’s are needed
2 local filepath = "c:\\myfolder\\myFile.txt"
3
4 local result, csum = awtx.os.checksumFile(filePath)
5 print(string.format("File %s result=%d, csum=0x%04X", filepath, result, csum)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.9 os Class Reference 67

This function returns a 16 bit checksum for the specified file.


Note:
C: Represents the drive letter for the internal flash memory in the Indicator
G: Represents the drive letter for an external USB memory stick

3.9.2.3 awtx.os.compareDelta ( a , b , delta )


result, result, result = awtx.os.compareDelta(a, b, delta)

Parameters
a - (Number) The first Lua number to use for the comparison.
b - (Number) The second Lua number to use for the comparison.
delta - (Number) The threshold band to use when comparing the numbers.

Returns

result - (Number) Returns 0 if the two numbers are within the delta threshold band.
result - (Number) Returns -1 if the first argument is less than the second argument.
result - (Number) Returns +1 if the first argument is greater than the second argument.

1 a = 0.00000000100
2 b = 0.00000000110
3 delta = 0.00000000001
4
5 result = awtx.os.compareDelta(a, b, delta)
6
7 -- Print statements output to the Lua Console (located at Ztools -> Zedit -> Output)
8 if (result == 0) then
9 print("ARGS_ARE_WITHIN_DELTA")
10 elseif (result == -1) then
11 print("FIRST_ARG_IS_LESS")
12 elseif (result == 1) then
13 print("FIRST_ARG_IS_GREATER\r
14 ")
15 end

This function compares 2 Lua double precision floating point numbers using a delta threshold band to test for
equality.
This function is needed sometimes when a very small difference in two floating point numbers will make a simple
== equality test fail due to the numbers not being precisely equal. If not equal the returned result indicates whether
the first argument is less then or greater than the second.

3.9.2.4 awtx.os.convertCsvFileToTable_LUA ( strDatabase ,


strTableName , strCsvFileName )
result = awtx.os.convertCsvFileToTable_LUA(strDatabase, strTableName, strCsvFileName)

Parameters
strDatabase - (String) The name and the path to the database file.
strTableName - (String) The name of the database table.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
68 Class Documentation

strCsvFileName - (String) Name of the CSV file being converted.

Returns

result - (Number) Displays whether the conversion process succeeded or failed.

1 -- Converts the csv file into a table.


2 local result = awtx.os.convertCsvFileToTable_LUA(databaseName, tableName, csvFile)

This function takes a CSV file and then converts the file into a sqlite table.
For result:
0 = SUCCESS

3.9.2.5 awtx.os.convertTableToCsvFile_LUA ( strDatabase ,


strTableName , strCsvFileName , strDirectory )
result = awtx.os.convertTableToCsvFile_LUA(strDatabase, strTableName, strCsvFileName, strDirectory)

Parameters
strDatabase - (String) The name and path of the database.
strTableName - (String) The name of the sqlite database table.
strCsvFileName - (String) The name of the CSV File.
strDirectory - (String) The directory being used.

Returns

result - (Int) Displays whether or not the conversion process succeeded or failed.

1 -- Converts the sqlite table into a csv file.


2 local result = awtx.os.convertTableToCsvFile_LUA(databaseName, tableName, csvFile, userDirectory)

This function converts a sqlite table and writes it out as a CSV file.
Return types for result:
0 = SUCCESS
otherwise
SQLITE3 ERROR

3.9.2.6 awtx.os.copyFile ( sourcePath , destPath )


result = awtx.os.copyFile(sourcePath, destPath)

Parameters
sourcePath - (String) A string specifying a fully qualified file path to the source file.
destPath - (String) A string specifying a fully qualified file path to the destination file.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.9 os Class Reference 69

Returns

result - (Number) Returns 0 if the file was copied OK. else an error result number.

1 -- Don’t forget for this style of Lua string two \\’s are needed
2 local srcFilepath = "c:\\myDir\\mySrcFile.txt"
3 local destFilepath = "c:\\myDir\\myDestFile.txt"
4
5 local result = awtx.os.copyFile(srcFilePath, destFilePath)
6
7 print(string.format("Filecopy result is %d", result)) -- Prints to the Lua Console (located at Ztools ->
Zedit -> Output)

1 -- As an alternative the file path could have been specified like this
2 -- in which case the string is literal and a single \ is correct
3 local filepath = ((c:\myDir\mySrcFile.txt))

This function copies a file. The function returns 0 if the file is copied successfully, else an error result number.
Note:
C: Represents the drive letter for the internal flash memory in the Indicator
G: Represents the drive letter for an external USB memory stick

3.9.2.7 awtx.os.cpuIdleFactor ( )
result = awtx.os.cpuIdleFactor()

Returns

result - (Number) Returns a number that represents the current CPU loading.

1 print(string.format("cpuIdleFactor() = %d", awtx.os.cpuIdleFactor())) -- Prints to the Lua Console (located


at Ztools -> Zedit -> Output)

This function returns a number that represents the current CPU loading.
The scale is arbitrary, the larger then number the less loaded the CPU, the smaller the number the greater the CPU
loading
For example, the code sample below will print a number in the range of 100. However if the systemEvents() call
was mistakenly mitted, then the code sample would essentially be an infinite loop that never relinquishes the CPU
so the cpuIdleFactor number would drop to 0, indicating that the script is very badly hogging the CPU.

3.9.2.8 awtx.os.createTimer ( callbackFunction , timePeriod )


timerID = awtx.os.createTimer(callbackFunction, timePeriod)

Parameters
callbackFunction - (Function) The Lua function to be called when the timer period expires.
timePeriod - (Number) The required time period in milliseconds.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
70 Class Documentation

Returns

timerID - (Number) Returns a numeric reference to this new timer.

1 local counter = 0
2
3 -- The timer function that runs every 1 second
4 function luaTimerCallback(timerID)
5 counter = counter + 1
6 print (string.format("Lua callback function. timerID=%d counter=%d", timerID, counter)) -- Prints to the
Lua Console (located at Ztools -> Zedit -> Output)
7 end
8
9 -- Main program start
10 timerID1 = awtx.os.createTimer(luaTimerCallback, 1000) -- 1 Second period
11 print(string.format("Lua: Created timerID1 = %d", timerID1)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)

This function creates a periodic timer that will call a specified Lua function with a time period set by the function call.
When the Lua callback function is called by the Scale, it will have one Lua input parameter specifying the timerID of
the timer that has just expired.

3.9.2.9 awtx.os.deleteDirectory ( path )


awtx.os.deleteDirectory(path)

Parameters
path - (String) The pathway of the string that you want to have deleted.

1 -- Delete the directory C:/mydir


2 local deleteFile = "c:\\myDir"
3 print("We will delete the file now.") -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
4 awtx.os.deleteDirectory(deleteFile)
5 print(string.format("%s has been deleted.", deleteFile)) -- Prints to the Lua Console (located at Ztools ->
Zedit -> Output)

This function takes the pathway of a directory and deletes it.

3.9.2.10 awtx.os.deleteFile ( delPath )


result = awtx.os.deleteFile(delPath)

Parameters
delPath - (String) Pathway of the file that is going to be deleted.

Returns

result - (Number) Returns 0 if the file was deleted okay, else an error result number

1 -- Don’t forget for this style of Lua string two \\’s are needed
2 local delPath = "c:\\myDir\\plzDeleteMe.txt"
3
4 local result = awtx.os.deleteFile(delPath)
5
6 print(string.format("File delete result is %d", result)) -- Prints to the Lua Console (located at Ztools ->
Zedit -> Output)

This function deletes a file at the path that was given.


Note:
C: Represents the drive letter for the internal flash memory in the Indicator
G: Represents the drive letter for an external USB memory stick

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.9 os Class Reference 71

3.9.2.11 awtx.os.deleteFolderAndFiles ( path )


awtx.os.deleteFolderAndFiles(path)

Parameters
path - (String) The pathway to the file or folder that you want deleted.

1 -- delete the file deleteMe.txt


2 local file = "c:\\myDir\\myCurFolder\\deleteMe.txt"
3 awtx.os.deleteFolderAndFiles(file)

This function takes the pathway of a file and/or folder and deletes it.

3.9.2.12 awtx.os.equateDelta ( a , b , delta )


result = awtx.os.equateDelta(a, b, delta)

Parameters
a - (Number) The first Lua number to test for equality against.
b - (Number) The second Lua number to test for equality againnst.
delta - (Number) The threshold band to use when testing the numbers for equality.

Returns

result - (Number) Returns 1 if the two numbers are within the delta threshold band, else returns 0.

1 local a = 0.0000001
2 local b = 0.0000002
3 local delta = 0.0000010
4
5 local result = awtx.os.equateDelta(a, b, delta)
6
7 if (result == 1) then
8 print(" the numbers are within a small delta of each other.") -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)
9 end

This function tests whether 2 Lua double precision floating point numbers are within a delta threshold band and
therefore deemed to be equal.
This function is needed sometimes when a very small difference in two floating point numbers will make a simple
== equality test fail due to the numbers not being precisely equal."

3.9.2.13 awtx.os.findFile ( filePath )


result = awtx.os.findFile(filePath)

Parameters
filePath - (String) A Lua string specifying a fully qualified filepath.

Returns

result - (Number) Returns 0 if the file was found, else a non zero number indicating the file was not found.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
72 Class Documentation

1 -- Don’t forget for this style of Lua string two \\’s are needed.
2 local filepath = "c:\\myFolder\\myFile.txt"
3
4 if (awtx.os.findFile(filepath) == 0) then
5 print(string.format("File %s was found", filepath)) -- Prints to the Lua Console (located at Ztools ->
Zedit -> Output)
6 else
7 print(string.format("File %s was not found", filepath)) -- Prints to the Lua Console (located at Ztools
-> Zedit -> Output)
8 end

1 -- As an alternative the filepath could have been specified like this


2 -- in which case the string is literal and a single \ is correct
3 local filepath = ((c:\myFolder\myFile.txt))

This function returns 0 if the file specified in the filepath was found, else a non zero number indicating the file was
not found.
Note:
C: Represents the drive letter for the internal flash memory in the Indicator
G: Represents the drive letter for an external USB memory stick

3.9.2.14 awtx.os.getSealedStatus ( )
result = awtx.os.getSealedStatus()

Returns

result - (Number) Returns 0 if the unit is sealed, otherwise returns 1.

1 -- Determines whether the object was or wasn’t sealed.


2
3 local objectSealed = awtx.os.getSealedStatus()

This function checks to see if the unit has or hasn't been sealed.

3.9.2.15 awtx.os.getVersion ( extent )


versionsTable = awtx.os.getVersion(extent)

Parameters
extent - (String) This is an optional parameter, if it is absent the returned table will contain version
information about the installed User applications only. If extent = '∗all' then the returned table
will also contain additional version information regarding some internal machine libraries.

Returns

versionsTable - (Table) A table containing a number of tables each describing the version, date, and description
information of the Installed User Applications.

1 -- Print statements are outputted to the Lua Console (located at Ztools -> Zedit -> Output)
2 print(" Installed Applications version information")
3
4 versionsTable = awtx.os.getVersionInfo("*all")
5
6 -- use ipairs here not pairs so that the data comes out in sensible order
7 for i, j in ipairs(versionTable) do
8 print()

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.9 os Class Reference 73

9 if type(j) == "table" then


10 for k,v in pairs(j) do
11 print(string.format("%-8s %-25s", k, tostring(v)))
12 end
13 end
14 end

This function returns a Lua table comprising of a number of other tables each detailing the version information of
the installed User Application scripts.
There will be one inner table for each on the User Application in the Scale, typically there will be 10 installed
Applications. Each inner table contains 3 key, value pairs, the keys are "date", "version", and "desc". See example
code and output for more information.

3.9.2.16 awtx.os.getVersionInfo ( tempString )


versionTable = awtx.os.getVersionInfo(tempString)

Parameters
tempString - (String) Tells what versions should be returned.

Returns

versionTable - (Table) Table of versions to be displayed. Outer table is the array type and the inner table are
hash types.

1 -- Gets all of the versions that have been made


2
3 local versionString = "*all"
4
5 local versionTable = awtx.os.getVersionInfo(verisonString)
6
7 for x, y, z in pairs(versionTable) do -- X = Version, Y = Date, Z = Description
8 print(x,y,z) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
9 end

This function finds all of the versions and returns a table of all the different verisons.
"tempString" should be "∗all" to return a table of everything.

3.9.2.17 awtx.os.killTimer ( timerID )


result = awtx.os.killTimer(timerID)

Parameters
timerID - (Number) The timerID reference number that was returned from the previous awtx.os.←-
createTimer() function call.

Returns

result - (Number) 0 for Success.

1 -- Print statements output to the Lua Console (located at Ztools -> Zedit -> Output)
2 local counter = 0
3
4 -- The timer function that runs every 1 second
5 function luaTimerCallback(timerID)
6 counter = counter + 1
7 print (string.format("Lua callback function. timerID=%d counter=%d", timerID, counter))
8 end

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
74 Class Documentation

9
10 -- Main program start
11 local timerID1 = awtx.os.createTimer(luaTimerCallback, 1000) --1 second period
12 print(string.format("Lua: Create timerID1 = %d", timerID1))
13
14 -- After the timer callback has run 10 times, kill this timer
15 if counter >= 10 then
16 result = awtx.os.killTimer(timerID1)
17 end
18 end

This function destroys a timer created with a previous call to awtx.os.createTimer()

3.9.2.18 awtx.os.listDirectory ( listDirectory )


awtx.os.listDirectory(listDirectory)

Parameters
listDirectory - (String) A Lua string specifying a fully qualified folder path.

1 -- Don’t forget for this style of Lua string two \\’s are needed
2 local filepath = "c:\\myFolder\\myFile.txt"
3
4 if (awtx.os.findFile(filepath) == 0) then
5 print(string.format("File %s was found", filepath)) -- Prints to the Lua Console (located at Ztools ->
Zedit -> Output)
6 awtx.os.listDirectory(filepath)
7 else
8 print(string.format("File %s was not found", filepath)) -- Prints to the Lua Console (located at Ztools
-> Zedit -> Output)
9 end

1 -- As an alternative the filepath could have been specified like this’


2 -- in which case the string is literal and a single \ is correct
3 local filepath = ((c:\myFolder\myFile.txt))

This function lists the directory contents specified by the folderPath to the default serial port.
Note:
C: Represents the drive letter for the internal flash memory in the Indicator
G: Represents the drive letter for an external USB memory stick

3.9.2.19 awtx.os.logThisError ( strError )


awtx.os.logThisError(strError)

Parameters
strError - (String) String that is an error message that is going to be logged.

1 --Registers an error
2 awtx.os.logThisError(errorMessage)

This function takes an error message and then logs the error.
If the function is called with null it could be a Lua bug where the function was called with nil instead of a Lua string.

3.9.2.20 awtx.os.makeDirectory ( path )


result = awtx.os.makeDirectory(path)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.9 os Class Reference 75

Parameters
path - (String) The pathway that will be created for the new directory.

Returns

result - (Number) Returns 0 if the file was moved okay, otherwise returns with an error result number.

1 -- Don’t forget for this style of Lua string two \\’s are needed.
2 local newDir = "c:\\%newDir"
3
4 local result = awtx.os.makeDirectory(newDir)
5
6 -- Print to the Lua Console (located at Ztools -> Zedit -> Output)
7 print(string.format("The %d directory has been created.", result))

This function creates a new directory in the path that is given.


Note:
C: Represents the drive letter for the internal flash memory in the Indicator
G: Represents the drive letter for an external USB memory stick

3.9.2.21 awtx.os.memoryMaxUsage ( )
highwaterUsePercent, poolsize = awtx.os.memoryMaxUsage()

Returns

highwaterUsePercent - (Number) The maximum memory pool usage so far, as a percentage of the total size
of the memory pool.
poolsize - (Number) The size of the memory pool in bytes.

1 print(string.format("High Water Percent used = %2.2f%% Poolsize = %d bytes", awtx.os.memoryMaxUsage())) --


Prints to the Lua Console (located at Ztools -> Zedit -> Output)
2 --Example output
3 --High Water Percent used = 50.68% Poolsize = 80011856 bytes

This function returns the maximum memory pool usage so far as a percentage of the total size of the memory pool.
The second returned parameter is the size of the memory pool in bytes.

3.9.2.22 awtx.os.memoryTest ( )
reportString = awtx.os.memoryTest()

Returns

reportString - (String) Returns a Lua string detailing the internal memory pool status.

1 print(string.format("Test: %s:", awtx.os.memoryTest())) -- Prints to the Lua Console (located at Ztools ->
Zedit -> Output)
2
3 --Example output
4 --Test: Memory pool Integrity test is OK
5 --Lua Allocs: Frees: Diff = 0.1MB: 0.0MB: 71kB

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
76 Class Documentation

This function returns a Lua string detailing the internal memory pool status.
Looking at the code sample below, the 3 numbers printed left to right
a) Total memory pool allocations since the Indicator was switched on
b) Total memory pool de-allocations since the Indicator was switched on
c) Difference between a) and b) which is the current amount of memory pool in use

3.9.2.23 awtx.os.moveFile ( srcPath , destPath )


result = awtx.os.moveFile(srcPath, destPath)

Parameters
srcPath - (String) The source location of the file that is going to be moved.
destPath - (String) The destination location for the file that will be moved.

Returns

result - (Number) Returns 0 if the file was moved okay, else an error result number.

1 -- Don’t forget for this style of Lua string two \\’s are needed.
2 local srcPath = "c:\\myDir\\mySrcFile.txt"
3 local destPath = "c:\\myDir\\myDestFile.txt"
4
5 local result = awtx.os.moveFile(srcPath, destPath)
6
7 print(string.format("File move result is %d", result)) -- Prints to the Lua Console (located at Ztools ->
Zedit -> Output)

This function moves a file from its original location to a new location that has been specified.
Note:
C: Represents the drive letter for the internal flash memory in the Indicator
G: Represents the drive letter for an external USB memory stick

3.9.2.24 awtx.os.registerFtpFileAddedEvent ( callbackFunction )


errorCode = awtx.os.registerFtpFileAddedEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale will call when a file has been uploaded to the
indicator via FTP.

Returns

errorCode - (Number) Returns 0 if no error occurred during registration.

1 -- Event handler to be called when files are uploaded via FTP.


2 function onFtpFileAdded(fileName)
3 print(string.format("FTP file upload detected: %s\r
4 ", fileName)) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
5 end
6
7 -- Register callback function "onFtpFileAdded" to handle FTP transfer event.
8 awtx.os.registerFtpFileAddedEvent(onFtpFileAdded)

Registers a Lua event handler function to be called when a file is uploaded to the system via FTP.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.9 os Class Reference 77

3.9.2.25 awtx.os.registerFtpFileDeletedEvent ( callbackFunction )


errorCode = awtx.os.registerFtpFileDeletedEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale will call when a file is deleted via FTP.

Returns

errorCode - (Number) Returns 0 if no error occurred during registration.

1 -- Event handler to be called when files are deleted via FTP.


2 function onFtpFileDeleted(fileName)
3 print(string.format("FTP file deletion detected: %s\r
4 ", fileName)) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
5 end
6
7 -- Register callback function "onFtpFileDeleted" to handle FTP file delete event.
8 awtx.os.registerFtpFileDeletedEvent(onFtpFileDeleted)

Registers a Lua event handler function to be called when a file is deleted via FTP.

3.9.2.26 awtx.os.registerFtpFileReceivedEvent ( callbackFunction )


errorCode = awtx.os.registerFtpFileReceivedEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale will call when a file is received via FTP.

Returns

errorCode - (Number) Returns 0 if no error occurred during registration.

1 -- Event handler to be called when files are received via FTP.


2 function onFtpFileReceived(fileName)
3 print(string.format("FTP file received: %s\r
4 ", fileName)) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
5 end
6
7 -- Register callback function "onFtpFileReceived" to handle FTP file received event.
8 awtx.os.registerFtpFileReceivedEvent(onFtpFileReceived)

Registers a Lua event handler function to be called when a file is received via FTP.

3.9.2.27 awtx.os.registerPasswordEnteredEvent ( callbackFunction )


errorCode = awtx.os.registerPasswordEnteredEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale calls when a user enters a non-system pass-
word.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
78 Class Documentation

Returns

errorCode - (Number) Returns 0 if no error occurred during registration.

1 -- Event handler to be called when the user enters a non-system password (system passwords are handled
internally and will not be seen by lua).
2 function onPasswordEntered(enteredPassword)
3 print(string.format("User entered password: %s\r
4 ", enteredPassword)) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
5 end
6
7 -- Register callback function "onPasswordEntered" to be called when the user enters a non-system
password.
8 awtx.os.registerPasswordEnteredEvent(onPasswordEntered)

Registers a Lua event handler function to be called when a user enters a non-system password.

3.9.2.28 awtx.os.registerScriptCloseEvent ( callbackFunction )


errorCode = awtx.os.registerScriptCloseEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale calls when the user script is closing.

Returns

errorCode - (Number) Returns 0 if no error occurred during registration.

1 -- Print statements get outputted to the Lua Console (located in Ztools -> Zedit -> Output)
2 -- Event handler to be called when the user script closes.
3 function onScriptClose()
4 print(string.format("User script closing...\r
5 "))
6 print(string.format("Performing cleanup actions...\r
7 "))
8 end
9
10 -- Register callback function "onScriptClose" to handle script close events.
11 awtx.os.registerScriptCloseEvent(onScriptClose)

Registers a Lua event handler function to be called when the user script is closing.

3.9.2.29 awtx.os.registerUsbDriveMountEvent ( callbackFunction )


errorCode = awtx.os.registerUsbDriveMountEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale will call when a USB drive is inserted or
removed.

Returns

errorCode - (Number) Returns 0 if no error occurred during registration.

1 -- Event handler to be called when a USB drive is inserted or removed.


2
3 -- Print statements are outputted to the Lua Console (located at Ztools -> Zedit -> Output)
4 function onUsbDriveMount(mounted, driveLetter)
5 if mounted == true then
6 print(string.format("USB drive inserted...\r

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.9 os Class Reference 79

7 Drive letter assigned: %s\r


8 ", driveLetter))
9 else
10 print(string.format("USB drive removed...\r
11 Drive letter removed: %s\r
12 ", driveLetter))
13 end
14 end
15
16 -- Register callback function "onUsbDriveMount" to handle USB drive mount/unmount events.
17 awtx.os.registerUsbDriveMountEvent(onUsbDriveMount)

Registers a Lua event handler function to be called when a USB drive is inserted or removed.

3.9.2.30 awtx.os.sleep ( sleep )


awtx.os.sleep(sleep)

Parameters
sleep - (Number) Number that tells how long the system will be in sleep for.

1 -- Put the system to sleep for 4 seconds


2 awtx.os.sleep(4000)

This function determines when the scale will enter a rest state and for how long it will be in the rest state.
For the sleep integer, 1 second of sleep = 1000 units

3.9.2.31 awtx.os.stopwatch ( )
msElapsed = awtx.os.stopwatch()

Returns

msElapsed - (Number) The amount of time (in milliseconds) that has elapsed since the first time it was called.

1 -- Simple stopwatch example


2
3 awtx.os.stopwatch()
4
5 local i = 0
6 while i < 5 do
7 i = i + 1
8 end
9 if i == 5 then
10 local watch = awtx.os.stopwatch()
11 end

This function returns the number of milliseconds that have passed since the last time it was called.

3.9.2.32 awtx.os.systemEvents ( timePeriod )


awtx.os.systemEvents(timePeriod)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
80 Class Documentation

Parameters
timePeriod - (Number) This is the time period in milliseconds that the Lua program will pause for, in order
to share the CPU with other events.

1 -- Main Program Loop


2 while true do
3
4 awtx.os.systemEvents(100) -- 100 mS period to let other events have CPU time
5
6 -- main program do something here ......
7 end

This function will pause the Lua program for the specified period.
This is an important function as it must be included in the Lua program's main loop. If this is omitted from the main
loop, the rest of the system will start due to the user program hogging the CPU.

3.9.2.33 awtx.os.unregisterFtpFileAddedEvent ( )
awtx.os.unregisterFtpFileAddedEvent()

1 -- Unregister a FTP File added event


2 awtx.os.unregisterFtpFileAddedEvent()

This function unregisters the FTP files that have have been added to free up space in the memory of the scale.

3.9.2.34 awtx.os.unregisterFtpFileDeletedEvent ( )
awtx.os.unregisterFtpFileDeletedEvent()

1 -- Unregister a FTP file delete event


2 awtx.os.unregisterFtpFileDeletedEvent()

This function unregisters an FTP File delete event from the scale's memory.

3.9.2.35 awtx.os.unregisterFtpFileReceivedEvent ( )
awtx.os.unregisterFtpFileReceivedEvent()

1 -- Unregister a FTP file received event


2 awtx.os.unregisterFtpFileReceivedEvent()

Unregisters a FTP File received event so that it can clear it from memory.

3.9.2.36 awtx.os.unregisterPasswordEnteredEvent ( )
awtx.os.unregisterPasswordEnteredEvent()

1 -- Unregisters a Password
2 awtx.os.unregisterPasswordEnteredEvent()

This function removes the password so that it can be erased from memory.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.10 pictureboxCtrl Class Reference 81

3.9.2.37 awtx.os.unregisterScriptCloseEvent ( )
awtx.os.unregisterScriptCloseEvent()

1 -- Unregister a scipt close event


2 awtx.os.unregisterScriptCloseEvent()

This function unregisters a script close event to erase it from memory.

3.9.2.38 awtx.os.unregisterUsbDriveMountEvent ( )
awtx.os.unregisterUsbDriveMountEvent()

1 -- Unmount a USB Drive


2 awtx.os.unregisterUsbDriveMountEvent()

This function unregisters the USB Drive device so that it can be erased from memory.

3.10 pictureboxCtrl Class Reference

Public Member Functions

• getLocation (checkPicture)
getX, getY = pictureboxCtrl:getLocation(checkPicture)

• getVisible (checkPicture)
visible = pictureboxCtrl:getVisible(checkPicture)

• setLocation (checkPicture, getX, getY)


pictureboxCtrl:setLocation(checkPicture, getX, getY)

• setVisible (checkPicture, visible)


pictureboxCtrl:setVisible(checkPicture, visible)

3.10.1 Detailed Description

The pictureboxCtrl namespace handles the picture boxes that appear on the screen of the system. It handles the
location and visibility of these picture boxes.

3.10.2 Member Function Documentation

3.10.2.1 pictureboxCtrl:getLocation ( checkPicture )


getX, getY = pictureboxCtrl:getLocation(checkPicture)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
82 Class Documentation

Parameters
checkPicture - (String) The name of the picturebox in which we want to find the starting point of.

Returns

getX - (Number) The X-coordinate of the starting point of the picturebox.


getY - (Number) The Y-coordinate of the starting point of the picturebox.

1 -- Get the location of the picturebox


2 local picturebox = "pictureBox1"
3 local getX, getY = pictureboxCtrl:getLocation(picturebox)
4
5 print(string.format("The location of %s is: %d, %d", picturebox, getX, getY)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function finds the location of the picturebox on the scale.

3.10.2.2 pictureboxCtrl:getVisible ( checkPicture )


visible = pictureboxCtrl:getVisible(checkPicture)

Parameters
checkPicture - (String) The picturebox we want to check the availability of.

Returns

visible - (Boolean) Determines whether of not the picturebox is visible.

1 -- Get the visibility of the picturebox


2 local picturebox = "picturebox2"
3 local visibility = pictureboxCtrl:getVisibility(picturebox)
4
5 print(string.format("The visibility of %s is set to: %c", picturebox, visibility)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

This function gets the visibility of the picturebox on the scale.

3.10.2.3 pictureboxCtrl:setLocation ( checkPicture , getX , getY )


pictureboxCtrl:setLocation(checkPicture, getX, getY)

Parameters
checkPicture - (String) The picturebox we want to set to the starting point.
getX - (Number) The X-coordinate of the starting point of the picturebox.
getY - (Number) The Y-coordinate of the starting point of the picturebox.

1 -- Set the location of the picturebox


2 local picturebox = "picturebox1"
3 local getX = -5
4 local getY = 15
5
6 pictureboxCtrl:setLocation(picturebox, getX, getY)

This function sets the location of the picturebox on the scale.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.11 ports Class Reference 83

3.10.2.4 pictureboxCtrl:setVisible ( checkPicture , visible )


pictureboxCtrl:setVisible(checkPicture, visible)

Parameters
checkPicture - (String) The picturebox we want to set the visibility of.
visible - (Boolean) Determines whether or not the picturebox is visible or not.

1 -- Set the visibility of the picturebox


2 local picturebox = "picturebox1"
3 local visibility = true
4
5 pictureboxCtrl:setVisible(picturebox, visibility)

This function sets the visibility of the picturebox on the scale.

3.11 ports Class Reference

Public Member Functions

• getInputPollPeriod ()
result = awtx.ports.getInputPollPeriod()

• getInputs ()
bitPattern = awtx.ports.getInputs()

• getOutputs ()
bitPattern = awtx.ports.getOutputs()

• registerSwitchChangeEvent (callbackFunction)
result = awtx.ports.registerSwitchChangeEvent(callbackFunction)

• setInputPollPeriod (arg1)
result = awtx.ports.setInputPollPeriod(arg1)

• unregisterSwitchChangeEvent ()
awtx.ports.unregisterSwitchChangeEvent()

3.11.1 Detailed Description

The ports namespace handles the inputting and outputting data from the ports installed on the system. It also
controls the port change events and the poll period events.

3.11.2 Member Function Documentation

3.11.2.1 awtx.ports.getInputPollPeriod ( )
result = awtx.ports.getInputPollPeriod()

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
84 Class Documentation

Returns

result - (Number) The value of the current input for the poll period.

1 -- Grab the input poll period


2
3 local result = awtx.ports.getInputPollPeriod()
4 print(string.format("The input poll period is: %2f", result)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)

Grabs the current input poll period value and sets it up to be modified.
Currently, this function will always return 0 since result is not being modified.

3.11.2.2 awtx.ports.getInputs ( )
bitPattern = awtx.ports.getInputs()

Returns

bitPattern - (Bit table) Returns a bit pattern of the current Input switch settings.

1 -- Print the state of the 3 input switches


2 local bits = awtx.ports.getInputs()
3 print (string.format("Input Bits = 0x%02X", bits)) -- Prints to the Lua Console (located at Ztools -> Zedit
-> Output)

This function returns a bit pattern of the state of the Scale's input switches
Where:
bit 0 = Input Switch 1
bit 1 = Input Switch 2
bit 2 = Input Switch 3

3.11.2.3 awtx.ports.getOutputs ( )
bitPattern = awtx.ports.getOutputs()

Returns

bitPattern - (Bit table) Returns a bit pattern of the current output switch settings.

1 -- Print the state of the 3 output switches.


2 local bits = awtx.ports.getOutputs()
3 print(string.format("Output Bits = 0X%02X", bits)) -- Prints to the Lua Console (located at Ztools -> Zedit
-> Output)

Function returns a bit pattern of the state of the scale's output switches.
Where bitPattern can equal:
bit 0 = Output Switch 1
bit 1 = Output Switch 2
bit 2 = Output Switch 3

3.11.2.4 awtx.ports.registerSwitchChangeEvent ( callbackFunction )


result = awtx.ports.registerSwitchChangeEvent(callbackFunction)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.11 ports Class Reference 85

Parameters
callbackFunction - (Function) The Lua function to be called when any one of the input switches changes state.

Returns

result - (Number) Returns 0 on success, else error -1 if the callback function is not specified.

1 -- This function will be called when any switch changes state


2
3 -- inputBits is the current state of all input switches
4 -- changeSwNum is the switch number that just flipped
5 -- newState is the new state of the bit that changed 0 = Off, 1 = On
6
7 function onSwitchChange(inputBits, changedSwNum, newState)
8 -- print out the details of what has just changed
9 print (string.format("Input Word=0x%02X Changed Switch Num.=%d New State=%d", inputBits, changedSwNum,
newState)) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
10 end
11
12 -- register the callback function that should be called when a switch is flipped
13 awtx.ports.registerSwitchChangeEvent(switchChangeFunc)

This function tells the Scale which Lua function it should call when one of the Scale's input switches changes state.
When the Lua callback function is triggered by a switch changing state, the callback function will be passed 3 input
parameters. See the code sample below for a description of the parameters.

3.11.2.5 awtx.ports.setInputPollPeriod ( arg1 )


result = awtx.ports.setInputPollPeriod(arg1)

Parameters
arg1 - (Number) Input that will be modified.

Returns

result - (Number) Modified input for poll period.

1 -- Sets an input poll period


2 local setPoll = awtx.ports.setInputPollPeriod(1)
3
4 print(string.format("Currently set input poll is: %2f", setPoll)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)

This function will set the Input poll period.


Currently, the result will always return the value of 1.

3.11.2.6 awtx.ports.unregisterSwitchChangeEvent ( )
awtx.ports.unregisterSwitchChangeEvent()

1 -- remove the shutdown function handler


2 awtx.ports.unregisterSwitchChangeEvent()

This function unregisters a previously set switch change event callback function. After this unregister function is
called, a change of switch state will no longer generate a call to the event handler.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
86 Class Documentation

3.12 printer Class Reference

Public Member Functions

• printFmt (formatNum)
awtx.printer.printFmt(formatNum)

• registerPrinterJobStatusEvent (callbackFunction)
awtx.printer.registerPrinterJobStatusEvent(callbackFunction)

• registerPrinterStatusEvent (callbackFunction)
awtx.printer.registerPrinterStatusEvent(callbackFunction)

• reportFmt (formatNum, formatType)


awtx.printer.reportFmt(formatNum, formatType)

• unregisterPrinterStatus ()
awtx.printer.unregisterPrinterStatus()

• unregisterPrinterJobStatusEvent ()
awtx.printer.unregisterPrinterJobStatusEvent()

3.12.1 Detailed Description

The printer namespace handles the printing of data from the system. It controls the formatting of the printed items
and handles the registration of printer job status events.

3.12.2 Member Function Documentation

3.12.2.1 awtx.printer.printFmt ( formatNum )


awtx.printer.printFmt(formatNum)

Parameters
formatNum - (Number) The label format number to be printed.

1 -- Print the passed parameter label format to the bound "print" port
2 awtx.printer.PrintFmt(1)

This function requests a print using the passed in formatNum print format information.
It uses the passed in argument to define the Label print format number to be used. It constructs a label based on
that number and the current weighing data which then gets sent out to the bound external Port(s).

3.12.2.2 awtx.printer.registerPrinterJobStatusEvent ( callbackFunction


)
awtx.printer.registerPrinterJobStatusEvent(callbackFunction)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.12 printer Class Reference 87

Parameters
callbackFunction - (Function) The Lua callback function the Indicator calls when the Print Event has completed.

1 -- Callback function arguments: This shows the 2 function arguments that are available to the callback
function.
2 function onPrinterJobComplete(printerNumber, jobResult)
3 -- Print statements are outputted to the Lua Console (located at Ztools -> Zedit -> Output)
4 print("Printer Job callback function has been called")
5 print(string.format("Printer Number is %d", printerNumber))
6 print(string.format("Printer Job Result is %d", jobResult))
7 end
8
9 -- Register our callback function, this is just a demo function that prints the Job result number
10 result = awtx.printer.registerPrinterStatusEvent(onPrinterJobComplete)
11
12 -- Printer Job Result Constraints:
13 --
14 -- PRINTER_EOL = 0
15 -- PRINTER_JOB_DONE = 1
16 -- PRINTER_JOB_ABORTED = 2
17 -- PRINTER_JOB_CREATE_FAIL = 3
18 --

This registers a Lua callback function that will be called when a printing job completes.
The application can look at the passed in arguments and then decide what it needs to do. The callback function can
tell the application information such as Printer number, Print Completed, Print Failed, Print Aborted. etc.
When the callback function is called it is passed 2 parameters to indicate the status of the remote printer. Because
of Lua's flexibility with function input parameters the programmer can choose to define a function that passes in all
of these parameters or omit as many of these parameters as desired.

3.12.2.3 awtx.printer.registerPrinterStatusEvent ( callbackFunction )


awtx.printer.registerPrinterStatusEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the Indicator calls when the Print Event has completed.

1 --Callback function arguments:


2
3 --This shows the 6 function arguments that are available to the callback function
4
5 function printerStatusCallback(printerNumber, onlineOffline, selected, paperOut, generalError, statusOK)
6 end

1 function onPrinterStatus(printerNumber, onlineOffline, selected, paperOut, generalError, statusOK)


2 -- Print statements are outputted to the Lua Console (located at Ztools -> Zedit -> Output)
3 print("Printer Status callback function has been called")
4
5 print(string.format("This is from Printer Number %d", printerNumber))
6 print(string.format("Printer online/offline status is %d", onlineOffline))
7 print(string.format("Printer selected status is %d", selected))
8 print(string.format("Printer paperOut status is %d", paperOut))
9 print(string.format("Printer generalError status is %d", generalError))
10 print(string.format("Printer statusOK condition is %d", statusOK))
11 end
12
13 -- Register our callback function, this is just a demo function that prints the Printer status
14 result = awtx.printer.registerPrinterStatusEvent(onPrinterStatus)

This registers a Lua callback function that will be called when there is a change of status of the external printer.
The application can look at the passed in status information and then decide what it needs to do. The status
changed are example, printer coming online, going offline, low paper, general error, etc.
When the callback function is called it is passed 6 parameters to indicate the status of the remote printer. Because
of Lua's flexibility with the function input parameters the programmer can choose to define a function that passes in
all of these parameters or omit as many of these parameters as desired.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
88 Class Documentation

Status Constants:
PRINTER_EOL = 0
PRINTER_OFFLINE = 1
PRINTER_ONLINE = 2
PRINTER_STATUS_OK = 3
PRINTER_STATUS_NOT_OK = 4
PRINTER_PAPERLOW = 5
PRINTER_NOT_PAPERLOW = 6
PRINTER_SELECTED = 7
PRINTER_NOT_SELECTED = 8
PRINTER_GENERAL_ERROR = 9
PRINTER_NOT_GENERAL_ERROR = 10

3.12.2.4 awtx.printer.reportFmt ( formatNum , formatType )


awtx.printer.reportFmt(formatNum, formatType)

Parameters
formatNum - (Number) The print format number to be used for the requested report field.
formatType - (Number) The field to apply the requested formatNum to.

1 -- First, we send a configured print format 5 header to the bound REPORT protocol port.
2 -- This doesn’t get printed immediately, but is queued for when the footer format type is printed.
3 awtx.printer.ReportFmt(5, 1)
4
5 -- Next, the configured body print format 6 is sent to the bound REPORT protocol port.
6 -- This function can be called multiple times while changing the information referenced by the
7 -- print format. Each time the function is called, the information from that iteration is
8 -- queued in the report print.
9 awtx.printer.ReportFmt(6, 2)
10
11 -- Finally, a configured footer print format 7 is sent to the bound REPORT protocol port.
12 -- This function call adds the footer format information to the constructed report, then triggers
13 -- a print of the completed report. This will start with the header, then all the iterated body
14 -- information, followed by the footer.
15 awtx.printer.ReportFmt(7, 3)

This function is used to print documents specifically formatted for report information.
Values for formatType are:
0 = normal print format (immediate)
1 = HEADER_FORMAT (deferred)
2 = RECORD_FORMAT (deferred)
3 = FOOTER_FORMAT (print deferred and footer)

3.12.2.5 awtx.printer.unregisterPrinterJobStatusEvent ( )
awtx.printer.unregisterPrinterJobStatusEvent()

1 -- Clear a previous PrinterJobStatusEvent registered callback


2
3 awtx.weight.unregisterPrinterJobStatusEvent()

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.13 scaleCtrl Class Reference 89

This function unregisters a previously set PrinterJobStatusEvent callback function.


After this unregister function is called, no further PrinterJobStatusEvent events will call the Lua handler function.

3.12.2.6 awtx.printer.unregisterPrinterStatus ( )
awtx.printer.unregisterPrinterStatus()

1 -- Clear a previous Printer Status Event registered callback


2
3 awtx.weight.unregisterPrinterStatusEvent()

This function unregisters a previously set PrinterJobStatusEvent callback function.


After this unregister function is called, no further PrinterJobStatusEvent events will call the Lua handler function.

3.13 scaleCtrl Class Reference

Public Member Functions

• getLocation (checkScale)
getX, getY = scaleCtrl:getLocation(checkScale)

• getVisible (checkScale)
visible = scaleCtrl:getVisible(checkScale)

• setActValVisible (checkScale, visible)


scaleCtrl:setActValVisible(checkScale, visible)

• setActiveValue (checkScale, activeValue)


scaleCtrl:setActiveValue(checkScale, activeValue)

• setLocation (checkScale, getX, getY)


scaleCtrl:setLocation(checkScale, getX, getY)

• setScaleNumVisible (checkScale, visible)


scaleCtrl:setScaleNumVisible(checkScale, visible)

• setUnitsVisible (checkScale, visible)


scaleCtrl:setUnitsVisible(checkScale, visible)

• setVisible (checkScale, visible)


scaleCtrl:setVisible(checkScale, visible)

3.13.1 Detailed Description

The scaleCtrl namespace handles the various items about the scale onto the display. It can control the location,
visibility, active value that's visible, scale number, and units of measure.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
90 Class Documentation

3.13.2 Member Function Documentation

3.13.2.1 scaleCtrl:getLocation ( checkScale )


getX, getY = scaleCtrl:getLocation(checkScale)

Parameters
checkScale - (String) The scale that is having its location being set.

Returns

getX - (Number) The X-coordinate of the scale.


getY - (Number) The Y-coordinate of the scale.

1 -- Gets the location of the scale


2 local scale = "scale002"
3 local getX, getY = scaleCtrl:getLocation(scale)
4
5 print(string.format("The location of %s is: %d, %d", scale, getX, getY)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function gets the location of the scale.

3.13.2.2 scaleCtrl:getVisible ( checkScale )


visible = scaleCtrl:getVisible(checkScale)

Parameters
checkScale - (String) The visibility of the scale in which we want to check.

Returns

visible - (Boolean) Determines whether the scale is visible.

1 -- Get the visibility of the scale


2 local scale = "scale003"
3 local visible = getVisible:getVisible(scale)
4
5 print(string.format("The visibility of %s is currently set to %c.", scale, visible)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

This function checks to see if the scale is visible.

3.13.2.3 scaleCtrl:setActiveValue ( checkScale , activeValue )


scaleCtrl:setActiveValue(checkScale, activeValue)

Parameters
checkScale - (String) The current scale that we are setting the active value for.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.13 scaleCtrl Class Reference 91

activeValue - (Number) The value we are assigning to the scale.

1 -- Sets the active value for a scale


2 local scale = "scale004"
3 local activeValue = 4
4
5 scaleCtrl:setActiveValue(scale, activeValue)

This function sets the active value of the current active scale.

3.13.2.4 scaleCtrl:setActValVisible ( checkScale , visible )


scaleCtrl:setActValVisible(checkScale, visible)

Parameters
checkScale - (String) The scale which we want to make the active value visible for.
visible - (Boolean) Determines whether of not the active value is visible.

1 -- Set the active value on the scale to be visible


2 local scale = "scale006"
3 local visible = true
4
5 scaleCtrl:setActValVisible(scale, visible)

This function sets the active value on the scale to be visible.

3.13.2.5 scaleCtrl:setLocation ( checkScale , getX , getY )


scaleCtrl:setLocation(checkScale, getX, getY)

Parameters
checkScale - (String) The scale that is getting its location set.
getX - (Number) The X-coordinate of the scale's location.
getY - (Number) The Y-coordinate of the scale's location.

1 -- Sets the location of the scale


2 local scale = "scale003"
3 local getX = 45
4 local getY = -75
5
6 scaleCtrl:setLocation(scale, getX, getY)

This function sets the location of the scale.

3.13.2.6 scaleCtrl:setScaleNumVisible ( checkScale , visible )


scaleCtrl:setScaleNumVisible(checkScale, visible)

Parameters

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
92 Class Documentation

checkScale - (String) The scale in which we want the numbers to be visible on.
visible - (Boolean) Determines whether or not the numbers are visible.

1 -- Set the scale number to be visible


2 local scale = "scale005"
3 local visible = true
4
5 scaleCtrl:setScaleNumVisible(scale, visible)

This function sets the numbers to be visible on the scale.

3.13.2.7 scaleCtrl:setUnitsVisible ( checkScale , visible )


scaleCtrl:setUnitsVisible(checkScale, visible)

Parameters
checkScale - (String) The scale that we are setting to have the units be visible.
visible - (Boolean) Determines whether the units are visible or not.

1 -- Set the units of measure to be visible


2 local scale = "scale005"
3 local visible = true
4
5 scaleCtrl:setUnitsVisible(scale, visible)

This function sets the units on a scale to be visible.

3.13.2.8 scaleCtrl:setVisible ( checkScale , visible )


scaleCtrl:setVisible(checkScale, visible)

Parameters
checkScale - (String) The scale that is being set to be visible.
visible - (Boolean) Determines whether the scale is visible or not.

1 -- Set the visibility of the scale


2 local scale = "scale003"
3 local visibility = true
4
5 scaleCtrl:setVisible(scale, visibility)

This function makes the current scale visible.

3.14 screensCtrl Class Reference

Public Member Functions

• addControl (screenName, control)


screensCtrl:addControl(screenName, control)

• show (screenName)
screensCtrl:show(screenName)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.15 serial Class Reference 93

3.14.1 Detailed Description

The screenCtrl namespace handles the screen itself. Currently, it handles new controls and the showing of informa-
tion.

3.14.2 Member Function Documentation

3.14.2.1 screensCtrl:addControl ( screenName , control )


screensCtrl:addControl(screenName, control)

Parameters
screenName - (String) Name of the screen that is having a control being added to it.
control - (String) The control that is going to be added to the screen.

1 -- Adds a control to the screen


2 local screenName = "Main"
3 local label1 = awtx.graphics.label.new("label1")
4 -- Adds the control to the screen
5 screensCtrl:addControl(screenName, label1)

This function adds a control to the screen.


A control is added to the screen if the screen type does not have a control already tied into it. If there is a control
already associated to the called screen type then an error message will pop up onto the screen.

3.14.2.2 screensCtrl:show ( screenName )


screensCtrl:show(screenName)

Parameters
screenName - (String) Name of the screen we want displayed.

1 -- Shows the current screen


2 local screenName = "Main"
3 screensCtrl:show(screenName)

This function displays the screen to the user.

3.15 serial Class Reference

Public Member Functions

• close (portNum)
result = awtx.serial.close(portNum)

• getConnectString (portNum)
result = awtx.serial.getConnectString(portNum)

• getEomChar (portNum)
result = awtx.serial.getEomChar(portNum)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
94 Class Documentation

• getMaxPorts ()
result = awtx.serial.getMaxPorts()

• getRx (portNum, maxBytes)


rxDataStr, readCount = awtx.serial.getRx(portNum, maxBytes)

• getRxCount (portNum)
count = awtx.serial.getRxCount(portNum)

• getSMATimeout (timeout)
returnVal = awtx.serial.getSMATimeout(timeout)

• open (portNum, baudrate, databits, parityStr, stopbits, handshakeStr)


result = awtx.serial.open(portNum, baudrate, databits, parityStr, stopbits, handshakeStr)

• registerEomEvent (portNum, eomHandler)


result = awtx.serial.registerEomEvent(portNum, eomHandler)

• registerSMAOnlineEvent (callbackFunction)
returnVal = awtx.serial.registerSMAOnlineEvent(callbackFunction)

• send (portNum, sendString)


result = awtx.serial.send(portNum, sendString)

• setEomChar (portNum, eomChar)


result = awtx.serial.setEomChar(portNum, eomChar)

• setSMATimeout (timeout)
returnVal = awtx.serial.setSMATimeout(timeout)

• unregisterEomEvent (portNum)
result = awtx.serial.unregisterEomEvent(portNum)

3.15.1 Detailed Description

The serial namespace handles the items that go through the serial port on the system. It handles the data being
read into from the serial port, sets the End of Message marker, sets up a timeout sequence for the SMA and other
functions listed down below.

3.15.2 Member Function Documentation

3.15.2.1 awtx.serial.close ( portNum )


result = awtx.serial.close(portNum)

Parameters
portNum - (Number) The selected serial port, either 1 or 2.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.15 serial Class Reference 95

Returns

result - (Number) Result of the serial port close function.

1 local COM1 = 1
2
3 local result = awtx.serial.close(COM1)
4 print(string.format("Close port %d Result = %d", COM1, result)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)

This function closes a Serial port.


Result can equal 3 different numbers:
0 Success Opening port
-1 Error closing port
-2 Port number out of valid range

3.15.2.2 awtx.serial.getConnectString ( portNum )


result = awtx.serial.getConnectString(portNum)

Parameters
portNum - (Number) The selected serial port, either 1 or 2.

Returns

result - (String) A string detailing the connection parameters for the Serial port.

1 local COM1 = 1
2
3 local result = awtx.serial.getConnectString(COM1)
4 print(string.format("Port %d: Connect String is %s", COM1, result)) -- Prints to the Lua Console (located
at Ztools -> Zedit -> Output)
5
6 --output Text
7 --Port 1: Connect String is Baud = 115200, Databits = 8, Parity = None, Stopbits = 1, Handshake = None

This function returns a string describing the current connection parameters for an open Serial port.

3.15.2.3 awtx.serial.getEomChar ( portNum )


result = awtx.serial.getEomChar(portNum)

Parameters
portNum - (Number) The selected serial port, either 1 or 2.

Returns

result - (Number) The numeric value of the EOM character.

1 local COM1 = 1
2 result = awtx.serial.getEomChar(COM1);
3 print(string.format("COM1 getEomChar(COM1) returned 0x%02X", result)) -- Prints to the Lua Console (located
at Ztools -> Zedit -> Output)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
96 Class Documentation

This function returns the numeric value of the EOM character as set by a previous call to the awtx.serial.setEom←-
Char() function.
The result will be one of the following 4 numbers:
0 = Success
-1 = Function called with wrong number of parameters
-2 = Parameter 1 should be a Lua number
-3 = Port number out of valid range
If no previous call to awtx.serial.setEomChar(portNum) has been made then awtx.serial.getEomChar(portNum) will
return 0.

3.15.2.4 awtx.serial.getMaxPorts ( )
result = awtx.serial.getMaxPorts()

Returns

result - (Number) Returns the max amount of ports.

1 -- Grabs the maximum amount of ports.


2
3 local maxPorts = awtx.serial.getMaxPorts()
4 print(string.format("Maximum amount of ports is %i", maxPorts)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)

This function gets the maximum amount of ports allowed.

3.15.2.5 awtx.serial.getRx ( portNum , maxBytes )


rxDataStr, readCount = awtx.serial.getRx(portNum, maxBytes)

Parameters
portNum - (Number) The selected serial port, either 1 or 2.
maxBytes - (Number) (Optional) The maximum number of bytes to be returned [optional parameter]

Returns

rxDataStr - (String) A Lua string read from the current serial input buffer.
readCount - (Number) The number of bytes read from the serial buffer [optional]

1 -- All of these are valid Lua examples:


2
3 local COM1 = 1
4
5 -- Get the entire input buffer into rxDataStr
6 rxDataStr = awtx.serial.getRx(COM1)
7
8 -- Get a maximum of 20 bytes from the input buffer
9 rxDataStr = awtx.serial.getRx(COM1, 20)
10
11 -- Get the entire input buffer, and the number of bytes returned
12 rxDataStr, readCount = awtx.serial.getRx(COM1)
13
14 -- Get a maximum of 10 bytes, and the number of bytes returned
15 rxDataStr, readCount = awtx.serial.getRx(COM1, 10)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.15 serial Class Reference 97

This function reads data from a previously opened serial port.


For maxBytes:
If more than maxBytes are present in the input buffer the remaining bytes will be returned when this function is next
called.
This function returns 2 parameters, if the programmer is not interested in the readCount parameter it can just be
ignored.
Note:
If an 'end of message' character has been set and is contained in the input buffer then this function will return data
up to and including that 'EOM' char. Data after the 'EOM' character is left to buffer for subsequent reading on the
next call to this function.

3.15.2.6 awtx.serial.getRxCount ( portNum )


count = awtx.serial.getRxCount(portNum)

Parameters
portNum - (Number) The serial port called to be counted. Accepted serial port values are 1 or 2.

Returns

count - (Number) The byte count received data currently in the input buffer for the selected serial channel.

1 local COM1 = 1
2 count = awtx.serial.getRxCount(COM1)

This function returns the current byte count of received data in the input buffer for selected serial port.

3.15.2.7 awtx.serial.getSMATimeout ( timeout )


returnVal = awtx.serial.getSMATimeout(timeout)

Parameters
timeout - (Number) The amount of time to be set for the timeout sequence.

Returns

returnVal - (Number) The status of whether the function ran correctly

1 local timeout = 500 -- 500 milliseconds


2
3 local returnVal = awtx.serial.getSMATimeout(timeout)
4 print(string.format("%i is the status of the SMA Timeout.", returnVal)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function gets a Timeout sequence for the SMA.


These are the possible outputs for returnVal:
0 = Completed Correctly
-1 = Missing a Parameter
-2 = Parameter Isn't Numeric

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
98 Class Documentation

3.15.2.8 awtx.serial.open ( portNum , baudrate , databits , parityStr ,


stopbits , handshakeStr )
result = awtx.serial.open(portNum, baudrate, databits, parityStr, stopbits, handshakeStr)

Parameters
portNum - (Number) The selected serial port, either 1 or 2
baudrate - (Number) 110, 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200.
databits - (Number) Either 7 or 8
parityStr - (String) Valid Strings 'EVEN', 'ODD', 'NONE', 'MARK', SPACE', or 'E', 'O', 'N', 'M', 'S'.
stopbits - (Number) Either 1 or 2
handshakeStr - (String) Valid Strings are 'NONE', 'SOFT', 'HARD', or 'N', 'S'. 'H'.

Returns

result - (Number) Result of the serial port open function.

1 -- This function returns a descriptive string corresponding to the passed in result number\
2 function getOpenResultMsg (result)
3 local fetStr = "Open Port, Result number not known";
4 local openPortMsgs = {
5 { 0, "Success"};,
6 {-1, "Port Open command failed"};,
7 {-2, "Port number out of valid range"};,
8 {-3, "Baudrate is not one of known values."};,
9 {-4, "Databits parameter invalid."};,
10 {-5, "Stopbits parameter invalid"};,
11 {-6, "Parity parameter invalid"};,
12 {-7, "Handshake parameter invalid"};,
13 };
14 for i = 1, #openPortMsgs do
15 if (openPortMsgs[i][1] == result) then
16 retStr = openPortMsgs[i][2];
17 break
18 end
19 end
20
21 return retStr
22 end
23
24 -- Open a Serial port on COM1 with Baudrate = 115, 200, 8 bits, no parity, 1 stop bit, no handshaking
25 local COM1 = 1
26
27 local result = awtx.serial.open(COM1, 115200, 8, "none", 1, "none")
28 print(dtring.format("open port %d Result = %d {%s};", COM1, result, getOpenResultMsg(result))) -- Prints to
the Lua Console (located at Ztools -> Zedit -> Output)

This function opens a Serial port with the required input parameters.
Possible results for result:
0 Success Opening Port
-1 Port Open command failed
-2 Port number out of valid range
-3 Baudrate is not one of known value
-4 Databits parameter invalid
-5 Stopbits parameter invalid
-6 Parity parameter involved
-7 Handshake parameter invalid
-10 Either the handshake or the parity string were passed as nil.
This example also shows a function to translate the return status value into a text string

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.15 serial Class Reference 99

3.15.2.9 awtx.serial.registerEomEvent ( portNum , eomHandler )


result = awtx.serial.registerEomEvent(portNum, eomHandler)

Parameters
portNum - (Number) The selected serial port number.
eomHandler - (Function) The callback function.

Returns

result - (Number) 0 if successful, otherwise a non-zero value.

1 local portNum = 1 -- Port 1


2 local CR = 13 -- Carriage Return
3
4 -- This handler will be called when the end of message (EOM) character is received
5 function eomHandler(thisPortNum)
6
7 local data, count = awtx.serial.getRx(portNum)
8
9 -- print the port number, the rxData, and the byte count up to the EOM character.
10 -- Print statements output to the Lua Console (located at Ztools -> Zedit -> Output)
11 print(string.format("Received %d bytes on serial port %d.", count, portNum))
12 print("Data: " .. data)
13 end
14
15 -- Set the carriage return to generate the EOM event
16 awtx.serial.setEomChar(portNum, CR)
17
18 -- Register the event handler and check the result
19 result = awtx.serial.registerEomEvent(portNum, eomHandler)
20 if (result == 0) then
21 print(’Successfully registered EOM event handler on port ’ .. portNum)
22 else
23 print(’Failed to register EOM event handler on port ’ .. portNum .. ’ with error ’ .. result)
24 end

This function registers a Lua callback function that will be called when the 'End of Message character is received on
the specified serial port.
When the user specified Lua function is called it will be passed one parameter which is the port number on which
the EOM character has been received.
This makes it flexible, for example, if the Indicator model has two serial channels, the code can be written to have
each channel calling a different Lua callback function or if preferred a single callback function can be used and the
portNum parameter can be tested to determine which port has just received the EOM character.

3.15.2.10 awtx.serial.registerSMAOnlineEvent ( callbackFunction )


returnVal = awtx.serial.registerSMAOnlineEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale calls when the SMA request has completed.

Returns

returnVal - (Number) Status of the function to determine that it worked as it should have. 0 is okay, a negative
number is an error.

1 function registerSMAOnline(returnVal)
2 print(string.format("Registering SMA Online Event.")) -- Prints to the Lua Console (located at Ztools ->
Zedit -> Output)
3 end
4 returnVal = awtx.registerSMAOnlineEvent(registerSMAOnline)

This function registers SMA Online events.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
100 Class Documentation

3.15.2.11 awtx.serial.send ( portNum , sendString )


result = awtx.serial.send(portNum, sendString)

Parameters
portNum - (Number) The selected serial port, either 1 or 2.
sendString - (String) Any valid UTF-8 string to be sent to the specified port.

Returns

result - (Number) Result of the serial port close function.

1 -- This assumes the COM1 serial port has already been opened
2 local COM1 = 1
3
4 local result = awtx.serial.send(COM1, "Hello All")

This function sends a string to the previously opened serial port.


Result will return one of these 3 numbers:
0 The string was sent successfully
-1 Error, The string was not successfully sent
-2 Port number out of valid range

3.15.2.12 awtx.serial.setEomChar ( portNum , eomChar )


result = awtx.serial.setEomChar(portNum, eomChar)

Parameters
portNum - (Number) The selected serial port, either 1 or 2.
eomChar - (Number) The character as a single numeric byte to be used as the End of Message marker.
Valid range is 0x01 to 0xFE.

Returns

result - (Number) Result of the setEomChar function.

1 local COM1 = 1
2 local ETX = 0x03
3
4 result = awtx.serial.open(COM1, 115200, 8, "NONE", 1, "NONE")
5 result = awtx.serial.setEomChar(COM1, ETX) -- set ASCII ETX as the End of Message character
6 result = awtx.serial.registerEomEvent(COM1, eomHandler)

This function sets the character to be used as the 'End of Message' marker when receiving data.
Result will return with one of these:
0 = Success
-1 = Function called with wrong number of parameters
-2 = Parameter 1 should be a Lua number
-3 = Port number out of valid range
-4 = EOM character should be a Lua Number between 0x01 and 0xFE
Note: For this to work, the setEomChar() function should be called after the awtx.serial.open() function is called.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.15 serial Class Reference 101

3.15.2.13 awtx.serial.setSMATimeout ( timeout )

returnVal = awtx.serial.setSMATimeout(timeout)

Parameters
timeout - (Number) The amount of time to be set for the timeout sequence.

Returns

returnVal - (Number) The status of whether the function ran correctly.

1 local timeout = 500 -- 500 milliseconds


2
3 local returnVal = awtx.serial.setSMATimeout(timeout)
4 print(string.format("%i is the status of the SMA Timeout.", returnVal)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function sets a Timeout sequence for the SMA.


Possible returnVal results:
0 = Completed Correctly
-1 = Missing a Parameter
-2 = Parameter Isn't Numeric

3.15.2.14 awtx.serial.unregisterEomEvent ( portNum )

result = awtx.serial.unregisterEomEvent(portNum)

Parameters
portNum - (Number) The selected serial port, either 1 or 2.

Returns

result - (Number) The numeric result of the unregisterEomEvent() function.

1 local COM1 = 1
2
3 -- this will stop a previously registered callback function from being called
4 result = awtx.serial.unregisteredEomEvent(portNum)
5 print(string.format("awtx.serial.unregisterEomEvent() Port COM%d returned Result = %d", portNum, result))
-- Prints to the Lua Console (located at Ztools -> Zedit -> Output)

This function unregisters a Lua callback function that has been previously set with the awtx.serial.registerEom←-
Event() function.
The result will return one of the four following numbers:
0 = Success
-1 = Function called with wrong number of parameters
-2 = Parameter 1 should be a Lua number
-3 = Port number out of valid range

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
102 Class Documentation

3.16 setpoint Class Reference

Public Member Functions

• activate (setpointNum)
returnVal = awtx.setpoint.activate(setpointNum)

• configure (setpoint, configTable)


returnVal = awtx.setpoint.configure(setpoint, configTable)

• deactivate (setpointNum)
returnVal = awtx.setpoint.deactivate(setpointNum)

• getInverted ()
result = awtx.setpoint.getInverted()

• getState (setpointNum)
returnVal = awtx.setpoint.getState(setpointNum)

• lockOff (setpointNum)
returnVal = awtx.setpoint.lockOff(setpointNum)

• lockOn (setpointNum)
returnVal = awtx.setpoint.lockOn(setpointNum)

• registerInputEvent (setpointNumber, callbackFunction)


result = awtx.setpoint.registerInputEvent(setpointNumber, callbackFunction)

• registerOutputEvent (setpointNum, callbackFunction)


result = awtx.setpoint.registerOutputEvent(setpointNum, callbackFunction)

• setInverted (invertNum)
awtx.setpoint.setInverted(invertNum)

• unlock (setpoint)
returnValue = awtx.setpoint.unlock(setpoint)

• unregisterInputEvent (setpointNum)
result = awtx.setpoint.unregisterInputEvent(setpointNum)

• unregisterOutputEvent (setpointNum)
result = awtx.setpoint.unregisterOutputEvent(setpointNum)

• varGet (varName)
result = awtx.setpoint.varGet(varName)

• varSet (varName, luaNumber)


result = awtx.setpoint.varSet(varName, luaNumber)

3.16.1 Detailed Description

The setpoint namespace handles the function that deal with setting the setpoint number on the system. They include
activating the setpoint number, locking or unlocking the setpoint number, registering and unregistering setpoint
numbers, and other functions detailed below.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.16 setpoint Class Reference 103

3.16.2 Member Function Documentation

3.16.2.1 awtx.setpoint.activate ( setpointNum )


returnVal = awtx.setpoint.activate(setpointNum)

Parameters
setpointNum - (Number) The number of the desired setpoint.

Returns

returnVal - (Number) Returns 0 if setpoint was activated successfully, returns -1 if setpoint number was out of
range.

1 local setpointNum = 10
2
3 local returnVal = awtx.setpoint.activate(setpointNum)
4
5 -- Print statements output to the Lua Console (located at Ztools -> Zedit -> Output)
6 if returnVal == 0 then
7 print(string.format("Setpoint number %d activated.", setpointNum))
8 else
9 print(string.format("Setpoint number %d out of range.", setpointNum))
10 end

Activates the specified setpoint number.

3.16.2.2 awtx.setpoint.configure ( setpoint , configTable )


returnVal = awtx.setpoint.configure(setpoint, configTable)

Parameters
setpoint - (Number) The number of the desired setpoint.
configTable - (Table) Lua table that holds all the possible parameters.

Returns

returnVal - (Number) Number that checks to see if the function ran correctly.

1 SP_1_Act = 100
2 SP_1_Deact = 100
3
4 function awtxReq.keypad.KEY_START_UP()
5 -- Configure a setpoint to activate when the gross weight in calibration units is below the value
6 -- of SP_1_Act variable but outside of the GZB and deactivate when the weight is above the value
7 -- of SP_1_Deact variable.
8 local configLuaAboveBelow = {mode="output", act="below", deact="above",
9 actbasis="grosswt", deactbasis="grosswt",
10 actlowerluavar="SP_1_Act", deactlowerluavar="SP_1_Deact",
11 offinsidegzb=1};
12
13 -- Store settings to Setpoint 1
14 awtx.setpoint.configure(1, configLuaAboveBelow)
15 end

1 function awtxReq.keypad.KEY_START_UP()
2 -- Configure a setpoint to activate when the gross weight is between 100 and 200 of the calibration
3 -- unit, then deactivate when the weight is outside of the range 50-250.
4 local configInsideOutside = {mode="output", act="inside", deact="outside",
5 actbasis="grosswt", deactbasis="grosswt",
6 actlower=100, actupper=200, deactlower=50, deactupper=250};
7
8 -- Store settings to Setpoint 1
9 awtx.setpoint.configure(1, configInsideOutside)
10 end

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
104 Class Documentation

This function configures setpoints for variables using a table.

1. mode
Setting Type - string
Setting Options - "disabled", "output", "input"

2. act
Setting Type - string
Setting Options - "above", "below", "inside", "outside", "motion", "nomotion", "centerzero", "notcenterzero",
"immediate", "user", "accumoperation", "printoperation", "zerooperation", "tareoperation", "tarekey", "selec-
tkey", "printkey", "unitskey", "zerokey", "equalto", "and", "or", "xor"

3. deact
Setting Type - string
Setting Options - "above", "below", "inside", "outside", "motion", "nomotion", "centerzero", "noncenterzero",
"immediate", "user", "accumoperation", "printoperation", "zerooperation", "tareoperation", "tarekey", "selec-
tkey", "printkey", "unitskey", "zerokey", "equalto", "and", "or", "xor"

4. bouncetime
Setting Type - double
Description - Defaulted to 0 to disable, time (in milliseconds) to wait before allowing the setpoint to change
states again.

5. actbasis
Setting Type - stirng
Setting Options - "grosswt", "netwt", "tarewt", "inmowt", "minwt", "maxwt", "grosswttotal", "netweighttotal",
"count", "target", "luavariable"

6. deactbasis
Setting Type - string
Setting Options - "grosswt", "netwt", "tarewt", "inmowt", "minwt", "maxwt", "grosswttotal", "netweighttotal",
"count", "target", "luavariable"

7. actscale
Setting Type - double
Description - Number of the scale to use for activation weight and status readings.

8. deactscale
Setting Type - double
Description - Number of the scale to use for deactivation weight and status readings.

9. actmotioninhibit
Setting Type - double
Description - Default 0, set to 1 if setpoint should not be allowed to activate during motion.

10. deactmotioninhibit
Setting Type - double
Description - Default 0, set to 1 if setpoint should not be allowed to deactivate during motion.

11. actlower
Setting Type - double
Description - Lower activate value to be used with inside, outside, above, and below setpoints.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.16 setpoint Class Reference 105

12. actupper
Setting Type - double
Description - Values of the configured basis above this number will activate inside and outside type setpoints.

13. deactlower
Setting Type - double
Description - Lower deactivate value to be used with inside, outside, above, and below setpoints.

14. deactupper
Setting Type - double
Description - Values of the configured basis above this number will deactivate inside and outside type set-
points.

15. actlowervarname
Setting Type - string
Description - The name of the variable set by setpoint.varSet() to be used as the current value when evaluating
the setpoint actlower condition.

16. actuppervarname
Setting Type - string
Description - The name of the variable set by setpoint.varSet() to be used as the current value when evaluating
the setpoint actupper condition.

17. deactlowervarname
Setting Type - string
Description - The name of the variable set by setpoint.varSet() to be used as the current value when evaluating
the setpoint deactlower condition.

18. deactuppervarname
Setting Type - string
Description - The name of the variable set by setpoint.varSet() to be used as the current value when evaluating
the setpoint deactupper condition.

19. actbasisvarname
Setting Type - string
Description - If basis is set to "luavariable", the name of the variable set by setpoint.varSet() to be used as the
target value when evaluating the setpoint activate condiditon.

20. deactbasisvarname
Setting Type - string
Description - If basis is set to "luavariable", the name of the variable set by setpoint.varSet() to be used as the
target value when evaluating the setpoint deactivate condition.

21. actlowerluavar
Setting Type - string
Description - The name of the lua variable to be used as the current value when evaluating the setpoint
actlower condition.

22. actupperluavar
Setting Type - string
Description - The name of the lua variable to be used as the current value when evaluating the setpoint
actlower condition.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
106 Class Documentation

23. deactlowerluavar
Setting Type - string
Description - The name of the lua variable to be used as the current value when evaluating the setpoint
actlower condition.

24. deactuppervar
Setting Type - string
Description - The name of the lua variable to be used as the current value when evaluating the setpoint
actlower condition.

25. actbasisluavar
Setting Type - string
Description - If the basis is set to "luavariable", the name of the lua variable to be used as the target value
when evaluating the setpoint activate condition.

26. deactbasisluavar
Setting Type - string
Description - If basis is set to "luavariable", the name of the lua variable to be used as the target value when
evaluating the setpoint deactivate condition.

27. offinsidegzb
Setting Type - double
Description - Default 0, set to 1 if the setpoint should be deactivated when the activation basis scale's gross
weight is inside GZB.

28. bus
Setting Type - double
Description - Set the bus number to the setpoint it is bount to. 0 = Onboard, 1 = Option bus #1, 2 = Option
bus #2 (if available), 3 = virtual

29. slot
Setting Type - double
Description - Set the card number to the setpoint it is bound to. Only used when bus is set to an option bus.

30. pin
Setting Type - double
Description - Set the pin number to the setpoint it is bound to.

Possible outputs for returnVal:


0 = Completed Correctly
-1 = Function Must Have 2 Parameters
-2 = Parameter 1 Must be Numeric
-3 = Setpoint Number Must be Between 1 and NUM_SETPOINTS
-4 = Parameter 2 Must Be a Lua Table
-5 = Setpoint Key Wasn't a String
-6 = Setpoint Value Wasn't a String or Value
-7 = Author Error; Invalid Mode

3.16.2.3 awtx.setpoint.deactivate ( setpointNum )


returnVal = awtx.setpoint.deactivate(setpointNum)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.16 setpoint Class Reference 107

Parameters
setpointNum - (Number) The number of the desired setpoint.

Returns

returnVal - (Number) Returns 0 if setpoint was deactivated successfully, returns -1 if setpoint number was out
of range.

1 local setpointNum = 10
2
3 local returnVal = awtx.setpoint.deactivate(setpointNum)
4
5 -- Print statements output to the Lua Console (located at Ztools -> Zedit -> Output)
6 if returnVal == 0 then
7 print(string.format("Setpoint number %d deactivated.", setpointNum))
8 else
9 print(string.format("Setpoint number %d out of range.", setpointNum))
10 end

Deactivates the specified setpoint number.

3.16.2.4 awtx.setpoint.getInverted ( )
result = awtx.setpoint.getInverted()

Returns

result - (Number) The output that will be set to be inverted.

1 local result = awtx.setpoint.getInverted()


2 print(string.format("The status of the get inverted function is: %i", result)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function takes the output for the setpoint and returns the number set to be inverted.

3.16.2.5 awtx.setpoint.getState ( setpointNum )


returnVal = awtx.setpoint.getState(setpointNum)

Parameters
setpointNum - (Number) The number of the desired setpoint.

Returns

returnVal - (Number) The desired target value for the system to hit. If 0 then okay, else if non zero it is an error.

1 local setpointNum = 10
2
3 local returnVal = awtx.setpoint.getState(setpointNum)
4
5 -- Print statements output to the Lua Console (located at Ztools -> Zedit -> Output)
6 if returnVal == 1 then
7 print(string.format("Setpoint number %d is active.", setpointNum))
8 else
9 print(string.format("Setpoint number %d is not active.", setpointNum))
10 end

Gets the current state of the specified setpoint.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
108 Class Documentation

3.16.2.6 awtx.setpoint.lockOff ( setpointNum )


returnVal = awtx.setpoint.lockOff(setpointNum)

Parameters
setpointNum - (Number) The number of the desired setpoint.

Returns

returnVal - (Number) Returns 0 if the operation performed correctly.

1 local setpointNum = 10
2
3 local returnVal = awtx.setpoint.lockOff(setpointNum)
4 print(string.format("Setpoint number %d turned off and locked.", setpointNum)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

Turns off and locks the specified setpoint number in the off position.

3.16.2.7 awtx.setpoint.lockOn ( setpointNum )


returnVal = awtx.setpoint.lockOn(setpointNum)

Parameters
setpointNum - (Number) The number of the desired setpoint.

Returns

returnVal - (Number) Returns 0 if the operation performed correctly.

1 local setpointNum = 10
2
3 local returnValue = awtx.setpoint.lockOn(setpointNum)
4 print(string.format("Setpoint number %d turned on and latched.", setpointNum)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

Turns on and latches the specified setpoint number in the on position.

3.16.2.8 awtx.setpoint.registerInputEvent ( setpointNumber ,


callbackFunction )
result = awtx.setpoint.registerInputEvent(setpointNumber, callbackFunction)

Parameters
setpointNumber - (Number) The number of the desired setpoint.
callbackFunction - (Function) The Lua callback function the scale calls when the register input request has
completed.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.16 setpoint Class Reference 109

Returns

result - (Number) Status of the function to determine that it worked as it should have.

1 local inputNum = 2
2
3 -- Print statements output to the Lua Console (located at Ztools -> Zedit -> Output)
4 function onInputChange(input, newState)
5 if newState == true then
6 print(string.format("Input number %d activated.", input))
7 else
8 print(string.format("Input number %d deactivated.", input))
9 end
10 end
11
12 local result = awtx.setpoint.registerInputEvent(inputNum, onInputChange)

This function registers an input event for a setpoint number.


Possible returns for result:
0 = Success
-1 = Function Must Take 2 Parameters
-2 = First Parameter Must Be a Number
-3 = First Parameter Is Not In Range
-4 = Second Parameter Should Be a Lua Function

3.16.2.9 awtx.setpoint.registerOutputEvent ( setpointNum ,


callbackFunction )
result = awtx.setpoint.registerOutputEvent(setpointNum, callbackFunction)

Parameters
setpointNum - (Number) The number of the desired setpoint.
callbackFunction - (Function) The Lua callback function that is called by the scale when the desired setpoint
changes.

Returns

result - (Number) Status of the function to determine that it worked as it should have.

1 local setpointNum = 5
2
3 -- Print statements are outputted to the Lua Console (located at Ztools -> Zedit -> Output)
4 function onOutputChange(setpoint, newState)
5 if newState == true then
6 print(string.format("Setpoint number %d activated.", setpoint))
7 else
8 print(string.format("Setpoint number %d deactivated.", setpoint))
9 end
10 end
11
12 local result = awtx.setpoint.registerOutputEvent(setpointNum, onOutputChange)

Registers a specific awtx setpoint, this allows a Lua event handler to be called.
Possible return values for result:
0 = Success
-1 = Function Needs 2 Parameters
-2 = First Parameter Must be a Number
-3 = First Parameter is Out of Range
-4 = Second Parameter Needs to be a Lua Function.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
110 Class Documentation

3.16.2.10 awtx.setpoint.setInverted ( invertNum )


awtx.setpoint.setInverted(invertNum)

Parameters
invertNum - (Number) Value that was returned from the getInverted function that will be inverted.

1 local invertNum = 5
2 local result = awtx.setpoint.setInverted(invertNum)
3 print(string.format("The inverted number is: %i", result)) -- Prints to the Lua Console (located at Ztools
-> Zedit -> Output)

This function takes the value that is going to be inverted and inverts the number.

3.16.2.11 awtx.setpoint.unlock ( setpoint )


returnValue = awtx.setpoint.unlock(setpoint)

Parameters
setpoint - (Number) The number of the desired setpoint.

Returns

returnValue - (Number) Checks to see if the function has been working correctly. If it is 0 then it is okay, if it is
a non zero then it is an error.

1 local setpoint = 10
2
3 local returnValue = awtx.setpoint.unlock(setpoint)
4 print(string.format("The status of the unlatched function is: %i", returnValue)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

This function unlatches the output for the setpoint number.

3.16.2.12 awtx.setpoint.unregisterInputEvent ( setpointNum )


result = awtx.setpoint.unregisterInputEvent(setpointNum)

Parameters
setpointNum - (Number) The number of the desired setpoint callback function.

Returns

result - (Number) Status of the function to determine that it worked as it should have.

1 local setpointNum = 5
2 local result = awtx.setpoint.unregisterInputEvent(setpointNum)

Unregisters the specified awtx setpoint number's callback function.


Possible return values for result:
0 = Success
-1 = Function Must Take 1 Parameter
-2 = First Parameter Must Be a Number
-3 = First Parameter Is Not In Range

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.16 setpoint Class Reference 111

3.16.2.13 awtx.setpoint.unregisterOutputEvent ( setpointNum )


result = awtx.setpoint.unregisterOutputEvent(setpointNum)

Parameters
setpointNum - (Number) The number of the desired setpoint callback function.

Returns

result - (Number) Status of the function to determine that it worked as it should have.

1 local setpointNum = 5
2 local result = awtx.setpoint.unregisterOutputEvent(setpointNum)

Unregisters the specified awtx setpoint number's callback function.


Possible return values for result:
0 = Success
-1 = Function must take 1 Parameter
-2 = First Parameter Must be a Number
-3 = First Parameter is Out of Range

3.16.2.14 awtx.setpoint.varGet ( varName )


result = awtx.setpoint.varGet(varName)

Parameters
varName - (String) The name of the variable that is going to be looked up.

Returns

result - (Number) Checks to see if the function worked correctly. If it returned 0, then it is okay, else if it
returned a non-zero, then there is an error.

1 local varName = "variableName"


2
3 local result = awtx.setpoint.varGet(varName)
4 print(string.format("The status of the variable get function is: %i", result)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function gets the variable names so that they can be set to a value.
If result returns back with a nil value then it could not find the variable.

3.16.2.15 awtx.setpoint.varSet ( varName , luaNumber )


result = awtx.setpoint.varSet(varName, luaNumber)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
112 Class Documentation

Parameters
varName - (String) The name of the variable.
luaNumber - (Number) Number to be assigned to the variable name.

Returns

result - (Number) Checks to see if the function worked correctly. If it is 0 then it is okay, any non-zero is an
error code.

1 -- Sets up the variable to be called.


2 local varName = "variableName"
3 local luaNumber = 7
4
5 local result = awtx.setpoint.varSet(varName, luaNumber)
6 print(string.format("The status of the variable set function is: %i", result)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function sets up a variable.

3.17 socket Class Reference

Public Member Functions

• connected (socketNumber)
connectedStatus = awtx.socket.connected(socketNumber)

• getEomChar (socketNumber)
eomChar = awtx.socket.getEomChar(socketNumber)

• getMaxSockets ()
maxSockets = awtx.socket.getMaxSockets()

• getRx (socketNumber, maxChar)


buffer, byteRead = awtx.socket.getRx(socketNumber, maxChar)

• getRxCount (socketNumber)
result = awtx.socket.getRxCount(socketNumber)

• registerEomEvent (socketNumber, callbackFunction)


registryIndex = awtx.socket.registerEomEvent(socketNumber, callbackFunction)

• send (socketNumber, txString)


result = awtx.socket.send(socketNumber, txString)

• setEomChar (socketNumber, eomChar)


result = awtx.socket.setEomChar(socketNumber, eomChar)

• unregisterEomEvent (socketNumber)
registryIndex = awtx.socket.unregisterEomEvent(socketNumber)

3.17.1 Detailed Description

The socket namespace allows the user to perform communications across ethernet socket connections. Once the
socket configuration is set up in the administrator menu Setup->Ports->E-Net->Conn.No, this interface can be
used to perform individual or event-driven communications over the socket connection.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.17 socket Class Reference 113

3.17.2 Member Function Documentation

3.17.2.1 awtx.socket.connected ( socketNumber )


connectedStatus = awtx.socket.connected(socketNumber)

Parameters
socketNumber - (Number) The socket that is being connected.

Returns

connectedStatus - (Number) The number that is returned to show that the device was connected to the socket
properly.

1 -- Checks the connection status of the socket


2 local socketNumber = 3
3 local connectedStatus = awtx.socket.connected(socketNumber)

This function checks to see if a socket has been connected by a device.

3.17.2.2 awtx.socket.getEomChar ( socketNumber )


eomChar = awtx.socket.getEomChar(socketNumber)

Parameters
socketNumber - (Number) The socket that is currently being used by the scale.

Returns

eomChar - (Number) The number value of the eom character that is going to be set.

1 local socketNumber = 4
2
3 eomChar = awtx.socket.getEomChar(socketNumber)
4 print(string.format("The eomChar that will be set is %d", eomChar)) -- Prints to the Lua Console (located
at Ztools -> Zedit -> Output)

This functions gets the eom character to be set for the scale.

3.17.2.3 awtx.socket.getMaxSockets ( )
maxSockets = awtx.socket.getMaxSockets()

Returns

maxSockets - (Number) The maximum amount of sockets available on a scale.

1 --Grab the max amount of sockets


2
3 maxSockets = awtx.socket.getMaxSocket()
4 print(string.format("%d is the maximum amount of sockets available.", maxSockets)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

This function grabs the maximum amount of sockets on a scale.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
114 Class Documentation

3.17.2.4 awtx.socket.getRx ( socketNumber , maxChar )


buffer, byteRead = awtx.socket.getRx(socketNumber, maxChar)

Parameters
socketNumber - (Number) The number of the socket that is currently in use. Only values 1 and 2 are ac-
cepted.
maxChar - (Number) (Optional) The maximum amount of characters allowed.

Returns

buffer - (String) The value of the buffer converted to a string format.


byteRead - (Number) The amount of bytes that were read.

1 local socketNumber = 1
2 maxChar = 200
3
4 local buffer, byteRead = awtx.socket.getRx(socketNumber, maxChar)

This function reads data from a previously opened socket.

3.17.2.5 awtx.socket.getRxCount ( socketNumber )


result = awtx.socket.getRxCount(socketNumber)

Parameters
socketNumber - (Number) The socket that is currently being used.

Returns

result - (Number) Returns the status of the function. 0 is success, non zero are errors.

1 local socketNumber = 2
2
3 local result = awtx.socket.getRxCount(socketNumber)
4 print(result) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)

This function grabs the current byte count of received data for the selected socket.

3.17.2.6 awtx.socket.registerEomEvent ( socketNumber ,


callbackFunction )
registryIndex = awtx.socket.registerEomEvent(socketNumber, callbackFunction)

Parameters
socketNumber - (Number) The number of the socket that is currently being used.
callbackFunction - (Function) The Lua callback function the scale should call when the eom register event is
called.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.17 socket Class Reference 115

Returns

registryIndex - (Number) The status of the function. If it returns 0 then the function worked correctly, returns
negative if incorrect.

1 local counter = 0
2
3 -- Registers the eom event
4 -- Print statements output to the Lua Console (located at Ztools -> Zedit -> Output)
5 function registerEom(returnVal)
6 counter = counter + 1
7 print(string.format("Lua Callback Function: registryIndex = %d counter = %d", registryIndex, counter))
8 end
9
10 --Main
11 registryIndex = awtx.socket.registerEomEvent(registerEom)
12 print(string.format("Lua: Registered an EOM event at registryIndex %d", registryIndex)

This function registers an Eom event for a scale.


Possible outputs for registryIndex:
0 = SUCCESS
-1 = ERROR: Function must have 2 parameters
-2 = ERROR: Parameter 1 should be numeric
-3 = ERROR: Index value not valid
-4 = ERROR: Parameter 2 must be a function

3.17.2.7 awtx.socket.send ( socketNumber , txString )


result = awtx.socket.send(socketNumber, txString)

Parameters
socketNumber - (Number) The socket that is currently being used.
txString - (String) The string that is going to be sent out.

Returns

result - (Number) Checks the status of the function. 0 is success, non zeros are errors.

1 local socketNumber = 1
2 local txString = "Pills"
3
4 result = awtx.socket.send(socketNumber, txString)
5 print(string.format("The output code for the send function is %d", result) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function sends out a tx string

3.17.2.8 awtx.socket.setEomChar ( socketNumber , eomChar )


result = awtx.socket.setEomChar(socketNumber, eomChar)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
116 Class Documentation

Parameters
socketNumber - (Number) The socket that is currently being used.
eomChar - (Number) The eom character that is being set for the scale.

Returns

result - (Number) The status of the function. 0 means success, non zero means error.

1 local socketNumber = 1
2 local eomChar = 6
3
4 local result = awtx.socket.setEomChar(socketNumber, eomChar)
5 print(string.format("The status of the setEomChar is %d", result)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)

This functions sets the eom character.

3.17.2.9 awtx.socket.unregisterEomEvent ( socketNumber )


registryIndex = awtx.socket.unregisterEomEvent(socketNumber)

Parameters
socketNumber - (Number) The number of the socket that is currently being used.

Returns

registryIndex - (Number) The status of the function. 0 means success, negative means error.

1 -- Unregisters the eom event


2 registryIndex = awtx.socket.unregisterEomEvent(socketNumber)

This function unregisters an eom event allowing for it to be garbage collected.


Possible outputs for registryIndex:
0 = SUCCESS
-1 = ERROR: Function must have 1 parameter
-2 = ERROR: Parameter 1 must be numeric
-3 = ERROR: Socket number not valid

3.18 textboxCtrl Class Reference

Public Member Functions

• getLocation (checkTextbox)
getX, getY = textboxCtrl:getLocation(checkTextbox)

• getText (checkTextbox)
getText = textboxCtrl:getText(checkTextbox)

• getVisible (checkTextbox)
visible = textboxCtrl:getVisible(checkTextbox)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.18 textboxCtrl Class Reference 117

• reSize (checkTextbox, getX, getY)


textboxCtrl:reSize(checkTextbox, getX, getY)

• setFont (checkTextbox, font)


textboxCtrl:setFont(checkTextbox, font)

• setLocation (checkTextbox, getX, getY)


textboxCtrl:setLocation(checkTextbox, getX, getY)

• setText (checkTextbox, newText)


textboxCtrl:setText(checkTextbox, newText)

• setVisible (checkTextboxes, visible)


textboxCtrl:setVisible(checkTextboxes, visible)

3.18.1 Detailed Description

The textboxCtrl function handles displaying textboxes onto the system's screen. The namespace handles the loca-
tion, text, visibility, size and font of the textbox.

3.18.2 Member Function Documentation

3.18.2.1 textboxCtrl:getLocation ( checkTextbox )


getX, getY = textboxCtrl:getLocation(checkTextbox)

Parameters
checkTextbox - (String) The textbox that we are getting the location for.

Returns

getX - (Number) The X-coordinate for the textbox.


getY - (Number) The Y-coordinate for the textbox.

1 -- Get the location of the textbox


2 local textbox = "textbox1"
3 local getX, getY = textboxCtrl:getLocation(textbox)
4
5 print(string.format("The location of %s is: %i, %i", textbox, getX, getY)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function gets the location for the textbox.

3.18.2.2 textboxCtrl:getText ( checkTextbox )


getText = textboxCtrl:getText(checkTextbox)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
118 Class Documentation

Parameters
checkTextbox - (String) The textbox that the text is going to be set to.

Returns

getText - (String) The text that is going to be set to the textbox.

1 -- Gets the text for a textbox


2 local textbox = "textbox 1"
3
4 local getText = textboxCtrl:getText(textbox)
5 print(string.format("This text will be set onto %s: %s", textbox, getText)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function gets text for the given textbox.

3.18.2.3 textboxCtrl:getVisible ( checkTextbox )


visible = textboxCtrl:getVisible(checkTextbox)

Parameters
checkTextbox - (String) The textbox that is being checked to see if it is visible.

Returns

visible - (Boolean) Determines if the textbox is visible or not.

1 -- Get the visibility of the textbox


2 local textbox = "textbox1"
3
4 local visible = textboxCtrl:getVisible(textbox)
5 print(string.format("The visibility of %s is: %c", textbox, visible)) -- Prints to the Lua Console (located
at Ztools -> Zedit -> Output)

This function grabs the visibility setting of the created textbox.

3.18.2.4 textboxCtrl:reSize ( checkTextbox , getX , getY )


textboxCtrl:reSize(checkTextbox, getX, getY)

Parameters
checkTextbox - (String) The textbox that is going to be resized.
getX - (Number) The X-coordinate of the starting point of the textbox.
getY - (Number) The Y-coordinate of the starting point of the textbox.

1 -- Resize the textbox


2 local textbox = "textbox1"
3 local getX = 60
4 local getY = 85
5
6 -- Set the new size for the textbox
7 textboxCtrl:reSize(textbox, getX, getY)

This function resizes the textbox.

3.18.2.5 textboxCtrl:setFont ( checkTextbox , font )


textboxCtrl:setFont(checkTextbox, font)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.18 textboxCtrl Class Reference 119

Parameters
checkTextbox - (String) The textbox that the font type will be set to.
font - (Number) The type of font that will be used to format the text in the textbox.

1 -- Set up the new font for the textbox


2 local textbox = "textbox1"
3 local fontType = 25 -- Number code for the font type being used.
4
5 textboxCtrl:setFont(textbox, fontType)

This function sets the font type for the text box.

3.18.2.6 textboxCtrl:setLocation ( checkTextbox , getX , getY )


textboxCtrl:setLocation(checkTextbox, getX, getY)

Parameters
checkTextbox - (String) The textbox that we are setting the location for.
getX - (Number) The X-coordinate for the textbox.
getY - (Number) The Y-coordinate for the textbox.

1 -- Set the location of the textbox.


2 local textbox = "textbox1"
3 local getX = 60
4 local getY = 35
5
6 textboxCtrl:setLocation(textbox, getX, getY)

This function sets the location for the textbox.

3.18.2.7 textboxCtrl:setText ( checkTextbox , newText )


textboxCtrl:setText(checkTextbox, newText)

Parameters
checkTextbox - (String) The textbox that will be having text applied to.
newText - (String) The text that is going to be applied to the textbox.

1 -- Sets the text onto the textbox


2 local textbox = "textbox 1"
3 -- First gets the text for the textbox
4 local getText = textboxCtrl:getText(textbox)
5 print(string.format("This text will be set onto %s: %s", textbox, getText)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)
6
7 -- Then sets the text onto the textbox
8 textboxCtrl:setText(textbox, getText)

This function sets the given text into the textbox.

3.18.2.8 textboxCtrl:setVisible ( checkTextboxes , visible )


textboxCtrl:setVisible(checkTextboxes, visible)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
120 Class Documentation

Parameters
checkTextboxes - (String) The textboxes that are being set to be visible to the user.
visible - (Boolean) Determines whether the textboxes are visible.

1 -- Set the visibility of the textbox


2 local textbox = "textbox1"
3 local visible = true
4
5 textboxCtrl:setVisible(textbox, visible)

This function sets the textboxes to be visible.

3.19 utf8 Class Reference

Public Member Functions

• charToCodePoint (utf8String)
result = awtx.utf8.charToCodePoint(utf8String)

• isLegalUtf8Char (testString)
result = awtx.utf8.isLegalUtf8Char(testString)

• isLegalUtf8String (testString)
result = awtx.utf8.isLegalUtf8String(testString)

• length (testString)
length = awtx.utf8.length(testString)

• toCodePoints (utf8String)
result = awtx.utf8.toCodePoints(utf8String)

• toLuaTable (utf8String)
luaTable = awtx.utf8.toLuaTable(utf8String)

3.19.1 Detailed Description

The utf8 namespace handles the utf8 characters that are entered into the system. This namespace checks to see
if a string is a legal utf8 string, determines the length, sets the utf8 characters to a code point and other functions
described below.

3.19.2 Member Function Documentation

3.19.2.1 awtx.utf8.charToCodePoint ( utf8String )


result = awtx.utf8.charToCodePoint(utf8String)

Parameters

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.19 utf8 Class Reference 121

utf8String - (String) The utf8 character to be convetred.

Returns

result - (String) Returns the unicode codepoint.

1 -- First the string we want to change to unicode.


2 local utf8Char = "J"
3 --Next we convert the character and then print out the results.
4 local result = awtx.utf8.charToCodePoint(utf8Char)
5 print(string.format("Character in utf8 = %s character in unicode = %s", utf8Char, result)) -- Prints to the
Lua Console (located at Ztools -> Zedit -> Output)

This function converts a utf8 character byte sequence into a Unicode codepoint.

3.19.2.2 awtx.utf8.isLegalUtf8Char ( testString )


result = awtx.utf8.isLegalUtf8Char(testString)

Parameters
testString - (String) The input character to be checked.

Returns

result - (Boolean) True if the input string is a legal single UTF-8 string, otherwise false.

1 -- Check to see if a typed in character (in this case, the letter ’H’) is a legal UTF8 character.
2 local legalUtf = awtx.utf8.isLegalUtf8Char("H")
3 -- Now print out the value of legalUtf
4 print(legalUtf) -- Prints to the Local Console (located at Ztools -> Zedit -> Output)

This function returns boolean true, if it is a legal single UTF-8 string, else it returns false. Internally it checks to see
if the byte stream representing the codepoint is a correct legal sequence.

3.19.2.3 awtx.utf8.isLegalUtf8String ( testString )


result = awtx.utf8.isLegalUtf8String(testString)

Parameters
testString - (String) The input string to be checked.

Returns

result - (Boolean) True if the input string is a legal single UTF-8 string, otherwise false.

1 -- Test a created string to check if it is a legal Utf8 string.


2 local testStr = "Hello, this is some text"
3 local legalStr = awtx.utf8.isLegalUtf8String(testStr)
4
5 -- Now print out the value of legalStr
6 print(legalStr) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)

This function returns boolean true, if the input string is a legal single UTF-8 string, else it returns false. Internally it
checks to see if the byte stream representing the codepoint is a correct legal sequence.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
122 Class Documentation

3.19.2.4 awtx.utf8.length ( testString )


length = awtx.utf8.length(testString)

Parameters
testString - (String) The input string to be measured.

Returns

length - (Number) The length of the string in codepoints.

1 print (string.len("Hello")) -- This line prints 5 for the string length


2
3 local utfLen = awtx.utf8.length("Hello") -- utfLen is the length of the inputted string.
4 -- Now the length of utfLen gets printed out to the Lua Console (located at Ztools -> Zedit -> Output)
5 print(utfLen) -- This line prints 5 for the correct length of codepoints

Gets the length of a UTF-8 string.

3.19.2.5 awtx.utf8.toCodePoints ( utf8String )


result = awtx.utf8.toCodePoints(utf8String)

Parameters
utf8String - (String) The utf8 string to be printed.

Returns

result - (Number) Checks to see if the function worked successfully. Returns 0 if successful, else a negative
number for an error message.

1 local utf8Char = "TEXT "


2
3 local result = awtx.utf8.toCodePoints(utf8Char)
4 print(result) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)

This function takes a utf8 string and prints it out as a codepoint array.
This function converts a valid utf8 string into an array of codepoints and then prints them out as a list of codepoints
including knowledge of the AWTX usage for POA codepoints.
If utf8String is null, probable means was called with nil instead of a Lua string.
Example Output:
17: U+00054 LATIN CAPITAL LETTER T
18: U+00045 LATIN CAPITAL LETTER E
19: U+00058 LATIN CAPITAL LETTER X
20: U+00054 LATIN CPAITAL LETTER T
21: U+00020 SPACE
34: U+0000D CARRIAGE RETURN
35: U+0000A LINE FEED

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.20 variables Class Reference 123

3.19.2.6 awtx.utf8.toLuaTable ( utf8String )


luaTable = awtx.utf8.toLuaTable(utf8String)

Parameters
utf8String - (String) The utf8 string to be converted to a Lua table.

Returns

luaTable - (Table) A Lua table of unicode codepoints.

1 local utf8Char = "Table Placement "


2
3 local luaTable = awtx.utf8.toLuaTable(utf8Char)
4 -- Print statements are outputted to the Lua Console (located at Ztools -> Zedit -> Output)
5 print(string.format("%S Has been converted into a table.", utf8Char))
6 print(luaTable)

This function returns a Lua table containing the codepoints of the utf8 input string.

3.20 variables Class Reference

Public Member Functions

• clearTable (tableName)
awtx.variables.clearTable(tableName)

• createTable (tableName)
awtx.variables.createTable(tableName)

• deleteTable (tableName)
awtx.variables.deleteTable(tableName)

• readTable (tableName)
readTable = awtx.variables.readTable(tableName)

• recall (tableName, key)


Value = awtx.variables.recall(tableName, key)
• store (tableName, key, value)
awtx.variables.store(tableName, key, value)

3.20.1 Detailed Description

The variables namespace deals primarily with tables. It handles creating, clearing, reading and deleting tables as
well as recalling and storing data onto the tables on the system.

3.20.2 Member Function Documentation

3.20.2.1 awtx.variables.clearTable ( tableName )


awtx.variables.clearTable(tableName)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
124 Class Documentation

Parameters
tableName - (String) Name of the table in which the items will be deleted from.

1 -- Clears the information from a Table


2 awtx.variables.clearTable(oldTable)

This function deletes items from the table specified.

3.20.2.2 awtx.variables.createTable ( tableName )


awtx.variables.createTable(tableName)

Parameters
tableName - (String) The name of the table that is going to be created.

1 -- Creates a new Table


2 awtx.variables.createTable(newTable)

This function creates a table of variables to be used.

3.20.2.3 awtx.variables.deleteTable ( tableName )


awtx.variables.deleteTable(tableName)

Parameters
tableName - (String) The name of the table that is going to be deleted.

1 -- Deletes the entire table from memory


2 awtx.variables.deleteTable(varTable)

This function deletes the listed table.

3.20.2.4 awtx.variables.readTable ( tableName )


readTable = awtx.variables.readTable(tableName)

Parameters
tableName - (String) The name of the table that is being read.

Returns

readTable - (Table) Table of records that has been parsed through.

1 -- Reads the information in a Table


2 local readTable = awtx.variables.readTable(varTable)
3 local readStr = toString(readTable)
4 print(readStr) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)

This function reads through a table that has been specified.

3.20.2.5 awtx.variables.recall ( tableName , key )


Value = awtx.variables.recall(tableName, key)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 125

Parameters
tableName - (String) (Optional) The name of the table that is having values recalled.
key - (String) The name for the value in which the value will be returned.

Returns

Value - (String) Value for the key name that has been called.

1 --Recall values from a table


2
3 local value = awtx.variables.recall(tableName, key)
4 print(string.format("The value for the key inputted is: ",value)) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)

This function returns the value from a given table and key.
Value can be a boolean, string, number, or table.

3.20.2.6 awtx.variables.store ( tableName , key , value )


awtx.variables.store(tableName, key, value)

Parameters
tableName - (String) (Optional) The name of the table that is having values stored into.
key - (String) Determines the name of the value being stored.
value - (String) What is being stored under the key value.

1 -- Create a new Table


2 awtx.variables.createTable(newTable)
3
4 --Store new values into the table
5 local key = "scaleId"
6 local value = "10"
7 awtx.variables.store(tableName, key, value)
8 print(string.format("Key %s and its value %s have been stored into a table", key, value)) -- Prints to the
Lua Console (located at Ztools -> Zedit -> Output)

This function stores variables into a table.


Value can be a boolean, string, number, or table.

3.21 weight Class Reference

Public Member Functions

• clearInmotion (scaleNumber)
awtx.weight.clearInmotion(scaleNumber)

• configureRateOfChange (scaleNumber, period, units)


awtx.weight.configureRateOfChange(scaleNumber, period, units)

• convertFromInternalCalUnit (scaleNumber, value, toUnit, applyRounding)


convertedResult = awtx.weight.convertFromInternalCalUnit(scaleNumber, value, toUnit, applyRounding)

• convertToInternalCalUnit (scaleNumber, value, applyRounding)


convertedResult = awtx.weight.convertToInternalCalUnit(scaleNumber, value, applyRounding)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
126 Class Documentation

• convertWeight (scaleNumber, fromUnit, value, toUnit, applyRounding)


convertedResult = awtx.weight.convertWeight(scaleNumber, fromUnit, value, toUnit, applyRounding)

• cycleActiveScale ()
awtx.weight.cycleActiveScale()

• cycleActiveValue (scaleNumber)
awtx.weight.cycleActiveValue(scaleNumber)

• cycleUnits (scaleNumber)
awtx.weight.cycleUnits(scaleNumber)

• getActiveScale ()
scaleNumber = awtx.weight.getActiveScale()

• getActiveValue ()
activeValue = awtx.weight.getActiveValue()

• getCalibWeightUnits (scaleNumber)
calibUnits = awtx.weight.getCalibWeightUnits(scaleNumber)

• getConfig (scaleNumber)
weightTable = awtx.weight.getConfig(scaleNumber)

• getCurrent (scaleNumber)
scaleDataTable = awtx.weight.getCurrent(scaleNumber)

• getCurrentUnits (scaleNumber)
currentUnit = awtx.weight.getCurrentUnits(scaleNumber)

• getInmotion (scaleNumber)
returnVal = awtx.weight.getInmotion(scaleNumber)

• getLastPrint (scaleNumber)
lastPrintTable = awtx.weight.getLastPrint(scaleNumber)

• getNumActiveScales ()
numActive = awtx.weight.getNumActiveScales()

• getPieceWeight ()
pieceWeight = awtx.weight.getPieceWeight()

• getRefreshLastPrint (scaleNumber)
lastPrintTable = awtx.weight.getRefreshLastPrint(scaleNumber)

• getSampleSize (scaleNumber)
sampleCount = awtx.weight.getSampleSize(scaleNumber)

• getTarget (scaleNumber)
target = awtx.weight.getTarget(scaleNumber)

• graphEnable (scaleIndex, graphType)


awtx.weight.graphEnable(scaleIndex, graphType)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 127

• inmotion (enable, startIO, stopIO, scaleNumber, multiplier)


awtx.weight.inmotion(enable, startIO, stopIO, scaleNumber, multiplier)

• registerAccumCompleteEvent (callbackFunction)
awtx.weight.registerAccumCompleteEvent(callbackFunction)

• registerHoldCompleteEvent (holdComplete)
awtx.weight.registerHoldCompleteEvent(holdComplete)

• registerInmotionCompleteEvent (callbackFunction)
awtx.weight.registerInmotionCompleteEvent(callbackFunction)

• registerInmotionErrorEvent (callbackFunction)
awtx.weight.registerInmotionErrorEvent(callbackFunction)

• registerInmotionStartEvent (callbackFunction)
awtx.weight.registerInmotionStartEvent(callbackFunction)

• registerPrintCompleteEvent (callbackFunction)
awtx.weight.registerPrintCompleteEvent(callbackFunction)

• registerSampleCompleteEvent (callbackFunction)
awtx.weight.registerSampleCompleteEvent(callbackFunction)

• registerSelectCompleteEvent (callbackFunction)
awtx.weight.registerSelectCompleteEvent(callbackFunction)

• registerTareCompleteEvent (callbackFunction)
awtx.weight.registerTareCompleteEvent(callbackFunction)

• registerUnitsCompleteEvent (callbackFunction)
awtx.weight.registerUnitsCompleteEvent(callbackFunction)

• registerWeightChangeEvent (callbackFunction)
awtx.weight.registerWeightChangeEvent(callbackFunction)

• registerZeroCompleteEvent (callbackFunction)
awtx.weight.registerZeroCompleteEvent(callbackFunction)

• requestAccum (scaleNumber)
awtx.weight.requestAccum(scaleNumber)

• requestHold (scaleNumber)
awtx.weight.requestHold(scaleNumber)

• requestKeyboardTare (scaleNumber, newTare)


awtx.weight.requestKeyboardTare(scaleNumber, newTare)

• requestPresetTare (scaleNumber, newTare)


awtx.weight.requestPresetTare(scaleNumber, newTare)

• requestPrint (scaleNumber)
awtx.weight.requestPrint(scaleNumber)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
128 Class Documentation

• requestSample (scaleNumber, mode)


awtx.weight.requestSample(scaleNumber, mode)

• requestTare (scaleNumber)
awtx.weight.requestTare(scaleNumber)

• requestTareClear (scaleNumber)
awtx.weight.requestTareClear(scaleNumber)

• requestZero (scaleNumber)
awtx.weight.requestZero(scaleNumber)

• requestZeroCheckWeigh (scaleNumber)
awtx.weight.requestZeroCheckWeigh(scaleNumber)

• resetAccum (scaleNumber)
awtx.weight.resetAccum(scaleNumber)

• resetPeakMax (scaleNumber)
awtx.weight.resetPeakMax(scaleNumber)

• resetPeakMin (scaleNumber)
awtx.weight.resetPeakMin(scaleNumber)

• scaleEnabled (scaleNumber)
returnVal = awtx.weight.scaleEnabled(scaleNumber)

• setAccum (scaleNumber, grosswtTot, netwtTot, newTare, countTot)


awtx.weight.setAccum(scaleNumber, grosswtTot, netwtTot, newTare, countTot)

• setActiveScale (scaleNumber)
returnVal = awtx.weight.setActiveScale(scaleNumber)

• setActiveValue (setActive)
activeValue = awtx.weight.setActiveValue(setActive)

• setBar (scaleIndex, basis, minWt, maxWt)


awtx.weight.setBar(scaleIndex, basis, minWt, maxWt)

• setCheck (scaleIndex, basis, minWt, underWt, overWt, maxWt, underDiv, overDiv)


awtx.weight.setCheck(scaleIndex, basis, minWt, underWt, overWt, maxWt, underDiv, overDiv)

• setConfig (scaleNumber, paramTable)


returnVal, messageReturn = awtx.weight.setConfig(scaleNumber, paramTable)

• setCurrentUnits (scaleNumber, newUnit)


lastUnit = awtx.weight.setCurrentUnits(scaleNumber, newUnit)

• setDisplayVariable (displayVariable, legend1, legend2, precision, scaleNumber, motionVar, centerZero)


awtx.weight.setDisplayVariable(displayVariable, legend1, legend2, precision, scaleNumber, motionVar, centerZero)

• setPieceWeight (scaleNumber, pieceWeight)


result = awtx.weight.setPieceWeight(scaleNumber, pieceWeight)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 129

• setSampleSize (scaleNumber, itemCount)


result = awtx.weight.setSampleSize(scaleNumber, itemCount)

• setTarget (scaleNumber, newTarget)


status = awtx.weight.setTarget(scaleNumber, newTarget)

• unitStrToUnitIndex (unitStr)
returnVal, unitEnum = awtx.weight.unitStrToUnitIndex(unitStr)

• unregisterAccumCompleteEvent ()
awtx.weight.unregisterAccumCompleteEvent()

• unregisterHoldCompleteEvent ()
result = awtx.weight.unregisterHoldCompleteEvent()

• unregisterInmotionCompleteEvent ()
awtx.weight.unregisterInmotionCompleteEvent()

• unregisterInmotionErrorEvent ()
awtx.weight.unregisterInmotionErrorEvent()

• unregisterInmotionStartEvent ()
awtx.weight.unregisterInmotionStartEvent()

• unregisterPrintCompleteEvent ()
awtx.weight.unregisterPrintCompleteEvent()

• unregisterSampleCompleteEvent ()
awtx.weight.unregisterSampleCompleteEvent()

• unregisterSelectCompleteEvent ()
awtx.weight.unregisterSelectCompleteEvent()

• unregisterTareCompleteEvent ()
awtx.weight.unregisterTareCompleteEvent()

• unregisterUnitsCompleteEvent ()
awtx.weight.unregisterUnitsCompleteEvent()

• unregisterWeightChangeEvent ()
awtx.weight.unregisterWeightChangeEvent()

• unregisterWeightUpdateEvent ()
awtx.weight.unregisterWeightUpdateEvent()

• unregisterZeroCompleteEvent ()
awtx.weight.unregisterZeroCompleteEvent()

3.21.1 Detailed Description

The weight namespace handles all of the weighing of objects on the system. It handles weight conversions, getting
active weight, requesting hold weight, grabbing target weight, and other functions detailed below.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
130 Class Documentation

3.21.2 Member Function Documentation

3.21.2.1 awtx.weight.clearInmotion ( scaleNumber )


awtx.weight.clearInmotion(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale is currently being used; if left out is set to 0 for
the active scale

1 local scaleNumber = 1
2
3 awtx.weight.clearInmotion(scaleNumber)
4 print(string.format("The scale with scale number %i has just cleared inmotion weight.", scaleNumber)) --
Prints to the Lua Console (located at Ztools -> Zedit -> Output)

This function clears the data from a scale that was dealing with weighing moving objects.

3.21.2.2 awtx.weight.configureRateOfChange ( scaleNumber , period ,


units )
awtx.weight.configureRateOfChange(scaleNumber, period, units)

Parameters
scaleNumber - (Number) (Optional) The scale that is currently in use. If not specified, will equal 0 for the
current active scale.
period - (Number) Time period over which to compute the rate of change in ms.
units - (Number) Time units used to express the rate of change in the current weight unit of mea-
sure.

1 -- Determine the rate of change for weight on the scale


2 local period = 4000 -- 4000 milliseconds
3 local units = 0 -- 0 for Seconds
4
5 awtx.weight.configureRateOfChange(period, units)
6 print("Rate of change configured.") -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)

This function configures the rate of change active value.


For 'period', The indicator uses all of the weight samples taken within the last 'x' milliseconds to calculate the rate of
change.
For 'units', possible outputs are:
0 = Seconds
1 = Minutes
2 = Hours
When the current scale unit selected is in Pounds (LBs) and the set rate of change unit is set to seconds, the rate
of change will be shown as lb/s.

3.21.2.3 awtx.weight.convertFromInternalCalUnit ( scaleNumber , value


, toUnit , applyRounding )
convertedResult = awtx.weight.convertFromInternalCalUnit(scaleNumber, value, toUnit, applyRounding)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 131

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, if left out is set to 0
for the active scale.
value - (Number) The weight to be converted to a new weighing unit.
toUnit - (Number) The units to convert the input weight into. See units definition table below.
applyRounding - (Number) 1 to round the converted weight to the nearest configured display division. 0
leaves result unrounded.

Returns

convertedResult - (Number) The weight value in the new requested units.

1 local UNITS_LB = 1
2 local UNITS_KG = 2
3
4 local wt = awtx.weight.getCurrent()
5 local weightToConv = wt.gross
6 local convertedResult
7
8 -- Convert value from Internal Calibration units without rounding
9 convertedResult = awtx.weight.convertFromInternalCalUnit(weighToConv, UNITS_KG, 0)
10 print(string.format("input=%3.8f result=%3.8f", weightToConv, convertedResult )) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

This function converts an input weight from the Indicator's internal calibration unit to the required new unit.
UNIT Definitions:
LB = 1
KG = 2
OZ = 3
GRAM = 4
LB_OZ = 5
CUSTOM UNIT1 = 6
CUSTOM UNIT2 = 7
CUSTOM UNIT3 = 8
CUSTOM UNIT4 = 9

3.21.2.4 awtx.weight.convertToInternalCalUnit ( scaleNumber , value ,


applyRounding )
convertedResult = awtx.weight.convertToInternalCalUnit(scaleNumber, value, applyRounding)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, if left out is set to 0
for the active scale.
value - (Number) The weight to be converted to the Indicator's internal calibration units.
applyRounding - (Number) 1 to round the converted weight to the nearest configured display division. 0
leaves result unrounded.

Returns

convertedResult - (Number) The weight value in the Indicator's internal calibration units.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
132 Class Documentation

1 local weightToConv = 1.1


2 local convertedResult
3
4 -- convert value to Internal Calibration units without rounding
5 convertedResult = awtx.weight.convertToInternalCalUnit(weightToConv, 0)
6 print(string.format("input=%3.8f result=%3.8f", weightToConv, convertedResult )) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

This function converts the current Indicator's active unit to its internal calibration unit.

3.21.2.5 awtx.weight.convertWeight ( scaleNumber , fromUnit , value ,


toUnit , applyRounding )
convertedResult = awtx.weight.convertWeight(scaleNumber, fromUnit, value, toUnit, applyRounding)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, if left out is set to 0
for the active scale.
fromUnit - (Number) The units of the valueToConvert input parameter. See units definition table below.
value - (Number) The weight to be converted to a new weighing unit.
toUnit - (Number) The units to convert the input weight into. See units definition table below.
applyRounding - (Number) 1 to round the converted weight to the nearest configured display division. 0
leaves result unrounded.

Returns

convertedResult - (Number) The weight value in the new requested units.

1 local wt = awtx.weight.getCurrent()
2 local weightToConv = wt.gross
3 local convertedResult
4
5 local UNITS_LB = 1
6 local UNITS_KG = 2
7
8 -- convert value from Kg’s to lb’s without rounding
9 -- Print statements are outputted to the Lua Console (located at Ztools -> Zedit -> Output)
10 convertedResult = awtx.weight.convertWeight( UNITS_KG, weightToConv, UNITS_LB, 0)
11 print(string.format("input=%3.8f result=%3.8f", weightToConv, convertedResult ))
12
13 -- convert value from Kg’s to lb’s with rounding to nearest configured division
14 convertResult = awtx.weight.convertWeight( UNITS_KG, weightToConv, UNITS_LB, 1)
15 print(string.format("input=%3.8f result=%3.8f", weightToConv, convertedResult ))

This function converts the current Indicator's active unit to its internal calibration unit.
UNIT Definitions:
LB = 1
KG = 2
OZ = 3
GRAM = 4
LB_OZ = 5
CUSTOM UNIT1 = 6
CUSTOM UNIT2 = 7
CUSTOM UNIT3 = 8
CUSTOM UNIT4 = 9

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 133

3.21.2.6 awtx.weight.cycleActiveScale ( )
awtx.weight.cycleActiveScale()

1 -- Cycle through active scales


2 awtx.weight.cycleActiveScale()

This function navigates through different scales that are currently active.

3.21.2.7 awtx.weight.cycleActiveValue ( scaleNumber )


awtx.weight.cycleActiveValue(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale to receive the cycle request, if left out is set to 0
for the active scale.

1 local SCALE_IS_OWNER = 0
2 local LUA_SCRIPT_IS_OWNER = 1
3
4 -- make the Scale own the display so see the Weight display
5 awtx.display.setMode(SCALE_IS_OWNER)
6
7 -- Set F1 key to trigger the active value cycle.
8 function awtx.keypad.KEY_F1_DOWN()
9 print("F1 pressed, about to cycle Active Value") -- Prints to the Lua Console (located at Ztools -> Zedit
-> Output)
10 awtx.weight.cycleActiveValue() -- cycle around Gross, Net, Tare
11 end

This function sends a request to the scaleNumber scale to cycle the current active value to the next active Value.
E.g. Gross, Net, Tare.

3.21.2.8 awtx.weight.cycleUnits ( scaleNumber )


awtx.weight.cycleUnits(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, if left out is set to 0
for the active scale.

1 local SCALE_IS_OWNER = 0
2 local LUA_SCRIPT_IS_OWNER = 1
3
4 -- make the Scale own the display so see the Weight display
5 awtx.display.setMode(SCALE_IS_OWNER)
6
7 -- arbitrary choice lets just use the F1 key for this example
8 function awtx.keypad.KEY_F1_DOWN()
9 print("F1 pressed, about to cycle Configured Units") -- Prints to the Lua Console (located at Ztools ->
Zedit -> Output)
10 awtx.weight.cycleUnits()
11 end

This function causes the Scale to cycle the display unit to the next configured weighing unit. E.g. lb, Kg etc.

3.21.2.9 awtx.weight.getActiveScale ( )
scaleNumber = awtx.weight.getActiveScale()

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
134 Class Documentation

Returns

scaleNumber - (Number) The current scale that is active.

1 local scaleNumber = awtx.weight.getActiveScale()


2 print(string.format("%i is the number of the current active scale.", scaleNumber)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

This function finds what scale is currently active.

3.21.2.10 awtx.weight.getActiveValue ( )
activeValue = awtx.weight.getActiveValue()

Returns

activeValue - (Number) Snapshot of the current active value of the scale.

1 local activeValue = awtx.weight.getActiveValue()


2 print(string.format("The current snapshot of the active value of the scale is: %i", activeValue)) -- Prints
to the Lua Console (located at Ztools -> Zedit -> Output)

This function grabs the current active value of the scale.

3.21.2.11 awtx.weight.getCalibWeightUnits ( scaleNumber )


calibUnits = awtx.weight.getCalibWeightUnits(scaleNumber)

Parameters
scaleNumber - (Number) Specifies which scale that is currently being used; if left out is set to 0 for the
active scale.

Returns

calibUnits - (Number) Number representation of the units being used.

1 local scaleNumber = 1
2
3 local calibUnits = awtx.weight.getCalibWeightUnits(scaleNumber)
4 print(string.format("The calibrated weight units on scale %i are %i", scaleNumber, calibUnits)) -- Prints
to the Lua Console (located at Ztools -> Zedit -> Output)

This function grabs the unit of measure for the calibration weight.

3.21.2.12 awtx.weight.getConfig ( scaleNumber )


weightTable = awtx.weight.getConfig(scaleNumber)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 135

Parameters
scaleNumber - (Number) The Scale number for which the weight configuration data is required. Currently,
the only accepted value is 1 (with 1 indicating that the scale being used is the current active
scale.)

Returns

weightTable - (Table) This is a Lua table containing a number of key - value pairs, containing the current Scale
configuration.

1 local SCALE_1 = 1
2
3 -- This gets & prints out all the weighing configuration data for Scale 1
4 local wtConfigTable = awtx.weight.getConfig(SCALE_1)
5
6 for k, v in pairs(wtConfigTable) do
7 print(k, v) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
8 end

1 local SCALE_1 = 1
2
3 -- This shows how to print a specific parameter from the Config Table
4 print(string.format("Weight Config. Division size = %d", wtConfigTable.division))

This function returns a Lua table containing a number of key value pairs containing a snapshot of the Scale Weight
Configuration data.
Table for weightTable:

1. site
Contains scale site information (e.g. USA, GB, CAN, EU, CHINA, INDIA).

2. capacity (Scale Specific)


Double value containing configured capacity

3. division (Scale Specific)


Double value indicating current scale divisions setting

4. updateFreq (Scale Specific)


Integer value of the scale update frequency.

5. autoTareClear (Scale Specific)


Boolean value indicating if tare clears automatically when the scale returns to the gross-zero band.

6. presentTareFlag (Scale Specific)


Boolean value indicating if tare clears automatically when the scale returns to the gross-zero band.

7. pbTareFlage (Scale Specific)


Boolean value indicating whether or not pushbutton tare is enabled.

8. keyTareFlag (Scale Specific)


Boolean value indicating whether or not keypad tare is enabled.

9. calwtunit (Scale Specific)


Integer value inticating the configured calibration unit (1 = lb, 2 = kg).

10. calwtunitStr (Scale Specific)


String identifier for current calibration unit ("lb" or "kg").

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
136 Class Documentation

11. siteID
String of configured site ID.

12. displaySeparator
Integer value indicating the current decimal separator character (0 = '.', 1 = ',')

13. grossZeroBand (Scale Specific)


Integer value indicating the number of divisions on either side of center zero to be considered inside the
gross-zero band.

14. autoprintpercent (Scale Specific)


Double value indicating at what percentage of capacity an auto-print should occur.

15. printRTZ (Scale Specific)


Boolean value indicating if the weight must return to sero before another auto-print can occur.

16. dateFormat
Integer value indicating the current date format (0 = "MMDD2Y", 1 = "MMDD4Y", 2 = "DDMM2Y", 3 = "DD←-
MM4Y").

17. timeFormat
Integer value indicating the current time format (0 = "12HR", 1 = "12HR-AP", 2 = "24HR").

3.21.2.13 awtx.weight.getCurrent ( scaleNumber )


scaleDataTable = awtx.weight.getCurrent(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) The Scale number for which the scale data is requested. If not speci-
fied, the active scale will be used.

Returns

scaleDataTable - (Table) A Lua table containing a number of key - value pairs, containing the current weight
data.

1 local SCALE_1 = 1
2
3 -- This gets & prints out all the Current Weight data for Scale 1
4
5 local scaleDataTable = awtx.weight.getCurrent(SCALE_1)
6
7 for k,v in pairs(scaleDataTable) do
8 print(k,v) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
9 end

1 local SCALE_1 = 1
2 local scaleDataTable = awtx.weight.getCurrent(SCALE_1)
3
4 -- This shows how to print a specific weight parameter from the Lua Table
5 print(string.format("Tare Weight = %d %s", scaleDataTable.tare, scaleDataTable.unitsStr)) -- Prints to the
Lua Console (located at Ztools -> Zedit -> Output)
6
7 --Example Print output
8
9 --Tare Weight = 2500 lb

Returns a Lua table containing a number of key value pairs containing a snapshot of the current scale data.
Table for scaleDataTable (same data as format as awtx.weight.getLastPrint())

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 137

1. gross
Gross Weight - Double - Current gross weight.

2. net
Net Weight - Double - Current net weight.

3. tare
Tare Weight - Double - Current tare weight.

4. units
Units of Measure - Integer - Represents the current unit of measure as an integer.

5. unitsStr
Units of Measure - String - Contains the current unit of measure as a string.

6. count
Piece Count - Integer - Current piece count (Net weight divided by Current Piece Weight).

7. motion
Motion - Boolean - True if scale is in motion, false if scale is stable.

8. centerZero
Center Zero - Boolean - True if scale is at center-zero.

9. underRange
Under Range Flag - Boolean - True if scale is in underload.

10. overRange
Over Range Flag - Boolean - True if scale is in overload.

11. min
Minimum - Double - Minimum recorded gross weight on scale since last reset.

12. max
Maximum - Double - Maximum recorded gross weight on scale since last reset.

13. roc
Rate of Change - Double - Current rate of change of the scale weight.

14. gtot
Gross Total - Double - Current total of gross weight values of all transactions since last reset.

15. ntot
Net Total - Double - Current total of net weight values of all transactions since last reset.

16. gtotcal
Gross Total Cal - Double - Current total of gross weight values in pounds of all transactions since last reset.

17. ntotcal
Net Total Cal - Double - Current total of net weight values in pounds of all transactions since last reset.

18. ctot
Count Total - Integer - Current total of piece count values of all transactions since last reset.

19. tran
Transaction Count - Integer - Current transaction count.

20. pcwt
Piece Weight - Double - Current piece weight being used to calculate the piece count.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
138 Class Documentation

21. adc
ADC Counts - Integer - ADC counts value coming from the scale ADC chip.

22. inGrossBand
In Gross Band - Boolean - True if weight is inside the cofigured gross zero band.

23. percent
Percent - Double - Current net weight divided by current tare weight as a percentage.

24. timestamp
Time Stamp - Integer - Seconds elapsed since 1/1/1970.

25. curUnitsFactor
Current Units Conversion - Double - Conversion factor used to convert pounds into the current unit of measure.

26. curCapacity
Current Capacity - Double - Configured capacity of the requested scale in the current unit of measure.

27. curDivision
Current Division - Double - Configured weight division resolution of the requested scale in the current unit of
measure.

28. curDigitsRight
Current Digits Right - Integer - Number of digits (precision) allowed to the right of the decimal in the current
division.

29. curDigitsLeft
Current Digits Left - Integer - Number of digits currently displayed to the left of the decimal on the requested
scale.

30. curDigitsTotal
Current Digits Total - Integer - Number of total digits being displayed (including decimal, if applicable).

31. consecNumber
Consecutive Number - Integer - Internal scale object counter controlled by special print tokens.

32. inmotion
In-motion Weight - Double - Current in-motion weight.

33. target
Target - Double - Current target weight.

34. holdEnabled
Hold Enabled - Boolean - True if HOLD function is active.

35. holdCounts
Hold Counts - Integer - Counts value of the scale when HOLD function was enabled.

36. gtotpluscur
Gross Total plus Current - Double - Current gross total weight plus current gross weight.

37. gtotminuscur
Gross Total minus Current - Double - Current gross total weight minus current gross weight.

38. ntotpluscur
Net Total plus Current - Double - Current net total weight plus current net weight.

39. ntotminuscur
Net Total minus Current - Double - Current net total weight minus current net weight.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 139

40. ctotpluscur
Count Total plus Current - Integer - Current piece count total weight plus current piece count.

41. ctotminuscur
Count Total minus Current - Integer - Current piece count total weight minus current piece count.

42. grossavg
Average Gross Weight - Double - Current average gross weight.

43. netavg
Average Net Weight - Double - Current average net weight.

44. countavg
Average Piece Count - Integer - Current average piece count.

45. freefall1
Free Fall 1 - Integer - Freefall 1 milliseconds.

46. freefall2
Free Fall 2 - Integer - Freefall 2 milliseconds.

47. futuregross1
Future Gross 1 - Double - Future gross 1 weight.

48. futuregross2
Future Gross 2 - Double - Future gross 2 weight.

49. futurenet1
Future Net 1 - Double - Future net 1 weight.

50. futurenet2
Future Net 2 - Double Future net 2 weight.

51. pcwtx1k
Current Piece Weight ∗ 1000.0 - Double - Current piece weight times 1000.

52. netmin
Minimum Net Weight - Double - Minimum recorded net weight on scale since last reset.

53. netmax
Maximum Net Weight - Double - Maximum recorded net weight on scale since last reset.

54. lastsample
Last Sample Size - Integer - Size of sample used to calculate piece weight.

3.21.2.14 awtx.weight.getCurrentUnits ( scaleNumber )


currentUnit = awtx.weight.getCurrentUnits(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, if left out is set to 0
for the active scale.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
140 Class Documentation

Returns

currentUnit - (Number) The currently selected weighing unit.

1 -- get the current unit number


2 currentUnit = awtx.weight.getCurrentUnits()
3 print(string.format("currentUnit = %d", currentUnit)) -- Prints to the Lua Console (located at Ztools ->
Zedit -> Output)

This function returns the currently selected weighing unit.


UNIT Definitions:
LB = 1
KG = 2
OZ = 3
GRAM = 4
LB_OZ = 5
CUSTOM UNIT1 = 6
CUSTOM UNIT2 = 7
CUSTOM UNIT3 = 8
CUSTOM UNIT4 = 9

3.21.2.15 awtx.weight.getInmotion ( scaleNumber )


returnVal = awtx.weight.getInmotion(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale is currently being used; if left out is set to 0 for
the active scale.

Returns

returnVal - (Number) Checks the status of the function to make sure the function is working correctly.

1 local scaleNumber = 1
2
3 local returnVal = awtx.weight.getInmotion(scaleNumber)
4 print(string.format("The status of the get inmotion weight function: %i", returnVal)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

This function gets the weight of an object that is moving.

3.21.2.16 awtx.weight.getLastPrint ( scaleNumber )


lastPrintTable = awtx.weight.getLastPrint(scaleNumber)

Parameters

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 141

scaleNumber - (Number) (Optional) The Scale number for which the last printed scale data is requested. If
not specified, the active scale will be used.

Returns

lastPrintTable - (Table) This is a Lua table containing a number of key - value pairs, containing the scale data
stored at the time of the last print.

1 local SCALE_1 = 1
2
3 -- This gets & prints out all the last printed Weight data for Scale 1
4 -- Contains around about 30 Individual Key-Value pairs
5
6 local lastPrintTable = awtx.weight.getLastPrint(SCALE_1)
7
8 for k,v in pairs(lastPrintTable) do
9 print(k,v) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
10 end

1 local SCALE_1 = 1
2 local lastPrintTable = awtx.weight.getLastPrint(SCALE_1)
3
4 -- This shows how to print a specific weight parameter from the Lua Table
5 print(string.format("Last Printed Tare Weight = %d %s", lastPrintTable.tare, lastPrintTable.unitsStr)) --
Prints to the Lua Console (located at Ztools -> Zedit -> Output)
6
7 --Example Print output
8
9 --Tare Weight = 2500 lb

This function returns a Lua Table containing a number of key value pairs containing a snapshot of the last printed
scale data.
Table for lastPrintTable (same data as format as awtx.weight.getCurrent())

1. gross
Gross Weight - Double - Current gross weight.

2. net
Net Weight - Double - Current net weight.

3. tare
Tare Weight - Double - Current tare weight.

4. units
Units of Measure - Integer - Represents the current unit of measure as an integer.

5. unitsStr
Units of Measure - String - Contains the current unit of measure as a string.

6. count
Piece Count - Integer - Current piece count (Net weight divided by Current Piece Weight).

7. motion
Motion - Boolean - True if scale is in motion, false if scale is stable.

8. centerZero
Center Zero - Boolean - True if scale is at center-zero.

9. underRange
Under Range Flag - Boolean - True if scale is in underload.

10. overRange
Over Range Flag - Boolean - True if scale is in overload.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
142 Class Documentation

11. min
Minimum - Double - Minimum recorded gross weight on scale since last reset.

12. max
Maximum - Double - Maximum recorded gross weight on scale since last reset.

13. roc
Rate of Change - Double - Current rate of change of the scale weight.

14. gtot
Gross Total - Double - Current total of gross weight values of all transactions since last reset.

15. ntot
Net Total - Double - Current total of net weight values of all transactions since last reset.

16. gtotcal
Gross Total Cal - Double - Current total of gross weight values in pounds of all transactions since last reset.

17. ntotcal
Net Total Cal - Double - Current total of net weight values in pounds of all transactions since last reset.

18. ctot
Count Total - Integer - Current total of piece count values of all transactions since last reset.

19. tran
Transaction Count - Integer - Current transaction count.

20. pcwt
Piece Weight - Double - Current piece weight being used to calculate the piece count.

21. adc
ADC Counts - Integer - ADC counts value coming from the scale ADC chip.

22. inGrossBand
In Gross Band - Boolean - True if weight is inside the cofigured gross zero band.

23. percent
Percent - Double - Current net weight divided by current tare weight as a percentage.

24. timestamp
Time Stamp - Integer - Seconds elapsed since 1/1/1970.

25. curUnitsFactor
Current Units Conversion - Double - Conversion factor used to convert pounds into the current unit of measure.

26. curCapacity
Current Capacity - Double - Configured capacity of the requested scale in the current unit of measure.

27. curDivision
Current Division - Double - Configured weight division resolution of the requested scale in the current unit of
measure.

28. curDigitsRight
Current Digits Right - Integer - Number of digits (precision) allowed to the right of the decimal in the current
division.

29. curDigitsLeft
Current Digits Left - Integer - Number of digits currently displayed to the left of the decimal on the requested
scale.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 143

30. curDigitsTotal
Current Digits Total - Integer - Number of total digits being displayed (including decimal, if applicable).

31. consecNumber
Consecutive Number - Integer - Internal scale object counter controlled by special print tokens.

32. inmotion
In-motion Weight - Double - Current in-motion weight.

33. target
Target - Double - Current target weight.

34. holdEnabled
Hold Enabled - Boolean - True if HOLD function is active.

35. holdCounts
Hold Counts - Integer - Counts value of the scale when HOLD function was enabled.

36. gtotpluscur
Gross Total plus Current - Double - Current gross total weight plus current gross weight.

37. gtotminuscur
Gross Total minus Current - Double - Current gross total weight minus current gross weight.

38. ntotpluscur
Net Total plus Current - Double - Current net total weight plus current net weight.

39. ntotminuscur
Net Total minus Current - Double - Current net total weight minus current net weight.

40. ctotpluscur
Count Total plus Current - Integer - Current piece count total weight plus current piece count.

41. ctotminuscur
Count Total minus Current - Integer - Current piece count total weight minus current piece count.

42. grossavg
Average Gross Weight - Double - Current average gross weight.

43. netavg
Average Net Weight - Double - Current average net weight.

44. countavg
Average Piece Count - Integer - Current average piece count.

45. freefall1
Free Fall 1 - Integer - Freefall 1 milliseconds.

46. freefall2
Free Fall 2 - Integer - Freefall 2 milliseconds.

47. futuregross1
Future Gross 1 - Double - Future gross 1 weight.

48. futuregross2
Future Gross 2 - Double - Future gross 2 weight.

49. futurenet1
Future Net 1 - Double - Future net 1 weight.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
144 Class Documentation

50. futurenet2
Future Net 2 - Double Future net 2 weight.

51. pcwtx1k
Current Piece Weight ∗ 1000.0 - Double - Current piece weight times 1000.

52. netmin
Minimum Net Weight - Double - Minimum recorded net weight on scale since last reset.

53. netmax
Maximum Net Weight - Double - Maximum recorded net weight on scale since last reset.

54. lastsample
Last Sample Size - Integer - Size of sample used to calculate piece weight.

If no print has occurred to populate the lastPrint snapshot, a one-time snapshot will be taken in this function call to
fill it and be returned.

3.21.2.17 awtx.weight.getNumActiveScales ( )
numActive = awtx.weight.getNumActiveScales()

Returns

numActive - (Number) The number of active scales available.

1 -- Find the amount of active scales


2
3 local numActive = awtx.weight.getNumActiveScales()
4 print(string.format("The number of active scales available is %i.", numActive))

This function finds all of the active scales and returns the amount of active scales there are.

3.21.2.18 awtx.weight.getPieceWeight ( )
pieceWeight = awtx.weight.getPieceWeight()

Returns

pieceWeight - (Table) The current piece weight the scale is using for counting mode operations.

1 -- This is a fully working if somewhat simplified example of how to do a piece weight sampling.
2
3 -- Print statements are outputted to the Lua Console (located at Ztools -> Zedit -> Output)
4 function sampleCompleteFunc (result, resultString)
5 print(string.format("Sample result=%d resultString=%s", result, resultString))
6
7 --print the new current piece weight. This will only be valid if the
8 --result argument = 0, otherwise the sampple didn’t complete successfully
9 print(string.format("Piece Weight is = %f", awtx.weight.getPieceWeight() ))
10 end
11
12 -- Ask the Scale to tell us when a Sample Request completes
13 awtx.weight.registerSampleCompleteEvent(sampleCompleteFunc)
14
15 -- set the current sample size to 100 items
16 result = awtx.weight.setSampleSize(100)
17
18 awtx.os.sleep(3000) -- Wait 3 seconds defore requesting a Sampling
19 awtx.weight.requestSample() -- Make the Sample Request

This function returns the current piece weight the scale is using for counting mode operations.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 145

3.21.2.19 awtx.weight.getRefreshLastPrint ( scaleNumber )


lastPrintTable = awtx.weight.getRefreshLastPrint(scaleNumber)

Parameters
scaleNumber - (Number) The scale number for which the weight data is required. Only Scale Number 1 is
currently supported.

Returns

lastPrintTable - (Table) This is a Lua table containing a number of key-value pairs, containing the current weight
data that was stored at the time of the last print.

1 local SCALE_1 = 1
2
3 -- This gets & prints out all the last refreshed printed Weight data for Scale 1
4 -- Contains around about 30 Individual Key-Value pairs
5
6 local lastPrintTable = awtx.weight.getRefreshLastPrint(SCALE_1)
7
8 for k,v in pairs(lastPrintTable) do
9 print(k,v) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)
10 end

1 local SCALE_1 = 1
2 local lastPrintTable = awtx.weight.getRefreshLastPrint(SCALE_1)
3
4 -- This shows how to print a specific weight parameter from the Lua Table
5 print(string.format("Last Printed Tare Weight = %d %s", lastPrintTable.tare, lastPrintTable.unitsStr)) --
Prints to the Lua Console (located at Ztools -> Zedit -> Output)
6
7 --Example Print output
8
9 --Tare Weight = 2500 lb

This function checks the parameters, then refreshes the last print snapshot then returns it into a Lua table.
Table for lastPrintTable

1. gross
Gross Weight - Double value of the total amount weight of an object.

2. net
Net Weight - Double value of the weight of the object that is being weighed minus the container it is located
in.

3. tare
Tare Weight - Double value of the weight container when empty.

4. units
Units of Measure - Integer value of the units of measure that the object is being measured in.

5. unitsStr
Units of Measure String - String value that is name of the units of measure itself. (Ex. Pounds/Lb)

6. count
Count - Double Value

7. motion
Motion - Boolean Value

8. centerZero
Center Zero - Boolean Value

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
146 Class Documentation

9. underRange
Under Range/Under Flag - Boolean value

10. overRange
Over Range/Over Flag - Boolean value

11. min
Minimum - Double Value

12. max
Maximum - Double value

13. roc
Rate of Change - Double value

14. gtot
Gross Total - Double value of the total amount of gross weight.

15. ntot
Net Total - Double value of the total amount of gross weight.

16. gtotcal
Gross Total Calculation - Double value of the calculated total of gross weight.

17. ntotcal
Net Total Calculation - Double value of the calculated total of net weight.

18. ctot
Count Total - Double value

19. tran
Transaction Count - Double value of the amount of objects passed onto the scale.

20. pcwt
Current Piece Weight - Double value of the weight of the object currently on the scale.

21. adc
Analog to Digital Convertter Counts - Double value

22. inGrossBand
In Gross Band. - Boolean value

23. percent
Percent - Double value

24. timestamp
Time Stamp - Integer value

25. curUnitsFactor
Current Units Conversion - Double value of the converted units of measure.

26. curCapacity
Current Capacity - Double value

27. curDivision
Current Division - Double value

28. curDigitsRight
Current Digits Right - Integer value

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 147

29. curDigitsLeft
Current Digits Left - Integer value

30. curDigitsTotal
Current Digits Total - Integer value

31. consecNumber
Transaction Count - Integer value

32. inmotion
Current In-motion Weight - Double value

33. target
Target - Double value of the desired weight of the objects.

34. holdEnabled
Hold Enabled - Double value

35. holdCounts
Hold Counts - Double value

36. gtotpluscur
Gross Total plus Current - Double value

37. gtotminuscur
Gross Total minus Current - Double value

38. ntotpluscur
Net Total plus Current - Double value

39. ntotminuscur
Net Total minus Current - Double value

40. ctotpluscur
Count Total plus Current - Double value

41. ctotminuscur
Count Total minus Current - Double Value

42. grossavg
Average Gross Weight - Double value

43. netavg
Average Net Weight - Double value

44. countavg
Average Weight Count - Double value

45. freefall1
Free Fall 1 - Double value

46. freefall2
Free Fall 2 - Double value

47. futuregross1
Future Gross 1 - Double value

48. futuregross2
Future Gross 2 - Double value

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
148 Class Documentation

49. futurenet1
Future Net 1 - Double value

50. futurenet2
Future Net 2 - Double value

51. pcwtx1k
Current Piece Weight ∗ 1000.0 - Double value

52. netmin
Minimum Net Weight - Double value

53. netmax
Maximum Net Weight - Double value

54. lastsample
Last Sample Size - Double value

3.21.2.20 awtx.weight.getSampleSize ( scaleNumber )


sampleCount = awtx.weight.getSampleSize(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, if left out is set to 0
for the active scale.

Returns

sampleCount - (Number) The current sample size the scale is using when taking piece weight samples.

1 -- This is a fully working if somewhat simplified example of how to do a piece weight sampling
2
3 -- get the current sample size
4 sampleCount = awtx.weight.getSampleSize()
5 print(string.format("Sample.Size = %d", sampleCount)) -- Prints to the Lua Console (located at Ztools ->
Zedit -> Output)

This function returns the current sample size the scale uses when taking piece weight samples. This will be an
integer value.

3.21.2.21 awtx.weight.getTarget ( scaleNumber )


target = awtx.weight.getTarget(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale's target to retreive; if left out the active scale
target is retreived.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 149

Returns

target - (Number) The current target weight of the scale.

1 local scaleNumber = 1
2
3 local target = awtx.weight.getTarget(scaleNumber)
4 print(string.format("The new target for scale number %i is %f", scaleNumber, target)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

This function gets the current target weight of the active scale.

3.21.2.22 awtx.weight.graphEnable ( scaleIndex , graphType )


awtx.weight.graphEnable(scaleIndex, graphType)

Parameters
scaleIndex - (Number) The number of the current active scale.
graphType - (Number) Specifies which graph it is that is set to be displayed.

1 local scaleIndex = 1
2 local graphType = 2
3
4 local newGraph = awtx.weight.graphEnable(scaleIndex, graphType)

This function enables the bargraph.


Values for graphType argument in function call are:
0 = Graph Off
1 = Checkweigh Mode, Graph off inside GZB
2 = Bargraph Mode, Graph off inside GZB
3 = Checkweigh Mode
4 = Bargraph Mode
5 = Checkweigh Mode, Graph off inside GZB, Outside 3 segments are ∗5 divisions
6 = Bargraph Mode, Graph off inside GZB
7 = Checkweigh Mode, Outside 3 segments are ∗5 divisions
8 = Bargraph Mode

3.21.2.23 awtx.weight.inmotion ( enable , startIO , stopIO ,


scaleNumber , multiplier )
awtx.weight.inmotion(enable, startIO, stopIO, scaleNumber, multiplier)

Parameters
enable - (Number) Controls whether movement will or will not happen.
startIO - (Number) Starts the movement of the object(s).

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
150 Class Documentation

stopIO - (Number) Stops the movement of the object(s).


scaleNumber - (Number) (Optional) Specifies which scale is currently being used; if left out is set to 0 for
the active scale.
multiplier - (Number) (Optional) Multiplies the speed of the object in motion.

1 -- Deals with inmotion weight.


2 awtx.weight.inmotion(enable, startIO, stopIO, scaleNumber, multiplier)
3 print(string.format("The scale with scale number %i is handling inmotion weight.", scaleNumber)) -- Prints
to the Lua Console (located at Ztools -> Zedit -> Output)

This function handles objects that are moving.

3.21.2.24 awtx.weight.registerAccumCompleteEvent ( callbackFunction


)
awtx.weight.registerAccumCompleteEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale calls when the Accumulate request has
completed.

1 -- This assumes the Print format and print device have already been set up
2
3 function onAccumComplete(resultInt, resultString)
4 print(string.format("Accum result=%d resultString=%s", resultInt, resultString)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)
5 end
6
7 -- Ask the Scale to tell us when a Accum Request completes
8 awtx.weight.registerAccumCompleteEvent(onAccumComplete)
9
10 awtx.os.sleep(3000) -- Wait 3 seconds before requesting a Accum
11 awtx.weight.requestAccum() -- Make the Accum Request

This function registers the callbackFunction argument to be called when an accumulation operation finishes.
When the callback function is called it is passed two parameters to indicate the result of the Accumulate operation.
Because of Lua's flexibility with function input parameters the programmer can choose to ignore one or even both
of these parameters if desired.
Values for accum resultInt are:
0 = ACCUM_NO_ERROR
1 = ACCUM_UNDERLOAD
2 = ACCUM_OVERLOAD
3 = ACCUM_RETURN_TO_ZERO
4 = ACCUM_NEGATIVE_WEIGHT
5 = ACCUM_MOTION
6 = ACCUM_DRIVER
7 = ACCUM_PENDING
8 = ACCUM_TOO_SOON
Values for accum resultString are:
0 = "ACCUM SUCCESS"
1 = "ACCUM UNDERLOAD"
2 = "ACCUM OVERLOAD"

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 151

3 = "ACCUM RETURN TO ZERO"


4 = "ACCUM NEGATIVE WEIGHT"
5 = "ACCUM MOTION"
6 = "ACCUM DRIVER"
7 = "ACCUM PENDING"
8 = "ACCUM TOO SOON"

3.21.2.25 awtx.weight.registerHoldCompleteEvent ( holdComplete )


awtx.weight.registerHoldCompleteEvent(holdComplete)

Parameters
holdComplete - (Function) The Lua callback function the scale calls when the hold request has completed.

1 function onHoldComplete (resultInt, resultString)


2 print(string.format("Hold Complete Result = %i, Hold Complete String = %s", resultInt, resultString)) --
Prints to the Lua Console (located at Ztools -> Zedit -> Output)
3 end
4
5 -- Asks the scale to tell us when a hold request completes.
6 awtx.weight.registerHoldCompleteEvent(onHoldComplete)
7
8 awtx.os.sleep(3000) -- System waits for 3 seconds
9 awtx.weight.requestHold() -- Make the hold request

This function registers the callbackFunction argument to be called when a hold operation finishes.
When the callback function is called it is passed two parameters to indicate the result of the Hold operation. Because
of Lua's flexibility with function input parameters the programmer can choose to ignore one or even both of these
parameters if desired.
Values for hold resultInt are:
0 = HOLD_NO_ERROR
1 = HOLD_MOTION
2 = HOLD_INVALID
3 = HOLD_DISABLED
4 = HOLD_PENDING
Values for hold resultString are:
0 = "HOLD SUCCESS"
1 = "HOLD MOTION"
2 = "HOLD INVALID"
3 = "HOLD DISABLED"
4 = "HOLD PENDING"

3.21.2.26 awtx.weight.registerInmotionCompleteEvent (
callbackFunction )
awtx.weight.registerInmotionCompleteEvent(callbackFunction)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
152 Class Documentation

Parameters
callbackFunction - (Function) The Lua callback function the scale calls when an in-motion process has com-
pleted.

1 function onInmotionComplete(scaleNumber)
2 print(string.format("Handled an in-motion complete event for scale %i", scaleNumber)) -- Prints to the
Lua Console (located at Ztools -> Zedit -> Output)
3 end
4
5 awtx.registerInmotionCompleteEvent(onInmotionComplete)

This function registers the callbackFunction argument to be called when an in-motion process completes.

3.21.2.27 awtx.weight.registerInmotionErrorEvent ( callbackFunction )


awtx.weight.registerInmotionErrorEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale calls when an in-motion error has occurred.

1 function onInmotionError(scaleNumber)
2 print(string.format("An in-motion error occurred on scale %i", scaleNumber)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)
3 end
4
5 awtx.registerInmotionErrorEvent(onInmotionError)

This function registers the callbackFunction argument to be called when an in-motion error occurs.

3.21.2.28 awtx.weight.registerInmotionStartEvent ( callbackFunction )


awtx.weight.registerInmotionStartEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale calls when an in-motion weighing event has
started.

1 function onInmotionStart(scaleNumber)
2 print(string.format("In-motion process started on scale %i", scaleNumber)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)
3 end
4
5 awtx.registerInmotionStartEvent(onInmotionStart)

This function registers the callbackFunction argument to be called when an in-motion weighing event has been
started.

3.21.2.29 awtx.weight.registerPrintCompleteEvent ( callbackFunction )


awtx.weight.registerPrintCompleteEvent(callbackFunction)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 153

Parameters
callbackFunction - (Function) The Lua callback function the scale calls when the Print request has completed.

1 -- This assumes the Print format and print device have already been set up
2
3 function onPrintComplete(resultInt, resultString)
4 print(string.format("Print result=%d resultString=%s", resultInt, resultString)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)
5 end
6
7 -- Ask the Scale to tell us when a Print Request completes
8 awtx.weight.registerPrintCompleteEvent(onPrintComplete)
9
10 awtx.os.sleep(3000) -- wait 3 seconds before requesting a Print
11 awtx.weight.requestPrint() -- Make the Print Request

This function sets the Lua callback function that should be called when a request Print operation completes.
When the callback function is called it is passed two parameters to indicate the result of the Print operation. Because
of Lua's flexibility with function input parameters the programmer can choose to ignore one or even both of these
parameters if desired.
Possible Print Complete resultInt values:
0 = "PRINT SUCCESS"
1 = "PRINT UNDERLOAD"
2 = "PRINT OVERLOAD"
3 = "PRINT RETURN_TO_ZERO"
4 = "PRINT MOTION"
5 = "PRINT DRIVER"
6 = "PRINT PENDING"
7 = "PRINT TOO SOON"
Values for Print resultString are:
0 = "PRINT SUCCESS"
1 = "PRINT UNDERLOAD"
2 = "PRINT OVERLOAD"
3 = "PRINT RETURN TO ZERO"
5 = "PRINT MOTION"
6 = "PRINT DRIVER"
7 = "PRINT PENDING"
8 = "PRINT TOO SOON"

3.21.2.30 awtx.weight.registerSampleCompleteEvent ( callbackFunction


)
awtx.weight.registerSampleCompleteEvent(callbackFunction)

Parameters

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
154 Class Documentation

callbackFunction - (Function) The Lua callback function the scale calls when a sample request has completed.

1 function onSampleComplete(resultInt, resultString)


2 print(string.format("Sample result=%d resultString=%s", resultInt, resultString)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)
3 end
4
5 -- Ask the Scale to tell us when a Sample Request completes
6 awtx.weight.registerSampleCompleteEvent(onSampleComplete)
7
8 awtx.os.sleep(3000) -- wait 3 seconds before requestion a Sample
9 awtx.weight.requestSample() -- Make the Sample Resquest

This function registers the callbackFunction argument to be called when a sample request operation finishes.
When the callback function is called it is passed two parameters to indicate the result of the sample operation.
Because of Lua's flexibility with function input parameters the programmer can choose to ignore one or even both
of these parameters if desired.
Values for sample resultInt are:
0 = SAMPLE_NO_ERROR
1 = SAMPLE_UNDERLOAD
2 = SAMPLE_OVERLOAD
3 = SAMPLE_MOTION
4 = SAMPLE_DRIVER
5 = SAMPLE_PENDING
6 = SAMPLE_ABORTED
7 = SAMPLE_SIZE
Possible Sample Complete Result values:
0 = "SAMPLE SUCCESS"
1 = "SAMPLE UNDERLOAD"
2 = "SAMPLE OVERLOAD"
3 = "SAMPLE MOTION"
4 = "SAMPLE DRIVER"
5 = "SAMPLE PENDING"
6 = "SAMPLE ABORTED"
7 = "SAMPLE SIZE"

3.21.2.31 awtx.weight.registerSelectCompleteEvent ( callbackFunction


)
awtx.weight.registerSelectCompleteEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale calls when a select request has completed.

1 function onSelectComplete(resultInt, resultString)


2 print(string.format("Select Complete result=%d resultString=%s", resultInt, resultString)) -- Prints to
the Lua Console (located at Ztools -> Zedit -> Output)
3 end
4
5 -- Ask the Scale to tell us when a Select Operation completes
6 awtx.weight.registerSelectCompleteEvent(onSelectComplete)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 155

This function registers the callbackFunction argument to be called when a select operation finishes.
When the callback function is called it is passed two parameters to indicate the result of the select operation.
Because of Lua's flexibility with function input parameters the programmer can choose to ignore one or even both
of these parameters if desired.
– All of these functions are valid
function onSelectComplete(resultInt, resultString) – Recommended form
end
function onSelectCompleteAlt1(resultInt)
end
function onSelectCompleteAlt2()
end
Possible Select Complete Result values:
0 = "SELECT SUCCESS"
1 = "SELECT INVALID"
2 = "SELECT DISABLED"

3.21.2.32 awtx.weight.registerTareCompleteEvent ( callbackFunction )


awtx.weight.registerTareCompleteEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale calls when the tare request has completed.

1 function onTareComplete(resultInt, resultString)


2 print(string.format("Tare result=%d resultString=%s", resultInt, resultString)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)
3 end
4
5 -- Ask the Scale to tell us when a Tare Request completes
6 awtx.weight.registerTareCompleteEvent(onTareComplete)
7
8 awtx.os.sleep(3000) -- wait 3 seconds before requesting a Tare
9 awtx.weight.requestTare() -- Make the Tare Request

This function registers the callbackFunction argument to be called when a tare operation finishes.
When the callback function is called it is passed two parameters to indicate the result of the Tare operation. Because
of Lua's flexibility with function input parameters the programmer can choose to ignore one or even both of these
parameters if desired.
– All of these functions are valid
function onTareComplete(result, resultString) – Recommended form
end
function onTareCompleteAlt1(result)
end
function onTareCompleteAlt2()
end
Values for tare resultInt are:
0 = TARE_NO_ERROR
1 = TARE_UNDERLOAD

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
156 Class Documentation

2 = TARE_OVERLOAD
3 = TARE_OVER_CAPACITY
4 = TARE_NEGATIVE
5 = TARE_MOTION
6 = TARE_DRIVER
7 = TARE_PENDING
8 = TARE_DISABLED
9 = TARE_OUTSIDE_GZB
Values for tare resultString are:
0 = "TARE SUCCESS"
1 = "TARE UNDERLOAD"
2 = "TARE OVERLOAD"
3 = "TARE OVER CAPACITY"
4 = "TARE NEGATIVE"
5 = "TARE MOTION"
6 = "TARE DRIVER"
7 = "TARE PENDING"
8 = "TARE DISABLED"
9 = "TARE OUTSIDE GZB"

3.21.2.33 awtx.weight.registerUnitsCompleteEvent ( callbackFunction )


awtx.weight.registerUnitsCompleteEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale calls when the units cycle request has com-
pleted.

1 function onUnitsComplete(resultInt, resultString)


2
3 print(string.format("Units Complete result=%d resultString=%s", resultInt, resultString)) -- Prints to
the Lua Console (located at Ztools -> Zedit -> Output)
4 end
5
6 -- Ask the Scale to tell us when a Unit change Request completes
7 awtx.weight.registerUnitsCompleteEvent(onUnitsComplete)

This function registers the callbackFunction argument to be called when a units cycle operation finishes.
The completion event may be a success or failure depending on a number of conditions within the Scale. When
the callback function is called it is passed two parameters to indicate the result of the operation. Because of Lua's
flexibility with function input parameters the programmer can choose to ignore one or even both of these parameters
if desired.
Values for units resultInt are:
0 = UNITS_NO_ERROR
1 = UNITS_INVALID
2 = UNITS_DISABLED
3 = UNITS_PENDING

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 157

4 = UNITS_NO_OTHER_UNIT
Values for units resultString are:
0 = "UNITS SUCCESS"
1 = "UNITS INVALID"
2 = "UNITS DISABLED"
3 = "UNITS PENDING"
4 = "UNITS NO OTHER UNIT"

3.21.2.34 awtx.weight.registerWeightChangeEvent ( callbackFunction )


awtx.weight.registerWeightChangeEvent(callbackFunction)

Parameters
callbackFunction - (Function) The function to call when the weight changes. The function is called with a single
argument containing the scale number.

1 -- Declare the event handler that will get called when the weight changes
2 function onWeightChange(scaleNum)
3 print("Handled a weight change event for scale " .. scaleNum) -- Prints to the Lua Console (located at
Ztools -> Zedit -> Output)
4 end
5
6 -- Register the event handler
7 awtx.weight.registerWeightChangeEvent(onWeightChange)

Registers a Lua event handler that will be called when the weight changes.
Depending on the system, this function has the possibility of being at a high frequency and could potentially affect
your system performance. Take this into consideration if you decide to make use of this event.
As with any event handler, the amount of work done inside the handler function should be minimal.

3.21.2.35 awtx.weight.registerZeroCompleteEvent ( callbackFunction )


awtx.weight.registerZeroCompleteEvent(callbackFunction)

Parameters
callbackFunction - (Function) The Lua callback function the scale calls when the Zero request has completed.

1 fucntion onZeroComplete(result, resultString)


2 print(string.format("Zero result=%d resultString=%s", result, resultString)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)
3 end
4
5 -- Register event handler to be called when a zero request completes.
6 awtx.weight.registerZeroCompleteEvent(onZeroComplete)
7
8 awtx.os.sleep(3000) -- wait 3 seconds before requesting the zero
9 awtx.weight.requestZero() -- Make the Zero Request

This function sets the callback function that should be called when a request Zero operation completes.
The completion event may be a success or failure depending on a number of conditions within the Scale. When
the callback function is called it is passed two parameters to indicate the result of the Zero operation. Because of
Lua's flexibility with the function input parameters the programmer can choose to ignore one or even both of these
parameters if desired.
Values for zero resultInt are:

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
158 Class Documentation

0 = ZERO_NO_ERROR
1 = ZERO_UNDERLOAD
2 = ZERO_OVERLOAD
3 = ZERO_RANGE
4 = ZERO_MOTION
5 = ZERO_DRIVER
6 = ZERO_PENDING
7 = ZERO_TARE_ACTIVE
Values for zero resultString are:
0 = "ZERO SUCCESS"
1 = "ZERO UNDERLOAD"
2 = "ZERO OVERLOAD"
3 = "ZERO RANGE"
4 = "ZERO MOTION"
5 = "ZERO DRIVER"
6 = "ZERO PENDING"
7 = "ZERO TARE ACTIVE"

3.21.2.36 awtx.weight.requestAccum ( scaleNumber )


awtx.weight.requestAccum(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, if left out is set to 0
for the active scale.

1 function accumCompleteFunc (result, resultString)


2 print(string.format("Accum. result=%d resultString=%s", result, resultString)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)
3 end
4
5 -- Ask the Scale to tell us when a Accumulate Request completes
6 awtx.weight.registerAccumCompleteEvent(accumCompleteFunc)
7
8 awtx.os.sleep(3000) -- wait 3 seconds before requesting a Tare
9 awtx.weight.requestAccum() -- Make the Accumulate Request

This function requests the Scale to add the current weight to the Accumulator store.
The Accumulate request itself may take some time to complete, for example it may have to wait for a stable weight.
Therefore the awtx.weight.requestAccum() function returns immediately to continue running the rest of the program.
If the programmer needs to know the result of the requestAccum() operation, he must subscribe to the accumulate
complete event by calling the awtx.weight.registerAccumCompleteEvent() function. Refer to the example for more
information.

3.21.2.37 awtx.weight.requestHold ( scaleNumber )


awtx.weight.requestHold(scaleNumber)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 159

Parameters
scaleNumber - (Number) (Optional) Specifies which scale to request the hold on; if left out hold is requested
on the active scale.

1 local scaleNumber = 1
2
3 awtx.weight.requestHold(scaleNumber)

This function requests a hold to be done on the current active scale.


HOLD is used to lock the scale at it's current weight. It can be useful when the scale platform is being moved but
the weight applied to the scale is not changing.

3.21.2.38 awtx.weight.requestKeyboardTare ( scaleNumber , newTare )


awtx.weight.requestKeyboardTare(scaleNumber, newTare)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, if left out is set to 0
for the active scale.
newTare - (Number) The new numeric Tare value required. This tare value is in the units of the active
Scale unit.

1 function tareCompleteFunc (result, resultString)


2 print(string.format("Tare result=%d, resultString=%s", result, resultString)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)
3 end
4
5 -- Ask the Scale to tell us when a Tare Request completes
6 awtx.weight.registerTareCompleteEvent(tareCompleteFunc)
7
8 awtx.os.sleep(3000) -- wait 3 seconds before requesting a Tare
9 awtx.weight.requestKeyboardTare(123.4) -- Make the Tare Request

This function requests the Scale to add the current weight to the Accumulator store.
This function emulates a tare as entered on the scale keyboard, so it compiles with the metrological requirements of
a keyboard entered tare. The tare request itself may take some time to complete, for example it may have to wait for
a stable weight. Therefore the awtx.weight.requestKeyboardTare() function returns immediately to continue running
the rest of the program. If the programmer needs to know the result of the requestKeyboardTare() operation, he
must subscribe to the tare complete event by calling the awtx.weight.registerTareCompleteEvent() function. Refer
to the example for more information.

3.21.2.39 awtx.weight.requestPresetTare ( scaleNumber , newTare )


awtx.weight.requestPresetTare(scaleNumber, newTare)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, if left out is set to 0
for the active scale.
newTare - (Number) The new numeric Tare value required. This tare value is in the units of the active
Scale unit.

1 function tareCompleteFunc (result, resultString)


2 print(string.format("Tare result=%d, resultString=%s", result, resultString)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)
3 end
4

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
160 Class Documentation

5 -- Ask the Scale to tell us when a Tare Request completes


6 awtx.weight.registerTareCompleteEvent(tareCompleteFunc)
7
8 awtx.os.sleep(3000) -- wait 3 seconds before requesting a Tare
9 awtx.weight.requestPresetTare(123.4) -- Make the Tare Request

This function requests the Scale to tare off the numeric tare value specified in the input parameter.
This function emulates a tare as entered on the scale keyboard, so it compiles with the metrological requirements
of a present tare. The tare request itself may take some time to complete, for example it may have to wait for a
stable weight. Therefore the awtx.weight.requestKeyboardTare() function returns immediately to continue running
the rest of the program. If the programmer needs to know the result of the requestPresetTare() operation, he must
subscribe to the tare complete event by calling the awtx.weight.registerTareCompleteEvent() function. Refer to the
example for more information.

3.21.2.40 awtx.weight.requestPrint ( scaleNumber )


awtx.weight.requestPrint(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, if left out is set to 0
for the active scale.

1 function printCompleteFunc (result, resultString)


2 print(string.format("Print result=%d, resultString=%s", result, resultString)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)
3 end
4
5 -- Ask the Scale to tell us when a Print Request completes
6 awtx.weight.registerTareCompleteEvent(printCompleteFunc)
7
8 awtx.os.sleep(3000) -- wait 3 seconds before requesting a Tare
9 awtx.weight.requestKeyboardTare(123.4) -- Make the Tare Request

This function requests the Scale to initiate a Print to the configured Printer Device.
The Print request itself may take some time to complete, for example it may have to wait for a stable weight.
Therefore the awtx.weight.requestPrint() function returns immediately to continue running the rest of the program.
If the programmer needs to know the result of the requestPrint() operation, he must subscribe to the Print complete
event be calling the awtx.weight.registerPrintCompleteEvent() function. Refer to the example for more information.

3.21.2.41 awtx.weight.requestSample ( scaleNumber , mode )


awtx.weight.requestSample(scaleNumber, mode)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, if left out is set to 0
for the active scale.
mode - (Number) The mode selected for counting PCWT piece weight. Two possible values
accepted: 1 for dribble method or 2 for bulk method.

1 function onSampleComplete (result, resultString)


2 print(string.format("Sample result=%d resultString=%s", result, resultString)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)
3 end
4
5 -- Ask the Scale to tell us when a Sample Request completes
6 awtx.weight.registerSampleCompleteEvent(onSampleComplete)
7
8 awtx.os.sleep(3000) -- wait 3 seconds before requesting a Sample
9 awtx.weight.requestSample(1) -- Make the Sample Request

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 161

This function requests the Scale to sample the current weight to determine a counting mode piece weight.
The sample request weighs the item(s) over a period of time and averages the results to obtain a stable and
very accurate piece weight. Therefore the awtx.weight.requestSample() function returns immediately to continue
running the rest of the program. If the programmer needs to know the result of the requestSample() operation, he
must subscribe to the accumulate complete event by calling the awtx.weight.onSampleComplete() function. Refer
to the example for more information.

3.21.2.42 awtx.weight.requestTare ( scaleNumber )


awtx.weight.requestTare(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, set to the current
active scale if left out.

1 function tareCompleteFunc (result, resultString)


2 print(string.format("Tare result=%d resultString=%s", result, resultString)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)
3 end
4
5 -- Ask the Scale to tell us when a Tare Request completes
6 awtx.weight.registerTareCompleteEvent(tareCompleteFunc)
7
8 awtx.os.sleep(3000) -- wait 3 seconds before requesting a Tare
9 awtx.weight.requestTare() -- Make the Tare Request

This function requests the Scale to tare off the current displayed weight.
The tare request itself may take some time to complete, for example it may have to wait for a stable weight. There-
fore the awtx.weight.requestTare() function returns immediately to continue running the rest of the program. If the
programmer needs to know the result of the requestTare() operation, he must subscribe to the tare complete event
by calling the awtx.weight.registerTareCompleteEvent() function. Refer to the example for more information.

3.21.2.43 awtx.weight.requestTareClear ( scaleNumber )


awtx.weight.requestTareClear(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used; if left out is set to 0
for the active scale.

1 local scaleNumber = 1
2
3 awtx.weight.requestTareClear(scaleNumber)
4 print(string.format("The scale with scale number %i has requested a tare weight to be cleared.",
scaleNumber)) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)

This function clears a tare that has been stored on the current active scale.

3.21.2.44 awtx.weight.requestZero ( scaleNumber )


awtx.weight.requestZero(scaleNumber)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
162 Class Documentation

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, set to the current
active scale if left out.

1 function zeroCompleteFunc (result, resultString)


2 print(string.format("Zero result=%d resultString=%s", result, resultString)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)
3 end
4
5 -- Ask the Scale to tell us when a Tare Request completes
6 awtx.weight.registerZeroCompleteEvent(zeroCompleteFunc)
7
8 awtx.os.sleep(3000) -- wait 3 seconds before requesting a Zero Balance Operation
9 awtx.weight.requestZero() -- Make the Zero Request

This function requests the Scale to zero off the current weight.
The zero balance request itself may take some time to complete, for example it may have to wait for a stable weight.
Therefore the awtx.weight.requestZero() function returns immediately to continue running the rest of the program.
If the programmer needs to know the result of the requestZero() operation, he must subscribe to the Zero complete
event by calling the awtx.weight.registerZeroCompleteEvent() function. Refer to the example for more information.

3.21.2.45 awtx.weight.requestZeroCheckWeigh ( scaleNumber )


awtx.weight.requestZeroCheckWeigh(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used; if left out is set to 0
for the active scale.

1 local scaleNumber = 1
2
3 awtx.weight.requestZeroCheckWeigh(scaleNumber)
4 print(string.format("The scale with scale number %i has requested a zero check weight.", scaleNumber)) --
Prints to the Lua Console (located at Ztools -> Zedit -> Output)

This function requests the scale to zero off the check weight.

3.21.2.46 awtx.weight.resetAccum ( scaleNumber )


awtx.weight.resetAccum(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, set to the current
active scale if left out.

1 -- reset the Accumulation stores to zero values


2 awtx.weight.resetAccum()

This function resets the individual totals in the Scale's Accumulation store to zero (Gross Weight, Net Weight, Count
& Transaction count)

3.21.2.47 awtx.weight.resetPeakMax ( scaleNumber )


awtx.weight.resetPeakMax(scaleNumber)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 163

Parameters
scaleNumber - (Number) (Optional) Specifies which scale is currently being used; if left out is set to 0 for
the active scale

1 awtx.weight.resetPeakMax(scaleIndex)
2 print(string.format("Reset the peak maximum value for the scale at index %i", scaleIndex)) -- Prints to the
Lua Console (located at Ztools -> Zedit -> Output)

This function resets the maximum peak value of the active scale.

3.21.2.48 awtx.weight.resetPeakMin ( scaleNumber )


awtx.weight.resetPeakMin(scaleNumber)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale is currently being used; if left out is set to 0 for
the active scale

1 awtx.weight.resetPeakMin(scaleIndex)
2 print(string.format("Reset the peak minimum value for the scale at index %i", scaleIndex)) -- Prints to the
Lua Console (located at Ztools -> Zedit -> Output)

This function resets the minimum peak value of the current active scale.

3.21.2.49 awtx.weight.scaleEnabled ( scaleNumber )


returnVal = awtx.weight.scaleEnabled(scaleNumber)

Parameters
scaleNumber - (Number) Specifies which scale is currently being used.

Returns

returnVal - (Number) Checks to see if the function has worked correctly.

1 local scaleNumber = 1
2
3 local returnVal = awtx.weight.scaleEnabled(scaleNumber)
4 print(string.format("The status of the scale enabled function: %i", returnVal)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

This function enables a scale as the current active scale.

3.21.2.50 awtx.weight.setAccum ( scaleNumber , grosswtTot , netwtTot


, newTare , countTot )
awtx.weight.setAccum(scaleNumber, grosswtTot, netwtTot, newTare, countTot)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
164 Class Documentation

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, set to the current
active scale if left out.
grosswtTot - (Number) The new value for the accumulation store's gross weight total.
netwtTot - (Number) The new value for the accumulation store's net weight total.
newTare - (Number) The new value for the accumulation store's count total.
countTot - (Number) The new value for the accumulation store's transaction count total.

1 -- Set the Accumulation store to some predefined values


2
3 awtx.weight.setAccum(1000.0, 200.0, 10, 2)

This function sets the individual totals in the Scale's Accumulation store to the values specified by the function
arguments.

3.21.2.51 awtx.weight.setActiveScale ( scaleNumber )


returnVal = awtx.weight.setActiveScale(scaleNumber)

Parameters
scaleNumber - (Number) The current scale that is active.

Returns

returnVal - (Number) Checks the status of the function to see if it is functioning correctly.

1 local scaleNumber = awtx.weight.getActiveScale()


2 local returnVal = awtx.weight.setActiveScale()
3 print(string.format("%i is the status of the set active scale.", returnVal)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This sets the scale that is currently in use as the active scale.

3.21.2.52 awtx.weight.setActiveValue ( setActive )


activeValue = awtx.weight.setActiveValue(setActive)

Parameters
setActive - (Number) The value that is going to be set as the new active value.

Returns

activeValue - (Number) Snapshot of the current active value in the scale.

1 local setActive = awtx.weight.getActiveValue()


2
3 local activeValue = awtx.weight.setActiveVale(setActive)
4 print(string.format("The current active value of the scale is: %i", activeValue)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

This function sets the new active value for the scale.
If the setActive value does not get set as the new active value for any reason, the system goes back to the original
active value and keeps that set as the current active value.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 165

3.21.2.53 awtx.weight.setBar ( scaleIndex , basis , minWt , maxWt )


awtx.weight.setBar(scaleIndex, basis, minWt, maxWt)

Parameters
scaleIndex - (Number) The number of the current active scale.
basis - (Number) index of the value type the graph is based on.
minWt - (Number) The weight value representing 0% on the bar graph.
maxWt - (Number) The weight value representing 100% on the bar graph.

1 awtx.weight.setBar(scaleIndex, basis, minWt, maxWt)


2 print(string.format("Set the bar for the scale at index %i", scaleIndex)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function sets up a minimum and maximum weight to be measured on a bar graph.
Values for basis argument in function call are:
0 = Gross
1 = Net
2 = Tare
3 = Minimum
4 = Maximum
5 = Rate-of-Change
6 = Gross Total
7 = Net Total
8 = Tare Total
9 = Count Total
10 = Transaction Count
11 = Piece Count
12 = Lua Var
13 = Piece Weight
14 = ADC Counts
∗see ReqConstants.lua - SCALE VALUES section for additional options.

3.21.2.54 awtx.weight.setCheck ( scaleIndex , basis , minWt , underWt


, overWt , maxWt , underDiv , overDiv )
awtx.weight.setCheck(scaleIndex, basis, minWt, underWt, overWt, maxWt, underDiv, overDiv)

Parameters
scaleIndex - (Number) Measure type for the scale.
basis - (Number) Base number the scale begins on.
minWt - (Number) The minimum set weight value that is set to the scale that objects should meet.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
166 Class Documentation

underWt - (Number) Value of the object that is below the minimum weight threshold.
overWt - (Number) Value of the object that is above the maximum weight threshold.
maxWt - (Number) The maximum set weight value that is set to the scale that objects should meet.
underDiv - (Number) Value under divider.
overDiv - (Number) Value over divider.

1 awtx.weight.setCheck(scaleIndex, basis, minWt, underWt, overWt, maxWt, underDiv, overDiv)


2 print(string.format("Set the check value for the scale at index %i", scaleIndex)) -- Prints to the Lua
Console (located at Ztools -> Zedit -> Output)

This function checks the values that are being put into the system.

3.21.2.55 awtx.weight.setConfig ( scaleNumber , paramTable )


returnVal, messageReturn = awtx.weight.setConfig(scaleNumber, paramTable)

Parameters
scaleNumber - (Number) Specifies which scale that is currently being used. Currently, this value is always
equal to 1.
paramTable - (Table) Lua table full of parameters to be used.

Returns

returnVal - (Number) Checks to see whether the function worked correctly or not.
messageReturn - (String) Message associated with the returnVal value.

1 local scaleNum = 1
2 local paramTable = {key, value};
3 local messageReturn = ""
4
5 local returnVal = awtx.weight.setConfig(scaleNum, paramTable)
6
7 -- Print statements output to the Lua Console (located at Ztools -> Zedit -> Output)
8 if returnVal == 0 then
9 messageReturn = "SUCCESS"
10 print(string.format("The setting of the configuration was: %i %s", returnVal, messageReturn))
11 elseif returnVal == -1 then
12 messageReturn = "Error: Setpoint set takes 2 parameters"
13 print(returnVal, " : ", messageReturn)
14 else --Else if statements would continue from here until all messages desired were created.
15 messageReturn = "Error"
16 print(returnVal, messageReturn)
17 end

This function sets the scale data from a passed in table.


Values for returnVal and messageReturn
0 = SUCCESS
-1 = Error: Setpoint set takes 2 parameters
-2 = Error: Setpoint parameter 1 must be a number
-3 = Error: Scale number must be between 1 and 1
-4 = Error: Config parameter 2 must be a table
-5 = Error: Config key must be a string.
-6 = Error: Config value must be a string or a number

3.21.2.56 awtx.weight.setCurrentUnits ( scaleNumber , newUnit )


Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 167

lastUnit = awtx.weight.setCurrentUnits(scaleNumber, newUnit)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, set to the current
active scale if left out.
newUnit - (Number) The unit number of the desired new unit.

Returns

lastUnit - (Number) The unit number that was in effect prior to the unit switch. This function will return -1 if the
new unit is not allowed with the current Scale configuration.

1 -- set the new weighing unit to be kg


2 local newUnit = 2
3 local lastUnit = awtx.weight.setCurrentUnits(newUnit)
4 print(string.format("lastUnit = %d newUnit = %d", lastUnit, newUnit)) -- Prints to the Lua Console (located
at Ztools -> Zedit -> Output)

This function switches the weighing units to the type specified in the input parameter.
If the newly selected unit is invalid, the function will return -1. For the newUnit to be valid it must be one of the units
that were defined as usable during the Scale's original set-up and calibration.

3.21.2.57 awtx.weight.setDisplayVariable ( displayVariable , legend1 ,


legend2 , precision , scaleNumber , motionVar , centerZero )
awtx.weight.setDisplayVariable(displayVariable, legend1, legend2, precision, scaleNumber, motionVar, centerZero)

Parameters
displayVariable - (String) This is the variable being set up through the function.
legend1 - (String) Gives info about the display variable.
legend2 - (String) Gives even more info about the display variable.
precision - (Number) Says how precise to make the display variable.
scaleNumber - (Number) (Optional) Specifies which scale is currently being used; if left out is set to 0 for
the active scale.
motionVar - (String) Determines if the variable is an inmotion variable.
centerZero - (String) Determines if it is a Center of Zero variable.

1 awtx.weight.setDisplayVariable(displayVariable, legend1, legend2, precision, scaleNumber, motionVar,


centerZero)
2 print(string.format("Set up the display variables for the scale with %i as the scale number", scaleNumber))
-- Prints to the Lua Console (located at Ztools -> Zedit -> Output)

This function sets up the display variable for the current active scale.

3.21.2.58 awtx.weight.setPieceWeight ( scaleNumber , pieceWeight )


result = awtx.weight.setPieceWeight(scaleNumber, pieceWeight)

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
168 Class Documentation

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, set to the current
active scale if left out.
pieceWeight - (Number) The new current piece weight that the Scale should use for counting mode oper-
ations.

Returns

result - (Number) Returns 0 for success, else -1 if the input parameter is in error.

1 -- set the current PieceWeight


2 result = awtx.weight.setPieceWeight(100)

This function sets the new current piece weight that the Scale should use for counting mode operations. The current
active units will be used to determine the units of the new piece weight.
Valid range for pieceWeight is 0.00001 to 10,000

3.21.2.59 awtx.weight.setSampleSize ( scaleNumber , itemCount )


result = awtx.weight.setSampleSize(scaleNumber, itemCount)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, set to the current
active scale if left out.
itemCount - (Number) The number of items that are being weighted during the piece weight sampling
operation. Valid range is 1 to 10,000.

Returns

result - (Number) Returns 0 for success, else -1 if the input parameter is in error.

1 -- set the current sample size


2 result = awtx.weight.setSampleSize(100)

This function sets the current sample size the scale will use when taking piece weight samples. This must be an
integer value.

3.21.2.60 awtx.weight.setTarget ( scaleNumber , newTarget )


status = awtx.weight.setTarget(scaleNumber, newTarget)

Parameters
scaleNumber - (Number) (Optional) Specifies which scale is currently being used; if left out is set to 0 for
the current active scale.
newTarget - (Number) Value that is going to be set as the new target value for the scale.

Returns

status - (Number) Checks the status of the function; if 0 then it was a success, if it was a non zero then it was
an error.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 169

1 local scaleNumber = 1
2
3 local target = awtx.weight.getTarget(scaleNumber)
4 local status = awtx.weight.setTarget(scaleNumber, target)
5 print(string.format("The status of the set target function is: %i", status)) -- Prints to the Lua Console
(located at Ztools -> Zedit -> Output)

This function gets the wanted target value and sets it as the target weight value for the current active scale.

3.21.2.61 awtx.weight.unitStrToUnitIndex ( unitStr )


returnVal, unitEnum = awtx.weight.unitStrToUnitIndex(unitStr)

Parameters
unitStr - (String) Value that an item is being measured in. Can be in 'lb', or 'kg', etc.

Returns

returnVal - (Number) Result status of the function.


unitEnum - (String) New unit of measure that has been applied.

1 local returnVal, unitEnum = awtx.weight.unitStrToUnitIndex(unitStr)


2
3 print(string.format("The status of the units conversion is %i and they were converted to %s", returnVal,
unitEnum)) -- Prints to the Lua Console (located at Ztools -> Zedit -> Output)

Converts a Unit string into an index unit.

3.21.2.62 awtx.weight.unregisterAccumCompleteEvent ( )
awtx.weight.unregisterAccumCompleteEvent()

1 -- Clear a previous Accumulate Complete registered callback


2 awtx.weight.unregisterAccumCompleteEvent()

This function unregisters a previously set Accumulate complete callback function. After this unregister function is
called, no further Accumulate complete events will call the Lua handler function.

3.21.2.63 awtx.weight.unregisterHoldCompleteEvent ( )
result = awtx.weight.unregisterHoldCompleteEvent()

Returns

result - (Number) Status check to see if the function worked correctly. Returns 0 if successfull, else returns a
non-zero value indicating an error.

1 local unregisterResult = awtx.weight.unregisterHoldCompleteEvent()


2 print(string.format("The status of the unregister hold complete event is: %i", unregisterResult)) -- Prints
to the Lua Console (located at Ztools -> Zedit -> Output)

This function unregisters the hold complete events from the system.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
170 Class Documentation

3.21.2.64 awtx.weight.unregisterInmotionCompleteEvent ( )
awtx.weight.unregisterInmotionCompleteEvent()

1 -- Clears a previous Inmotion complete event registered callback


2 awtx.weight.unregisterInmotionCompleteEvent()

This function removes the registry of the Inmotion complete event from the system memory.

3.21.2.65 awtx.weight.unregisterInmotionErrorEvent ( )
awtx.weight.unregisterInmotionErrorEvent()

1 -- Clears a previous inmotion error event registered callback


2 awtx.unregisterInmotionErrorEvent()

This function removes the registry of the inmotion error event from the system memory.

3.21.2.66 awtx.weight.unregisterInmotionStartEvent ( )
awtx.weight.unregisterInmotionStartEvent()

1 -- Clears a previous Inmotion start event registered callback.


2 awtx.weight.unregisterInmotionStartEvent()

This function removes the registry of the inmotion start event.

3.21.2.67 awtx.weight.unregisterPrintCompleteEvent ( )
awtx.weight.unregisterPrintCompleteEvent()

1 -- Clear a previous Print Complete registered callback


2 awtx.weight.unregisterPrintCompleteEvent()

This function unregisters a previously set Print complete callback function. After this unregister function is called,
no further Print complete events will call the Lua handler function.

3.21.2.68 awtx.weight.unregisterSampleCompleteEvent ( )
awtx.weight.unregisterSampleCompleteEvent()

1 -- Clear a previous Sample Complete registered callback


2 awtx.weight.unregisterSampleCompleteEvent()

This function unregisters a previously set Sample complete callback function. After this unregister function is called,
no further Sample complete events will call the Lua handler function.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
3.21 weight Class Reference 171

3.21.2.69 awtx.weight.unregisterSelectCompleteEvent ( )
awtx.weight.unregisterSelectCompleteEvent()

1 -- Clear a previous Select Complete registered callback


2 awtx.weight.unregisterSelectCompleteEvent()

This function unregisters a previously set Select complete callback function. After this unregister function is called,
no further Select complete events will call the Lua handler function.

3.21.2.70 awtx.weight.unregisterTareCompleteEvent ( )
awtx.weight.unregisterTareCompleteEvent()

1 -- Clear a previous Tare Complete registered callback


2 awtx.weight.unregisterTareCompleteEvent()

This function unregisters a previously set Tare complete callback function. After this unregister function is called, no
further Tare complete events will call the Lua handler function.

3.21.2.71 awtx.weight.unregisterUnitsCompleteEvent ( )
awtx.weight.unregisterUnitsCompleteEvent()

1 -- Clear a previous Units Complete registered callback


2 awtx.weight.unregisterUnitsCompleteEvent()

This function unregisters a previously set Units complete callback function. After this unregister function is called,
no further Units complete events will call the Lua handler function.

3.21.2.72 awtx.weight.unregisterWeightChangeEvent ( )
awtx.weight.unregisterWeightChangeEvent()

1 -- unregisters any existing event handler


2 awtx.weight.unregisterWeightChangeEvent()

Unregisters a Lua event handler that has already been registered.


This function has no effect there is no registered function.

3.21.2.73 awtx.weight.unregisterWeightUpdateEvent ( )
awtx.weight.unregisterWeightUpdateEvent()

1 -- Clear a previous Weight update event registered callback


2 awtx.weight.unregisterWeightUpdateEvent()

This function unregisters a previously set weight update event callback function. After this unregister function is
called, no further weight update events will call the Lua handler function.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
172 Class Documentation

3.21.2.74 awtx.weight.unregisterZeroCompleteEvent ( )
awtx.weight.unregisterZeroCompleteEvent()

1 -- Clear a previous Zero Complete registered callback


2 awtx.weight.unregisterZeroCompleteEvent()

This function unregisters a previously set Zero complete callback function. After this unregister function is called,
no further Zero complete events will call the Lua handler function.

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
Index

activate convertFromInternalCalUnit
setpoint, 103 weight, 130
addControl convertTableToCsvFile_LUA
screensCtrl, 93 os, 68
applicationPath convertToInternalCalUnit
os, 66 weight, 131
convertWeight
buttonCtrl, 5 weight, 132
getLocation, 5 copyFile
getText, 6 os, 68
getVisible, 6 cpuIdleFactor
reSize, 6 os, 69
setFont, 7 createTable
setLocation, 7 variables, 124
setText, 7 createTimer
setVisible, 8 os, 69
cycleActiveScale
charToCodePoint weight, 132
utf8, 120 cycleActiveValue
checksumFile weight, 133
os, 66 cycleUnits
circle weight, 133
graphics, 26
clearInmotion deactivate
weight, 130 setpoint, 106
clearScreen decode
graphics, 26 json, 39
clearTable deleteDirectory
variables, 123 os, 70
close deleteFile
serial, 94 os, 70
clrDisplayBusy deleteFolderAndFiles
display, 9 os, 70
graphics, 26 deleteTable
clrDisplayFlash variables, 124
display, 10 display, 8
clrSegments clrDisplayBusy, 9
display, 10 clrDisplayFlash, 10
compareDelta clrSegments, 10
os, 67 doBeep, 11
configRpn getBatteryControl, 11
keypad, 42 getBuzzer, 11
configure getBuzzerEnable, 11
setpoint, 103 getGraphControl, 12
configureRateOfChange getLabelControl, 12
weight, 130 getMode, 12
connected getScaleControl, 13
socket, 113 getSetpointControl, 13
convertCsvFileToTable_LUA setBuzzer, 13
os, 67 setBuzzerEnable, 14
174 INDEX

setDisplayBusy, 14 getActiveValue
setDisplayFlash, 14 weight, 134
setMode, 14 getBatteryControl
setOneSegment, 15 display, 11
setSegment, 16 getBuzzer
setSegments, 17 display, 11
writeLine, 18 getBuzzerEnable
doBeep display, 11
display, 11 getCalibWeightUnits
drawLine weight, 134
graphics, 27 getConfig
drawText weight, 134
graphics, 27 getConnectString
serial, 95
encode getCurrent
json, 39 weight, 136
enterCheckWt getCurrentUnits
keypad, 42 weight, 139
enterCheckWtWithUnits getEomChar
keypad, 43 serial, 95
enterDate socket, 113
keypad, 44 getGraphControl
enterFloat display, 12
keypad, 45
getInactivityShutdownTime
enterInteger
hardware, 34
keypad, 46
getInmotion
enterIpAddress
weight, 140
keypad, 46
getInputPollPeriod
enterString
ports, 83
keypad, 47
getInputs
enterTime
ports, 84
keypad, 47
getInverted
enterWeightWithUnits
setpoint, 107
keypad, 48
getLabelControl
equateDelta
display, 12
os, 71
getLastPrint
fillCircle weight, 140
graphics, 27 getLocation
fillQuadrant buttonCtrl, 5
graphics, 28 labelCtrl, 61
fillRect pictureboxCtrl, 81
graphics, 28 scaleCtrl, 90
findFile textboxCtrl, 117
os, 71 getMaxOptionBusCount
fmtPrint, 18 hardware, 35
get, 19 getMaxOptionCardCount
getRaw, 19 hardware, 35
printBuffer, 20 getMaxPorts
registerVarChangeReqEvent, 20 serial, 96
set, 21 getMaxSockets
unregisterVarChangeReqEvent, 22 socket, 113
varGet, 22 getMode
varSet, 23 display, 12
getNumActiveScales
get weight, 144
fmtPrint, 19 getOutputs
getActiveScale ports, 84
weight, 133 getPieceWeight

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
INDEX 175

weight, 144 moveTo, 29


getRaw picturebox.new, 29
fmtPrint, 19 putPixel, 30
getRefreshLastPrint quadrant, 30
weight, 144 rFillRect, 31
getRpnMode rRect, 31
keypad, 49 rect, 30
getRx screens.new, 32
serial, 96 setActiveScreen, 32
socket, 113 setDisplayBusy, 32
getRxCount setInverted, 33
serial, 97 setMode, 33
socket, 114
getSMATimeout hardware, 33
serial, 97 getInactivityShutdownTime, 34
getSampleSize getMaxOptionBusCount, 35
weight, 148 getMaxOptionCardCount, 35
getScaleControl getShutdownEnable, 35
display, 13 getSystem, 35
getSealedStatus reboot, 36
os, 72 registerShutdownEvent, 36
getSetpointControl setInactivityShutdownTime, 37
display, 13 setShutdownEnable, 37
getShutdownEnable setShutdownVoltage, 38
hardware, 35 unregisterShutdownEvent, 38
getState
inmotion
setpoint, 107
weight, 149
getSystem
isLegalUtf8Char
hardware, 35
utf8, 121
getTarget
isLegalUtf8String
weight, 148
utf8, 121
getText
buttonCtrl, 6 json, 38
labelCtrl, 61 decode, 39
textboxCtrl, 117 encode, 39
getVersion
os, 72 KEY_F1_DOWN
getVersionInfo keypad, 49
os, 73 KEY_F1_REPEAT
getVisible keypad, 50
buttonCtrl, 6 KEY_F1_UP
labelCtrl, 61 keypad, 50
pictureboxCtrl, 82 KEY_NUMERIC_DOWN
scaleCtrl, 90 keypad, 50
textboxCtrl, 118 KEY_NUMERIC_REPEAT
graphEnable keypad, 51
weight, 149 KEY_NUMERIC_UP
graphics, 25 keypad, 51
circle, 26 KEY_PRINT_DOWN
clearScreen, 26 keypad, 51
clrDisplayBusy, 26 KEY_PRINT_REPEAT
drawLine, 27 keypad, 52
drawText, 27 KEY_PRINT_UP
fillCircle, 27 keypad, 52
fillQuadrant, 28 KEY_SELECT_DOWN
fillRect, 28 keypad, 52
label.new, 28 KEY_SELECT_REPEAT
lineTo, 29 keypad, 53

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
176 INDEX

KEY_SELECT_UP unregisterRpnEvent, 59
keypad, 53 killTimer
KEY_TARE_DOWN os, 73
keypad, 53
KEY_TARE_REPEAT label.new
keypad, 54 graphics, 28
KEY_TARE_UP labelCtrl, 60
keypad, 54 getLocation, 61
KEY_UNITS_DOWN getText, 61
keypad, 54 getVisible, 61
KEY_UNITS_REPEAT reSize, 62
keypad, 55 setFont, 62
KEY_UNITS_UP setLocation, 62
keypad, 55 setText, 63
KEY_ZERO_DOWN setVisible, 63
keypad, 56 length
KEY_ZERO_REPEAT utf8, 121
keypad, 56 lineTo
KEY_ZERO_UP graphics, 29
keypad, 56 listDirectory
keypad, 40 os, 74
configRpn, 42 lockOff
enterCheckWt, 42 setpoint, 107
lockOn
enterCheckWtWithUnits, 43
setpoint, 108
enterDate, 44
logThisError
enterFloat, 45
os, 74
enterInteger, 46
enterIpAddress, 46
makeDirectory
enterString, 47
os, 74
enterTime, 47
memoryMaxUsage
enterWeightWithUnits, 48
os, 75
getRpnMode, 49
memoryTest
KEY_F1_DOWN, 49
os, 75
KEY_F1_REPEAT, 50
moveFile
KEY_F1_UP, 50
os, 76
KEY_NUMERIC_DOWN, 50 moveTo
KEY_NUMERIC_REPEAT, 51 graphics, 29
KEY_NUMERIC_UP, 51
KEY_PRINT_DOWN, 51 open
KEY_PRINT_REPEAT, 52 serial, 97
KEY_PRINT_UP, 52 os, 63
KEY_SELECT_DOWN, 52 applicationPath, 66
KEY_SELECT_REPEAT, 53 checksumFile, 66
KEY_SELECT_UP, 53 compareDelta, 67
KEY_TARE_DOWN, 53 convertCsvFileToTable_LUA, 67
KEY_TARE_REPEAT, 54 convertTableToCsvFile_LUA, 68
KEY_TARE_UP, 54 copyFile, 68
KEY_UNITS_DOWN, 54 cpuIdleFactor, 69
KEY_UNITS_REPEAT, 55 createTimer, 69
KEY_UNITS_UP, 55 deleteDirectory, 70
KEY_ZERO_DOWN, 56 deleteFile, 70
KEY_ZERO_REPEAT, 56 deleteFolderAndFiles, 70
KEY_ZERO_UP, 56 equateDelta, 71
registerRpnEvent, 57 findFile, 71
selectList, 57 getSealedStatus, 72
setDate, 58 getVersion, 72
setRpnMode, 58 getVersionInfo, 73
setTime, 59 killTimer, 73

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
INDEX 177

listDirectory, 74 labelCtrl, 62
logThisError, 74 textboxCtrl, 118
makeDirectory, 74 readTable
memoryMaxUsage, 75 variables, 124
memoryTest, 75 reboot
moveFile, 76 hardware, 36
registerFtpFileAddedEvent, 76 recall
registerFtpFileDeletedEvent, 76 variables, 124
registerFtpFileReceivedEvent, 77 rect
registerPasswordEnteredEvent, 77 graphics, 30
registerScriptCloseEvent, 78 registerAccumCompleteEvent
registerUsbDriveMountEvent, 78 weight, 150
sleep, 79 registerEomEvent
stopwatch, 79 serial, 98
systemEvents, 79 socket, 114
unregisterFtpFileAddedEvent, 80 registerFtpFileAddedEvent
unregisterFtpFileDeletedEvent, 80 os, 76
unregisterFtpFileReceivedEvent, 80 registerFtpFileDeletedEvent
unregisterPasswordEnteredEvent, 80 os, 76
unregisterScriptCloseEvent, 80 registerFtpFileReceivedEvent
unregisterUsbDriveMountEvent, 81 os, 77
registerHoldCompleteEvent
picturebox.new weight, 151
graphics, 29
registerInmotionCompleteEvent
pictureboxCtrl, 81
weight, 151
getLocation, 81
registerInmotionErrorEvent
getVisible, 82
weight, 152
setLocation, 82
registerInmotionStartEvent
setVisible, 82
weight, 152
ports, 83
registerInputEvent
getInputPollPeriod, 83
setpoint, 108
getInputs, 84
registerOutputEvent
getOutputs, 84
setpoint, 109
registerSwitchChangeEvent, 84
registerPasswordEnteredEvent
setInputPollPeriod, 85
os, 77
unregisterSwitchChangeEvent, 85
registerPrintCompleteEvent
printBuffer
weight, 152
fmtPrint, 20
registerPrinterJobStatusEvent
printFmt
printer, 86
printer, 86
registerPrinterStatusEvent
printer, 86
printer, 87
printFmt, 86
registerRpnEvent
registerPrinterJobStatusEvent, 86
keypad, 57
registerPrinterStatusEvent, 87
registerSMAOnlineEvent
reportFmt, 88
serial, 99
unregisterPrinterJobStatusEvent, 88
registerSampleCompleteEvent
unregisterPrinterStatus, 89
weight, 153
putPixel
graphics, 30 registerScriptCloseEvent
os, 78
quadrant registerSelectCompleteEvent
graphics, 30 weight, 154
registerShutdownEvent
rFillRect hardware, 36
graphics, 31 registerSwitchChangeEvent
rRect ports, 84
graphics, 31 registerTareCompleteEvent
reSize weight, 155
buttonCtrl, 6 registerUnitsCompleteEvent

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
178 INDEX

weight, 156 serial, 93


registerUsbDriveMountEvent close, 94
os, 78 getConnectString, 95
registerVarChangeReqEvent getEomChar, 95
fmtPrint, 20 getMaxPorts, 96
registerWeightChangeEvent getRx, 96
weight, 157 getRxCount, 97
registerZeroCompleteEvent getSMATimeout, 97
weight, 157 open, 97
reportFmt registerEomEvent, 98
printer, 88 registerSMAOnlineEvent, 99
requestAccum send, 99
weight, 158 setEomChar, 100
requestHold setSMATimeout, 100
weight, 158 unregisterEomEvent, 101
requestKeyboardTare set
weight, 159 fmtPrint, 21
requestPresetTare setAccum
weight, 159 weight, 163
requestPrint setActValVisible
weight, 160 scaleCtrl, 91
requestSample setActiveScale
weight, 160 weight, 164
requestTare setActiveScreen
weight, 161 graphics, 32
requestTareClear setActiveValue
weight, 161 scaleCtrl, 90
requestZero weight, 164
weight, 161 setBar
requestZeroCheckWeigh weight, 164
weight, 162
setBuzzer
resetAccum
display, 13
weight, 162
setBuzzerEnable
resetPeakMax
display, 14
weight, 162
setCheck
resetPeakMin
weight, 165
weight, 163
setConfig
scaleCtrl, 89 weight, 166
getLocation, 90 setCurrentUnits
getVisible, 90 weight, 166
setActValVisible, 91 setDate
setActiveValue, 90 keypad, 58
setLocation, 91 setDisplayBusy
setScaleNumVisible, 91 display, 14
setUnitsVisible, 92 graphics, 32
setVisible, 92 setDisplayFlash
scaleEnabled display, 14
weight, 163 setDisplayVariable
screens.new weight, 167
graphics, 32 setEomChar
screensCtrl, 92 serial, 100
addControl, 93 socket, 115
show, 93 setFont
selectList buttonCtrl, 7
keypad, 57 labelCtrl, 62
send textboxCtrl, 118
serial, 99 setInactivityShutdownTime
socket, 115 hardware, 37

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
INDEX 179

setInputPollPeriod registerInputEvent, 108


ports, 85 registerOutputEvent, 109
setInverted setInverted, 109
graphics, 33 unlock, 110
setpoint, 109 unregisterInputEvent, 110
setLocation unregisterOutputEvent, 110
buttonCtrl, 7 varGet, 111
labelCtrl, 62 varSet, 111
pictureboxCtrl, 82 show
scaleCtrl, 91 screensCtrl, 93
textboxCtrl, 119 sleep
setMode os, 79
display, 14 socket, 112
graphics, 33 connected, 113
setOneSegment getEomChar, 113
display, 15 getMaxSockets, 113
setPieceWeight getRx, 113
weight, 167 getRxCount, 114
setRpnMode registerEomEvent, 114
keypad, 58 send, 115
setSMATimeout setEomChar, 115
serial, 100 unregisterEomEvent, 116
setSampleSize stopwatch
weight, 168 os, 79
setScaleNumVisible store
scaleCtrl, 91 variables, 125
setSegment systemEvents
display, 16 os, 79
setSegments
textboxCtrl, 116
display, 17
getLocation, 117
setShutdownEnable
getText, 117
hardware, 37
getVisible, 118
setShutdownVoltage
reSize, 118
hardware, 38
setFont, 118
setTarget
setLocation, 119
weight, 168
setText, 119
setText
setVisible, 119
buttonCtrl, 7
toCodePoints
labelCtrl, 63
utf8, 122
textboxCtrl, 119 toLuaTable
setTime utf8, 122
keypad, 59
setUnitsVisible unitStrToUnitIndex
scaleCtrl, 92 weight, 169
setVisible unlock
buttonCtrl, 8 setpoint, 110
labelCtrl, 63 unregisterAccumCompleteEvent
pictureboxCtrl, 82 weight, 169
scaleCtrl, 92 unregisterEomEvent
textboxCtrl, 119 serial, 101
setpoint, 102 socket, 116
activate, 103 unregisterFtpFileAddedEvent
configure, 103 os, 80
deactivate, 106 unregisterFtpFileDeletedEvent
getInverted, 107 os, 80
getState, 107 unregisterFtpFileReceivedEvent
lockOff, 107 os, 80
lockOn, 108 unregisterHoldCompleteEvent

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
180 INDEX

weight, 169 variables, 123


unregisterInmotionCompleteEvent clearTable, 123
weight, 169 createTable, 124
unregisterInmotionErrorEvent deleteTable, 124
weight, 170 readTable, 124
unregisterInmotionStartEvent recall, 124
weight, 170 store, 125
unregisterInputEvent
setpoint, 110 weight, 125
unregisterOutputEvent clearInmotion, 130
setpoint, 110 configureRateOfChange, 130
unregisterPasswordEnteredEvent convertFromInternalCalUnit, 130
os, 80 convertToInternalCalUnit, 131
unregisterPrintCompleteEvent convertWeight, 132
weight, 170 cycleActiveScale, 132
unregisterPrinterJobStatusEvent cycleActiveValue, 133
printer, 88 cycleUnits, 133
unregisterPrinterStatus getActiveScale, 133
printer, 89 getActiveValue, 134
unregisterRpnEvent getCalibWeightUnits, 134
keypad, 59 getConfig, 134
unregisterSampleCompleteEvent getCurrent, 136
weight, 170 getCurrentUnits, 139
unregisterScriptCloseEvent getInmotion, 140
os, 80 getLastPrint, 140
unregisterSelectCompleteEvent getNumActiveScales, 144
weight, 170 getPieceWeight, 144
unregisterShutdownEvent getRefreshLastPrint, 144
hardware, 38 getSampleSize, 148
unregisterSwitchChangeEvent getTarget, 148
ports, 85 graphEnable, 149
unregisterTareCompleteEvent inmotion, 149
weight, 171 registerAccumCompleteEvent, 150
unregisterUnitsCompleteEvent registerHoldCompleteEvent, 151
weight, 171 registerInmotionCompleteEvent, 151
unregisterUsbDriveMountEvent registerInmotionErrorEvent, 152
os, 81 registerInmotionStartEvent, 152
unregisterVarChangeReqEvent registerPrintCompleteEvent, 152
fmtPrint, 22 registerSampleCompleteEvent, 153
unregisterWeightChangeEvent registerSelectCompleteEvent, 154
weight, 171 registerTareCompleteEvent, 155
unregisterWeightUpdateEvent registerUnitsCompleteEvent, 156
weight, 171 registerWeightChangeEvent, 157
unregisterZeroCompleteEvent registerZeroCompleteEvent, 157
weight, 171 requestAccum, 158
utf8, 120 requestHold, 158
charToCodePoint, 120 requestKeyboardTare, 159
isLegalUtf8Char, 121 requestPresetTare, 159
isLegalUtf8String, 121 requestPrint, 160
length, 121 requestSample, 160
toCodePoints, 122 requestTare, 161
toLuaTable, 122 requestTareClear, 161
requestZero, 161
varGet requestZeroCheckWeigh, 162
fmtPrint, 22 resetAccum, 162
setpoint, 111 resetPeakMax, 162
varSet resetPeakMin, 163
fmtPrint, 23 scaleEnabled, 163
setpoint, 111 setAccum, 163

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
INDEX 181

setActiveScale, 164
setActiveValue, 164
setBar, 164
setCheck, 165
setConfig, 166
setCurrentUnits, 166
setDisplayVariable, 167
setPieceWeight, 167
setSampleSize, 168
setTarget, 168
unitStrToUnitIndex, 169
unregisterAccumCompleteEvent, 169
unregisterHoldCompleteEvent, 169
unregisterInmotionCompleteEvent, 169
unregisterInmotionErrorEvent, 170
unregisterInmotionStartEvent, 170
unregisterPrintCompleteEvent, 170
unregisterSampleCompleteEvent, 170
unregisterSelectCompleteEvent, 170
unregisterTareCompleteEvent, 171
unregisterUnitsCompleteEvent, 171
unregisterWeightChangeEvent, 171
unregisterWeightUpdateEvent, 171
unregisterZeroCompleteEvent, 171
writeLine
display, 18

Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen

You might also like