Changes for page 01 Lua Functions
Last modified by Theodore Xu on 2023/10/26 10:51
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,4 +1,4 @@ 1 -= **1 Interface Description** =1 += **1 Interface description** = 2 2 3 3 == **Data type definition** == 4 4 ... ... @@ -92,24 +92,20 @@ 92 92 1. From the print result, the first line and the second line are successfully called and returns true; the third line fails the call, the error message is translated as: the bar student has been registered, and there is indeed an error in the code. 93 93 1. The fourth line of code uses two variables to receive the return value. The call failed, the first variable stat is nil, and the second variable err stores the error message. Then print it out using print, which is the output of the third line. This example shows how to capture and view the error message. 94 94 95 -== **Modification of the PrintFunction** ==95 +== **Modification of print function** == 96 96 97 -For the convenience of remote development, the print data is sent to the front end (web page) by means of network transmission, and the user can see the result of the debug output, because it consumes certain data and occupies the bandwidth of the server (or occupies server resources). So makethe following restrictions:97 +For the convenience of remote development, the print data is sent to the front end (web page) by means of network transmission, and the user can see the result of the debug output, because it consumes certain data and occupies the bandwidth of the server (or occupies server resources). So the following restrictions are made. 98 98 99 -**1.Interval limit: **When debugging, transfer once every 2~~3 seconds; 99 +1. **Interval limit: **When debugging, transfer once every 2~~3 seconds; 100 +1. **Data limit: **The transfer data cannot be larger than 1.5KB in a single transmission, otherwise the extra part will be ignored; 101 +1. **Transmission limit: **The data transmission will be stopped automatically after the debugging windows is not closed normally. Only when it is in the debugging window and the switch is on, there is data transmission; 100 100 101 -**2.Data limit: **The transfer data cannot be larger than 1.5KB, and the extra part will be ignored; 102 - 103 -**3.Transmission limit: **The data transmission will be stopped automatically after the debugging windows is not closed normally. Only when it is in the debugging window and the switch is on, there is data transmission; 104 - 105 105 Users should pay attention to avoid printing a lot of useless information, should minimize the debug output 106 106 107 107 In addition, please refer to the front-end documentation for how to use view debugging. 108 108 109 109 ((( 110 -= **2 Address Operation** = 111 - 112 - 108 += **2 Address operation** = 113 113 ))) 114 114 115 115 |=16-bit data formal|=HLword|=32-bit data formal|=HLword|= 64-bit data formal|=HLword ... ... @@ -142,20 +142,17 @@ 142 142 43218765 143 143 )))|10 144 144 145 - *If HLword entersany other value,it will be treated as invalid.141 + Table 2-1 146 146 147 - Demo: Reads a 32-bit floating-point number at position D0 of PLC 143 +(% class="box errormessage" %) 144 +((( 145 +**✎Note: **If HLword enters any other value, it will be treated as invalid. 146 +))) 148 148 148 +== **addr_getshort(string addr[, number type, number hlword])** == 149 149 150 +**Function:** Read 16-bit signed decimal address 150 150 151 -[[image:企业微信截图_20210506180640.png||height="301" width="600" class="img-thumbnail"]] 152 - 153 -== **2.1 addr_getshort(string addr[, number type, number hlword])** == 154 - 155 -**Function:** 156 - 157 -Read 16-bit signed decimal address 158 - 159 159 **Parameters:** 160 160 161 161 //addr//: address ... ... @@ -173,13 +173,11 @@ 173 173 Failed: multi 174 174 175 175 ((( 176 -== ** 2.2addr_setshort(string addr, number num[, number type, number hlword])** ==169 +== **addr_setshort(string addr, number num[, number type, number hlword])** == 177 177 ))) 178 178 179 -**Function:** 172 +**Function:** Write 16-bit signed decimal address 180 180 181 -Write 16-bit signed decimal address 182 - 183 183 **Parameters:** 184 184 185 185 //addr//: address ... ... @@ -197,13 +197,11 @@ 197 197 Failed: multi 198 198 199 199 ((( 200 -== ** 2.3addr_getword(string addr[, number type, number hlword])** ==191 +== **addr_getword(string addr[, number type, number hlword])** == 201 201 ))) 202 202 203 -**Function:** 194 +**Function:** Read 16-bit unsigned decimal address 204 204 205 -Read 16-bit unsigned decimal address 206 - 207 207 **Parameters:** 208 208 209 209 //addr//: address ... ... @@ -219,13 +219,11 @@ 219 219 Failed: multi 220 220 221 221 ((( 222 -== ** 2.4addr_setword(string addr, number num[, number type, number hlword])** ==211 +== **addr_setword(string addr, number num[, number type, number hlword])** == 223 223 ))) 224 224 225 -**Function:** 214 +**Function:**Write 16-bit unsigned decimal address 226 226 227 -Write 16-bit unsigned decimal address 228 - 229 229 **Parameters:** 230 230 231 231 //addr//: address ... ... @@ -243,13 +243,11 @@ 243 243 Failed: multi 244 244 245 245 ((( 246 -== ** 2.5addr_getint(string addr[, number type, number hlword])** ==233 +== **addr_getint(string addr[, number type, number hlword])** == 247 247 ))) 248 248 249 -**Function:** 236 +**Function:** Read 32-bit signed decimal address 250 250 251 -Read 32-bit signed decimal address 252 - 253 253 **Parameters:** 254 254 255 255 //addr//: address ... ... @@ -265,13 +265,11 @@ 265 265 Failed: multi 266 266 267 267 ((( 268 -== ** 2.6addr_setint(string addr, number num[, number type, number hlword])** ==253 +== **addr_setint(string addr, number num[, number type, number hlword])** == 269 269 ))) 270 270 271 -**Function:** 256 +**Function:** Write 32-bit signed decimal address 272 272 273 -Write 32-bit signed decimal address 274 - 275 275 **Parameters:** 276 276 277 277 //addr//: address ... ... @@ -289,13 +289,11 @@ 289 289 Failed: multi 290 290 291 291 ((( 292 -== ** 2.7addr_getdword(string addr[, number type, number hlword])** ==275 +== **addr_getdword(string addr[, number type, number hlword])** == 293 293 ))) 294 294 295 -**Function:** 278 +**Function:** Read 32-bit unsigned decimal address 296 296 297 -Read 32-bit unsigned decimal address 298 - 299 299 **Parameters:** 300 300 301 301 //addr//: address ... ... @@ -311,13 +311,11 @@ 311 311 Failed: multi 312 312 313 313 ((( 314 -== ** 2.8addr_setdword(string addr, number num[, number type, number hlword])** ==295 +== **addr_setdword(string addr, number num[, number type, number hlword])** == 315 315 ))) 316 316 317 -**Function:** 298 +**Function:** Write 32-bit unsigned decimal address 318 318 319 -Write 32-bit unsigned decimal address 320 - 321 321 **Parameters:** 322 322 323 323 //addr//: address ... ... @@ -335,13 +335,11 @@ 335 335 Failed: multi 336 336 337 337 ((( 338 -== ** 2.9addr_getbit(string addr[, number type])** ==317 +== **addr_getbit(string addr[, number type])** == 339 339 ))) 340 340 341 -**Function:** 320 +**Function:** Read a bit of the register address 342 342 343 -Read a bit of the register address 344 - 345 345 **Parameters:** 346 346 347 347 //addr//: address ... ... @@ -357,13 +357,11 @@ 357 357 Failed: multi 358 358 359 359 ((( 360 -== ** 2.10addr_setbit(string addr, number num[, number type])** ==337 +== **addr_setbit(string addr, number num[, number type])** == 361 361 ))) 362 362 363 -**Function:** 340 +**Function:** Write a bit of the register address 364 364 365 -Write a bit of the register address 366 - 367 367 **Parameters:** 368 368 369 369 //addr//: address ... ... @@ -381,13 +381,11 @@ 381 381 Failed: multi 382 382 383 383 ((( 384 -== ** 2.11addr_getfloat(string addr[, number type, number hlword])** ==359 +== **addr_getfloat(string addr[, number type, number hlword])** == 385 385 ))) 386 386 387 -**Function:** 362 +**Function:** Read 32-bit floating address 388 388 389 -Read 32-bit floating address 390 - 391 391 **Parameters:** 392 392 393 393 //addr//: address ... ... @@ -403,13 +403,11 @@ 403 403 Failed: multi 404 404 405 405 ((( 406 -== ** 2.12addr_setfloat(string addr, number num[, number type, number hlword])** ==379 +== **addr_setfloat(string addr, number num[, number type, number hlword])** == 407 407 ))) 408 408 409 -**Function:** 382 +**Function:** Write 32-bit floating address 410 410 411 -Write 32-bit floating address 412 - 413 413 **Parameters:** 414 414 415 415 //addr//: address ... ... @@ -427,13 +427,11 @@ 427 427 Failed: multi 428 428 429 429 ((( 430 -== ** 2.13addr_getdouble(string addr[, number type, number hlword])** ==401 +== **addr_getdouble(string addr[, number type, number hlword])** == 431 431 ))) 432 432 433 -**Function:** 404 +**Function:** Read 64-bit floating address 434 434 435 -Read 64-bit floating address 436 - 437 437 **Parameters:** 438 438 439 439 //addr//: address ... ... @@ -449,13 +449,11 @@ 449 449 Failed: multi 450 450 451 451 ((( 452 -== ** 2.14addr_setdouble(string addr, number num[, number type, number hlword])** ==421 +== **addr_setdouble(string addr, number num[, number type, number hlword])** == 453 453 ))) 454 454 455 -**Function:** 424 +**Function:** Write 64-bit floating address 456 456 457 -Write 64-bit floating address 458 - 459 459 **Parameters:** 460 460 461 461 addr: address ... ... @@ -473,13 +473,11 @@ 473 473 Failed: multi 474 474 475 475 ((( 476 -== ** 2.15addr_getstring(string addr, number length[, number type, number hlbyte])** ==443 +== **addr_getstring(string addr, number length[, number type, number hlbyte])** == 477 477 ))) 478 478 479 -**Function:** 446 +**Function:** Read the specified length string from address 480 480 481 -Read the specified length string from address 482 - 483 483 **Parameters:** 484 484 485 485 //addr//: address ... ... @@ -497,13 +497,11 @@ 497 497 Failed: multi 498 498 499 499 ((( 500 -== ** 2.16addr_setstring(string addr, string str[, number type, number hlbyte])** ==465 +== **addr_setstring(string addr, string str[, number type, number hlbyte])** == 501 501 ))) 502 502 503 -**Function:** 468 +**Function:** Write the specified length string to address 504 504 505 -Write the specified length string to address 506 - 507 507 **Parameters:** 508 508 509 509 //addr//: address ... ... @@ -521,13 +521,11 @@ 521 521 Failed: multi 522 522 523 523 ((( 524 -== ** 2.17addr_bmov(string dst, string src, number length)** ==487 +== **addr_bmov(string dst, string src, number length)** == 525 525 ))) 526 526 527 -**Function:** 490 +**Function:** Copy data from source address to destination address 528 528 529 -Copy data from source address to destination address 530 - 531 531 **Parameters:** 532 532 533 533 //dst//: destination address ... ... @@ -543,13 +543,11 @@ 543 543 **Failed: multi** 544 544 545 545 ((( 546 -== ** 2.18addr_fill(string addr, number num, number length)** ==507 +== **addr_fill(string addr, number num, number length)** == 547 547 ))) 548 548 549 -**Function:** 510 +**Function:** Write the same value to consecutive addresses 550 550 551 -Write the same value to consecutive addresses 552 - 553 553 **Parameters:** 554 554 555 555 //addr//: address ... ... @@ -565,13 +565,11 @@ 565 565 Failed: multi 566 566 567 567 ((( 568 -== ** 2.19addr_newnoaddr(string addr, number offset)** ==527 +== **addr_newnoaddr(string addr, number offset)** == 569 569 ))) 570 570 571 -**Function:** 530 +**Function:** Offset address value relative to //addr// 572 572 573 -Offset address value relative to //addr// 574 - 575 575 **Parameters:** 576 576 577 577 //addr//: address ... ... @@ -585,13 +585,11 @@ 585 585 Failed: multi 586 586 587 587 ((( 588 -== ** 2.20addr_newstataddr(string addr, number offset)** ==545 +== **addr_newstataddr(string addr, number offset)** == 589 589 ))) 590 590 591 -**Function:** 548 +**Function:** Offset station number relative to //addr //station number 592 592 593 -Offset station number relative to //addr //station number 594 - 595 595 **Parameters:** 596 596 597 597 //addr//: address ... ... @@ -604,12 +604,10 @@ 604 604 605 605 Failed: multi 606 606 607 -== ** 2.21addr_gethex64(string addr[, number type, number hlword])** ==562 +== **addr_gethex64(string addr[, number type, number hlword])** == 608 608 609 -**Function:** 564 +**Function:** Read 64-bit hexadecimal numbers 610 610 611 -Read 64-bit hexadecimal numbers 612 - 613 613 **Parameters:** 614 614 615 615 //addr//: address ... ... @@ -624,12 +624,10 @@ 624 624 625 625 Failed: multi 626 626 627 -== ** 2.22addr_sethex64(string addr, number num[, number type, number hlword])** ==580 +== **addr_sethex64(string addr, number num[, number type, number hlword])** == 628 628 629 -**Function:** 582 +**Function:** Write 64-bit hexadecimal addresses 630 630 631 -Write 64-bit hexadecimal addresses 632 - 633 633 **Parameters:** 634 634 635 635 //addr//: address ... ... @@ -650,11 +650,11 @@ 650 650 651 651 Operations on the serial port such as read, write, etc. must use ':' for full mode calls, ie operations on an open serial object. 652 652 653 -**Serial port name and mode :**604 +**Serial port name and mode** 654 654 655 655 The serial port configured in the communication configuration window cannot be configured again using the script. RS232 and RS458 (or RS422) can be used simultaneously, but RS422 and RS485 are mutually exclusive.For example, when the communication port is configured with COM1-485, the script can only open COM1-232, but not COM1-485/422. Similarly, when the communication port is configured with COM2-485, the script can only open COM2-232, but not COM2-485. 656 656 657 -Attempting to use a script to open a serial port in an unsupported mode will result in an error directly, as below 608 +Attempting to use a script to open a serial port in an unsupported mode will result in an error directly, as below. 658 658 659 659 |((( 660 660 local setup = {