欢迎图片

Changes for page Lua Script

Last modified by Devin Chen on 2025/11/10 16:04

From version 3.2
edited by xingzhi lin
on 2025/09/24 10:26
Change comment: There is no comment for this version
To version 7.1
edited by xingzhi lin
on 2025/10/31 10:52
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -580,7 +580,7 @@
580 580  
581 581  == [[we_bas_getstring>>||anchor="HAddressclass"]] ==
582 582  
583 -Prototype: we_bas_getstring(address, len)
583 +Prototype: we_bas_getstring(address, len [, type, element4, element5, element6])
584 584  
585 585  Function: Read string
586 586  
... ... @@ -589,7 +589,37 @@
589 589  * address(string):address
590 590  * len(number):length,Unit: byte
591 591  * type(number):type,type=1 is write-through
592 +* element4:element
592 592  
594 +|=(% style="width: 203px;" %)Value|=(% style="width: 967px;" %)Describe
595 +|(% style="width:203px" %)0|(% style="width:967px" %)Default
596 +|(% style="width:203px" %)1|(% style="width:967px" %)Forced prohibition of the use of the high-order function
597 +|(% style="width:203px" %)2|(% style="width:967px" %)Enable high and low character swapping
598 +|(% style="width:203px" %)3|(% style="width:967px" %)Enable high and low byte swapping
599 +|(% style="width:203px" %)4|(% style="width:967px" %)Gbk text, normal setting
600 +|(% style="width:203px" %)5|(% style="width:967px" %)Gbk text, the first byte is the string length
601 +|(% style="width:203px" %)6|(% style="width:967px" %)Endian-reversed type1: 12345678 -> 87654321
602 +|(% style="width:203px" %)7|(% style="width:967px" %)Endian-reversed type2: 12345678 -> 78563412
603 +|(% style="width:203px" %)8|(% style="width:967px" %)Endian-reversed type3: 12345678 -> 56781234
604 +|(% style="width:203px" %)9|(% style="width:967px" %)Endian-reversed type4: 12345678 -> 65872143
605 +|(% style="width:203px" %)10|(% style="width:967px" %)Endian-reversed type5: 12345678 -> 43218765
606 +|(% style="width:203px" %)11|(% style="width:967px" %)Characters are stored in one word
607 +|(% style="width:203px" %)12|(% style="width:967px" %)Unicode text
608 +
609 +* element5:element
610 +
611 +|=(% style="width: 203px;" %)Value|=(% style="width: 967px;" %)Describe
612 +|(% style="width:203px" %)0|(% style="width:967px" %)Default
613 +|(% style="width:203px" %)4|(% style="width:967px" %)Gbk text, normal setting
614 +|(% style="width:203px" %)5|(% style="width:967px" %)Gbk text, the first byte is the string length
615 +|(% style="width:203px" %)12|(% style="width:967px" %)Unicode text
616 +
617 +* element6:element
618 +
619 +|=(% style="width: 203px;" %)Value|=(% style="width: 967px;" %)Describe
620 +|(% style="width:203px" %)0|(% style="width:967px" %)Default
621 +|(% style="width:203px" %)11|(% style="width:967px" %)Characters are stored in one word
622 +
593 593  Return:
594 594  
595 595  * Success: the designated length of the string
... ... @@ -598,12 +598,12 @@
598 598  Example:
599 599  
600 600  {{code language="Lua"}}
601 -print(we_bas_getstring("@W_HDW0", 10))
631 +print(we_bas_getstring("@W_HDW0", 10,0,0,0,0))
602 602  {{/code}}
603 603  
604 604  == [[we_bas_setstring>>||anchor="HAddressclass"]] ==
605 605  
606 -Prototype: we_bas_setstring(address, str [, len])
636 +Prototype: we_bas_setstring(address, str [, len, type, element4, element5, element6])
607 607  
608 608  Function: Write string
609 609  
... ... @@ -612,7 +612,37 @@
612 612  * address(string):address
613 613  * str(string):string
614 614  * len(number):length, if not set, it will be the bytes of the string
645 +* element4:element
615 615  
647 +|=(% style="width: 203px;" %)Value|=(% style="width: 967px;" %)Describe
648 +|(% style="width:203px" %)0|(% style="width:967px" %)Default
649 +|(% style="width:203px" %)1|(% style="width:967px" %)Forced prohibition of the use of the high-order function
650 +|(% style="width:203px" %)2|(% style="width:967px" %)Enable high and low character swapping
651 +|(% style="width:203px" %)3|(% style="width:967px" %)Enable high and low byte swapping
652 +|(% style="width:203px" %)4|(% style="width:967px" %)Gbk text, normal setting
653 +|(% style="width:203px" %)5|(% style="width:967px" %)Gbk text, the first byte is the string length
654 +|(% style="width:203px" %)6|(% style="width:967px" %)Endian-reversed type1: 12345678 -> 87654321
655 +|(% style="width:203px" %)7|(% style="width:967px" %)Endian-reversed type2: 12345678 -> 78563412
656 +|(% style="width:203px" %)8|(% style="width:967px" %)Endian-reversed type3: 12345678 -> 56781234
657 +|(% style="width:203px" %)9|(% style="width:967px" %)Endian-reversed type4: 12345678 -> 65872143
658 +|(% style="width:203px" %)10|(% style="width:967px" %)Endian-reversed type5: 12345678 -> 43218765
659 +|(% style="width:203px" %)11|(% style="width:967px" %)Characters are stored in one word
660 +|(% style="width:203px" %)12|(% style="width:967px" %)Unicode text
661 +
662 +* element5:element
663 +
664 +|=(% style="width: 203px;" %)Value|=(% style="width: 967px;" %)Describe
665 +|(% style="width:203px" %)0|(% style="width:967px" %)Default
666 +|(% style="width:203px" %)4|(% style="width:967px" %)Gbk text, normal setting
667 +|(% style="width:203px" %)5|(% style="width:967px" %)Gbk text, the first byte is the string length
668 +|(% style="width:203px" %)12|(% style="width:967px" %)Unicode text
669 +
670 +* element6:element
671 +
672 +|=(% style="width: 203px;" %)Value|=(% style="width: 967px;" %)Describe
673 +|(% style="width:203px" %)0|(% style="width:967px" %)Default
674 +|(% style="width:203px" %)11|(% style="width:967px" %)Characters are stored in one word
675 +
616 616  Return:
617 617  
618 618  * Success: true
... ... @@ -622,7 +622,7 @@
622 622  
623 623  {{code language="Lua"}}
624 624  local str = "Hello"
625 -we_bas_setstring("@W_HDW0", str)
685 +we_bas_setstring("@W_HDW0", str, 10, 0, 0, 0, 0)
626 626  {{/code}}
627 627  
628 628  == [[we_bas_bmov>>||anchor="HAddressclass"]] ==
... ... @@ -7783,6 +7783,106 @@
7783 7783  |crc16_arc|0x8005|0x0000|0x0000|true|true|123456789|0xBB3D
7784 7784  |crc32|0x04C11DB7|0xFFFFFFF|0xFFFFFFF|true|true|123456789|0xCBF43926
7785 7785  
7846 += LuaUserSecure =
7847 +
7848 +== user_secure.usersecure_getInfo ==
7849 +
7850 +**Prototype : **user_secure.usersecure_getInfo()
7851 +
7852 +**Function: **Get all user information
7853 +
7854 +**Return: **
7855 +
7856 +* Success: User data table
7857 +* Failure: Returns nil
7858 +
7859 +**Example**
7860 +
7861 +{{code language="LUA"}}
7862 +secure = user_secure.usersecure_getInfo()
7863 + for index,j in pairs(secure) do
7864 + for msg,value in pairs(j) do
7865 + if "permission" == msg then
7866 + print("index",index,"msg",msg,"value",table.concat(value,','))
7867 + else
7868 + print("index",index,"msg",msg,"value",value)
7869 + end
7870 +
7871 + end
7872 + end
7873 +
7874 +{{/code}}
7875 +
7876 +== user_secure.usersecure_addInfo ==
7877 +
7878 +
7879 +**Prototype : **user_secure.usersecure_addInfo(username,password,supassword,desc,hide,permission)
7880 +
7881 +**Function: **Add user information
7882 +
7883 +**Parameters**:
7884 +
7885 +* username(string):新增用户名(长度16位)
7886 +* password(string):密码(长度8位)
7887 +* supassword(string):确认密码(长度8位)
7888 +* desc(string):描述,(长度10位)
7889 +* hide(bool):控制隐藏,true :权限不足时隐藏
7890 +* permission(table):权限,1为拥有权限,0为无权限
7891 +
7892 +**Return: **
7893 +
7894 +* Success: Return 0
7895 +* Failure: Returns nil
7896 +
7897 +**Example**
7898 +
7899 +{{code language="LUA"}}
7900 +tab = {0,1,1,1,1,1,1,1,1,1,1,1}
7901 +user_secure.usersecure_addInfo("user1","123","123","user1",false,"tab")
7902 +{{/code}}
7903 +
7904 +== user_secure.usersecure_deleteInfo ==
7905 +
7906 +== user_secure.usersecure_login ==
7907 +
7908 +== user_secure.usersecure_logout ==
7909 +
7910 +== user_secure.usersecure_updatepwd ==
7911 +
7912 += LuaChart =
7913 +
7914 +== chart.setAlarmBtnSpacing ==
7915 +
7916 +**Prototype : **user_secure.usersecure_getInfo()
7917 +
7918 +**Function: **Connect to a DB file.(If the file does not exist)
7919 +
7920 +**Parameters**:
7921 +
7922 +* dbFilePath (string): Full path to the DB file to connect to (create)
7923 +
7924 +**Return: **
7925 +
7926 +* Success: database object
7927 +* Failure: Returns nil and error.
7928 +
7929 +**Example**
7930 +
7931 +{{code language="LUA"}}
7932 +sql = require "Luasqlite" -- Introducing the lua libraries  
7933 +env = sql.sqlite3() -- Get the environment class
7934 +{{/code}}
7935 +
7936 +== chart.setAlarmBtnScale ==
7937 +
7938 +== chart.setFormulaBtnSpacing ==
7939 +
7940 +== chart.setFormulaBtnScale ==
7941 +
7942 +== chart.setBarChartBtnSpacing ==
7943 +
7944 +== chart.setBarChartBtnScale ==
7945 +
7786 7786  = Environment operation =
7787 7787  
7788 7788  (% class="wikigeneratedid" id="HGetsqliteenvironment" %)