Avery Weigh-Tronix Lua API Reference Manual: Mon Sep 14 2015 13:12:38
Avery Weigh-Tronix Lua API Reference Manual: Mon Sep 14 2015 13:12:38
Avery Weigh-Tronix Lua API Reference Manual: Mon Sep 14 2015 13:12:38
1.0
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
Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
x CONTENTS
Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
CONTENTS xi
Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
xii CONTENTS
Index 173
Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
Chapter 1
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
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
• getLocation (checkButton)
getX, getY = buttonCtrl:getLocation(checkButton)
• getText (checkButton)
getText = buttonCtrl:getText(checkButton)
• getVisible (checkButton)
visible = buttonCtrl:getVisible(checkButton)
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.
Parameters
checkButton - (String) The button we want to get the location of.
Returns
Parameters
checkButton - (String) The button we want to get text for.
Returns
This function gets the text for the button on the scale.
Parameters
checkButton - (String) The button that we are checking the visibility of.
Returns
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
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.
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.
This function sets the font type for on the button on the scale.
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.
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.
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.
• clrDisplayBusy ()
awtx.display.clrDisplayBusy()
• clrDisplayFlash ()
awtx.display.clrDisplayFlash()
• 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)
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.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
3.2.2.2 awtx.display.clrDisplayFlash ( )
awtx.display.clrDisplayFlash()
Parameters
newSegmentHi - (Number) The new segments hi 32 bits.
newSegmentLo - (Number) The new segments lo 32 bits.
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()
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.
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.
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.
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.
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.
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
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
3.2.2.11 awtx.display.getScaleControl ( )
awtxScale = awtx.display.getScaleControl()
Returns
awtxScale - (Function) Handler that controls the scales that have been used.
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.
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.
Sets up the buzzer (if it has been enabled) to buzz on the system.
Parameters
newVal - (Number) Sets the buzzer's enable status.
3.2.2.15 awtx.display.setDisplayBusy ( )
awtx.display.setDisplayBusy()
3.2.2.16 awtx.display.setDisplayFlash ( )
awtx.display.setDisplayFlash()
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
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.
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.
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.
Parameters
newSegmentHi - (Number) The new segments hi 32 bits.
newSegmentLo - (Number) The new segments lo 32 bits.
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.
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.
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.
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)
• 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)
• 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
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.
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.
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.
Parameters
tempPrintFmt - (String) A temporary print format string to be filled in with current information.
Returns
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.
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.
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.
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
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
3.3.2.6 awtx.fmtPrint.unregisterVarChangeReqEvent ( )
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.
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
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.
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
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
• clearScreen ()
awtx.graphics.clearScreen()
• clrDisplayBusy ()
awtx.graphics.clrDisplayBusy()
• label.new (labelName)
labelTable = awtx.graphics.label.new(labelName)
• moveTo (x, y)
awtx.graphics.moveTo(x, y)
Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
26 Class Documentation
• 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)
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.
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.
3.4.2.2 awtx.graphics.clearScreen ( )
awtx.graphics.clearScreen()
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()
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.
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.
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.
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)
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.
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
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.
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.
This function moves the current cursor position to the specified point.
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.
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.
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.
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
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.
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.
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
Parameters
screenName - (String) Name of the screen you want to create.
Returns
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.
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()
Parameters
invertedState - (Number) Whether the display should be inverted or not. 1 for inverted, 0 for non-inverted.
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.
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.
• 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()
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.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
This function grabs the maximum bus count and returns the amount allowed.
3.5.2.3 awtx.hardware.getMaxOptionCardCount ( )
result = awtx.hardware.getMaxOptionCardCount()
Returns
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.
This function will return the current state of the shutdown enable flag. 1 if the shutdown event is enabled, else 0 if
disabled.
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.
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
3.5.2.6 awtx.hardware.reboot ( )
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.
Parameters
callbackFunction - (Function) The Lua callback function the scale should call when low battery or inactivity
shutdown event occurs.
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
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.
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.
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
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.
Parameters
voltVal - (Number) Voltage currently being used.
Returns
result - (Number) Voltage that has been set for the shutdown sequence.
This function sets the shutdown voltage for the shutdown sequence of the indicator.
3.5.2.11 awtx.hardware.unregisterShutdownEvent ( )
awtx.hardware.unregisterShutdownEvent()
• 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)
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.
Parameters
encodedString - (String) String to be decoded.
Returns
Parameters
initialString - (String) String to be encoded.
Returns
Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
40 Class Documentation
• 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()
• 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)
• setRpnMode (lastRpnMode)
newRpnMode = awtx.keypad.setRpnMode(lastRpnMode)
• unregisterRpnEvent ()
awtx.keypad.unregisterRpnEvent()
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.
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.
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
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
Returns
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
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
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
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
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
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.
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
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
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
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
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
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()
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()
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()
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
Parameters
pressedChar - (Number) ASCII decimal integer of the character being pressed.
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.
Parameters
repeatedChar - (Number) ASCII decimal integer of the character being repeated.
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.
Parameters
releasedChar - (Number) ASCII decimal integer of the character being released.
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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.
Parameters
handler - (Function) The event handler that will be called when an RPN event occurs.
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
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
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
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.
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
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
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()
• getLocation (checkLabel)
getX, getY = labelCtrl:getLocation(checkLabel)
• getText (checkLabel)
newText = labelCtrl:getText(checkLabel)
• getVisible (checkLabel)
visible = labelCtrl:getVisible(checkLabel)
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
Parameters
checkLabel - (String) The label we are getting the starting point for.
Returns
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.
This function puts text onto the label that has been inputted.
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
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.
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.
This function sets the font type for the text on the label.
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.
Parameters
checkLabel - (Text) The label that the text will be applied to.
newText - (String) The text that will be applied to the label.
This function sets the text that has been received onto a label.
Parameters
checkLabel - (String) The label we are setting to be visible.
visible - (Boolean) Determines if the label is visible or not.
• 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)
• cpuIdleFactor ()
result = awtx.os.cpuIdleFactor()
• deleteDirectory (path)
awtx.os.deleteDirectory(path)
• deleteFile (delPath)
result = awtx.os.deleteFile(delPath)
• deleteFolderAndFiles (path)
awtx.os.deleteFolderAndFiles(path)
• 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()
• 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()
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.1 awtx.os.applicationPath ( )
pathString = awtx.os.applicationPath()
Returns
pathString - (String) A Lua string specifying the fully qualified path to the application folder.
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
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
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.
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
Returns
This function takes a CSV file and then converts the file into a sqlite table.
For result:
0 = SUCCESS
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.
This function converts a sqlite table and writes it out as a CSV file.
Return types for result:
0 = SUCCESS
otherwise
SQLITE3 ERROR
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.
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.
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
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.
Parameters
path - (String) The pathway of the string that you want to have deleted.
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)
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
Parameters
path - (String) The pathway to the file or folder that you want deleted.
This function takes the pathway of a file and/or folder and deletes it.
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."
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
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
This function checks to see if the unit has or hasn't been sealed.
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
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.
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.
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.
Parameters
timerID - (Number) The timerID reference number that was returned from the previous awtx.os.←-
createTimer() function call.
Returns
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
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
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
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.
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))
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.
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
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
Parameters
callbackFunction - (Function) The Lua callback function the scale will call when a file has been uploaded to the
indicator via FTP.
Returns
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
Parameters
callbackFunction - (Function) The Lua callback function the scale will call when a file is deleted via FTP.
Returns
Registers a Lua event handler function to be called when a file is deleted via FTP.
Parameters
callbackFunction - (Function) The Lua callback function the scale will call when a file is received via FTP.
Returns
Registers a Lua event handler function to be called when a file is received via FTP.
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
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.
Parameters
callbackFunction - (Function) The Lua callback function the scale calls when the user script is closing.
Returns
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.
Parameters
callbackFunction - (Function) The Lua callback function the scale will call when a USB drive is inserted or
removed.
Returns
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
Registers a Lua event handler function to be called when a USB drive is inserted or removed.
Parameters
sleep - (Number) Number that tells how long the system will be in sleep for.
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.
This function returns the number of milliseconds that have passed since the last time it was called.
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.
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()
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()
This function unregisters an FTP File delete event from the scale's memory.
3.9.2.35 awtx.os.unregisterFtpFileReceivedEvent ( )
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()
3.9.2.38 awtx.os.unregisterUsbDriveMountEvent ( )
awtx.os.unregisterUsbDriveMountEvent()
This function unregisters the USB Drive device so that it can be erased from memory.
• getLocation (checkPicture)
getX, getY = pictureboxCtrl:getLocation(checkPicture)
• getVisible (checkPicture)
visible = pictureboxCtrl:getVisible(checkPicture)
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.
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
Parameters
checkPicture - (String) The picturebox we want to check the availability of.
Returns
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.
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
Parameters
checkPicture - (String) The picturebox we want to set the visibility of.
visible - (Boolean) Determines whether or not the picturebox is visible or not.
• 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()
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.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.
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.
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.
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
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.
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.
Parameters
arg1 - (Number) Input that will be modified.
Returns
3.11.2.6 awtx.ports.unregisterSwitchChangeEvent ( )
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
• printFmt (formatNum)
awtx.printer.printFmt(formatNum)
• registerPrinterJobStatusEvent (callbackFunction)
awtx.printer.registerPrinterJobStatusEvent(callbackFunction)
• registerPrinterStatusEvent (callbackFunction)
awtx.printer.registerPrinterStatusEvent(callbackFunction)
• unregisterPrinterStatus ()
awtx.printer.unregisterPrinterStatus()
• unregisterPrinterJobStatusEvent ()
awtx.printer.unregisterPrinterJobStatusEvent()
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.
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).
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.
Parameters
callbackFunction - (Function) The Lua callback function the Indicator calls when the Print Event has completed.
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
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()
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
3.12.2.6 awtx.printer.unregisterPrinterStatus ( )
awtx.printer.unregisterPrinterStatus()
• getLocation (checkScale)
getX, getY = scaleCtrl:getLocation(checkScale)
• getVisible (checkScale)
visible = scaleCtrl:getVisible(checkScale)
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
Parameters
checkScale - (String) The scale that is having its location being set.
Returns
Parameters
checkScale - (String) The visibility of the scale in which we want to check.
Returns
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
This function sets the active value of the current active scale.
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.
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.
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.
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.
Parameters
checkScale - (String) The scale that is being set to be visible.
visible - (Boolean) Determines whether the scale is visible or not.
• 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
The screenCtrl namespace handles the screen itself. Currently, it handles new controls and the showing of informa-
tion.
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.
Parameters
screenName - (String) Name of the screen we want displayed.
• 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()
• getRxCount (portNum)
count = awtx.serial.getRxCount(portNum)
• getSMATimeout (timeout)
returnVal = awtx.serial.getSMATimeout(timeout)
• registerSMAOnlineEvent (callbackFunction)
returnVal = awtx.serial.registerSMAOnlineEvent(callbackFunction)
• setSMATimeout (timeout)
returnVal = awtx.serial.setSMATimeout(timeout)
• unregisterEomEvent (portNum)
result = awtx.serial.unregisterEomEvent(portNum)
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.
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
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)
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.
Parameters
portNum - (Number) The selected serial port, either 1 or 2.
Returns
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
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]
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
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.
Parameters
timeout - (Number) The amount of time to be set for the timeout sequence.
Returns
Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
98 Class Documentation
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
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
Parameters
portNum - (Number) The selected serial port number.
eomHandler - (Function) The callback function.
Returns
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.
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)
Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
100 Class Documentation
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
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")
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
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
returnVal = awtx.serial.setSMATimeout(timeout)
Parameters
timeout - (Number) The amount of time to be set for the timeout sequence.
Returns
result = awtx.serial.unregisterEomEvent(portNum)
Parameters
portNum - (Number) The selected serial port, either 1 or 2.
Returns
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
• activate (setpointNum)
returnVal = awtx.setpoint.activate(setpointNum)
• 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)
• 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)
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
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
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
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.
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
3.16.2.4 awtx.setpoint.getInverted ( )
result = awtx.setpoint.getInverted()
Returns
This function takes the output for the setpoint and returns the number set to be inverted.
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
Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
108 Class Documentation
Parameters
setpointNum - (Number) The number of the desired setpoint.
Returns
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.
Parameters
setpointNum - (Number) The number of the desired setpoint.
Returns
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)
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)
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
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.
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)
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)
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
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)
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.
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.
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.
• connected (socketNumber)
connectedStatus = awtx.socket.connected(socketNumber)
• getEomChar (socketNumber)
eomChar = awtx.socket.getEomChar(socketNumber)
• getMaxSockets ()
maxSockets = awtx.socket.getMaxSockets()
• getRxCount (socketNumber)
result = awtx.socket.getRxCount(socketNumber)
• unregisterEomEvent (socketNumber)
registryIndex = awtx.socket.unregisterEomEvent(socketNumber)
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
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.
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
Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
114 Class Documentation
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
1 local socketNumber = 1
2 maxChar = 200
3
4 local buffer, byteRead = awtx.socket.getRx(socketNumber, maxChar)
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.
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)
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)
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)
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.
• 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
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.
Parameters
checkTextbox - (String) The textbox that we are getting the location for.
Returns
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
Parameters
checkTextbox - (String) The textbox that is being checked to see if it is visible.
Returns
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.
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.
This function sets the font type for the text box.
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.
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.
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.
• 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)
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.
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
Returns
This function converts a utf8 character byte sequence into a Unicode codepoint.
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.
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.
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
Parameters
testString - (String) The input string to be measured.
Returns
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.
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
Parameters
utf8String - (String) The utf8 string to be converted to a Lua table.
Returns
This function returns a Lua table containing the codepoints of the utf8 input string.
• 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)
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.
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.
Parameters
tableName - (String) The name of the table that is going to be created.
Parameters
tableName - (String) The name of the table that is going to be deleted.
Parameters
tableName - (String) The name of the table that is being read.
Returns
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.
This function returns the value from a given table and key.
Value can be a boolean, string, number, or table.
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.
• clearInmotion (scaleNumber)
awtx.weight.clearInmotion(scaleNumber)
Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
126 Class Documentation
• 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)
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
• 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)
• 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
• 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)
• setActiveScale (scaleNumber)
returnVal = awtx.weight.setActiveScale(scaleNumber)
• setActiveValue (setActive)
activeValue = awtx.weight.setActiveValue(setActive)
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
• 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()
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
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.
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.
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
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
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
This function converts the current Indicator's active unit to its internal calibration unit.
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
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()
This function navigates through different scales that are currently active.
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.
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
3.21.2.10 awtx.weight.getActiveValue ( )
activeValue = awtx.weight.getActiveValue()
Returns
Parameters
scaleNumber - (Number) Specifies which scale that is currently being used; if left out is set to 0 for the
active scale.
Returns
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.
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).
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 = ',')
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").
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.
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
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)
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
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
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
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.
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
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.
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)
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
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
Parameters
holdComplete - (Function) The Lua callback function the scale calls when the hold request has completed.
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.
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.
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.
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"
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.
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"
Parameters
callbackFunction - (Function) The Lua callback function the scale calls when a select request has completed.
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"
Parameters
callbackFunction - (Function) The Lua callback function the scale calls when the tare request has completed.
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"
Parameters
callbackFunction - (Function) The Lua callback function the scale calls when the units cycle request has com-
pleted.
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"
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.
Parameters
callbackFunction - (Function) The Lua callback function the scale calls when the Zero request has completed.
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"
Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, if left out is set to 0
for the active scale.
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.
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)
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.
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.
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.
Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
160 Class Documentation
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.
Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, if left out is set to 0
for the active scale.
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.
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.
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.
Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, set to the current
active scale if left out.
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.
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.
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.
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.
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.
Parameters
scaleNumber - (Number) (Optional) Specifies which scale that is currently being used, set to the current
active scale if left out.
This function resets the individual totals in the Scale's Accumulation store to zero (Gross Weight, Net Weight, Count
& Transaction count)
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.
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.
Parameters
scaleNumber - (Number) Specifies which scale is currently being used.
Returns
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)
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.
This function sets the individual totals in the Scale's Accumulation store to the values specified by the function
arguments.
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.
This sets the scale that is currently in use as the active scale.
Parameters
setActive - (Number) The value that is going to be set as the new active value.
Returns
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
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.
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.
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.
This function checks the values that are being put into the system.
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
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.
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.
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.
This function sets up the display variable for the current active scale.
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.
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
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.
This function sets the current sample size the scale will use when taking piece weight samples. This must be an
integer value.
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.
Parameters
unitStr - (String) Value that an item is being measured in. Can be in 'lb', or 'kg', etc.
Returns
3.21.2.62 awtx.weight.unregisterAccumCompleteEvent ( )
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.
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()
This function removes the registry of the Inmotion complete event from the system memory.
3.21.2.65 awtx.weight.unregisterInmotionErrorEvent ( )
awtx.weight.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()
3.21.2.67 awtx.weight.unregisterPrintCompleteEvent ( )
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()
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()
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()
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()
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()
3.21.2.73 awtx.weight.unregisterWeightUpdateEvent ( )
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()
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
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
Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
INDEX 179
Generated on Mon Sep 14 2015 13:12:38 for Avery Weigh-Tronix Lua API Reference Manual by Doxygen
180 INDEX
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