Changes for page 01 Lua Functions

Last modified by Theodore Xu on 2023/10/26 10:51

From version 12.1
edited by Hunter
on 2023/02/18 15:29
Change comment: There is no comment for this version
To version 5.36
edited by Stone Wu
on 2022/07/12 11:03
Change comment: There is no comment for this version

Summary

Details

Page properties
Parent
... ... @@ -1,1 +1,1 @@
1 -V-BOX.V-Net.Manual.04 Lua Script.WebHome
1 +V-BOX.V-Net.1\.User Manual.04 Lua Script.WebHome
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.Hunter
1 +XWiki.Stone
Content
... ... @@ -1,17 +1,5 @@
1 1  = **1 Interface description** =
2 2  
3 -(% style="width:749.222px" %)
4 -|=(% scope="row" style="width: 374px;" %)z|=(% style="width: 373px;" %)cxz
5 -|=(% style="width: 374px;" %) |(% style="width:373px" %)
6 -|=(% style="width: 374px;" %) |(% style="width:373px" %)
7 -
8 -|分类|宽|高
9 -|网页全屏|700-850|400
10 -|手机全屏|300|400
11 -|其他大图片|400左右|400左右
12 -|小图片|200左右|200左右
13 -
14 -
15 15  == **Data type definition** ==
16 16  
17 17  |=**Type**|=**Description**
... ... @@ -152,7 +152,7 @@
152 152  
153 153   Table 2-1
154 154  
155 -(% class="box infomessage" %)
143 +(% class="box errormessage" %)
156 156  (((
157 157  **✎Note: **If HLword enters any other value, it will be treated as invalid.
158 158  )))
... ... @@ -620,12 +620,11 @@
620 620  Attempting to use a script to open a serial port in an unsupported mode will result in an error directly, as below.
621 621  
622 622  |(((
623 -{{code language="LUA"}}
624 624  local setup = {
625 625  
626 626  name = "COM2",
627 627  
628 -mode = 422, -- COM2 does not support RS422
615 +mode = 422, ~-~- COM2 does not support RS422
629 629  
630 630  ...
631 631  
... ... @@ -632,7 +632,6 @@
632 632  }
633 633  
634 634  serial.open(setup)
635 -{{/code}}
636 636  )))
637 637  
638 638  **Data bit:**
... ... @@ -1077,9 +1077,8 @@
1077 1077  
1078 1078  If there is no custom configuration, return an empty table, otherwise, return with "field name/field content"
1079 1079  
1080 -**For example:**
1066 +E.g:
1081 1081  
1082 -{{code language="LUA"}}
1083 1083  {
1084 1084  
1085 1085  [1]= {[1]=1234, [2]=1, [3]='temp', [4]='23.5', [5]={"fruit"="apple"}},
... ... @@ -1092,8 +1092,7 @@
1092 1092  
1093 1093  }
1094 1094  
1095 -Failed: table empty table
1096 -{{/code}}
1080 +Failed: //table// empty table
1097 1097  
1098 1098  (((
1099 1099  == **bns_get_config(string from)** ==
... ... @@ -1173,15 +1173,13 @@
1173 1173  
1174 1174  Type (1: switch, 2: number, 3: string)
1175 1175  
1176 -**For example:**
1160 +E.g:
1161 + {
1177 1177  
1178 -{{code language="LUA"}}
1179 -{
1163 +[1]={~-~-The first communication port
1180 1180  
1181 -[1]={--The first communication port
1165 +[1]={~-~-monitoring point array of the first communication port
1182 1182  
1183 -[1]={--monitoring point array of the first communication port
1184 -
1185 1185  [1]={[1]=11,[2]='data1',[3]=3,[4]=2},
1186 1186  
1187 1187  [2]={[1]=12,[2]='data2',[3]=3,[4]=2},
... ... @@ -1188,23 +1188,23 @@
1188 1188  
1189 1189  ...
1190 1190  
1191 -[n]={[1]=xx,[2]='datan',[3]=x,[4]=x},--n monitoring points
1173 +[n]={[1]=xx,[2]='datan',[3]=x,[4]=x},~-~-n monitoring points
1192 1192  
1193 1193  },
1194 1194  
1195 -[2]=14, --ID
1177 +[2]=14, ~-~-ID
1196 1196  
1197 -[3]='Modbus TCP' --n monitoring points
1179 +[3]='Modbus TCP' ~-~-n monitoring points
1198 1198  
1199 1199  },
1200 1200  
1201 -[2]={--The second communication port
1183 +[2]={~-~-The second communication port
1202 1202  
1203 -[1]={},--The monitoring point of the second communication port is not configured and is empty
1185 +[1]={},~-~-The monitoring point of the second communication port is not configured and is empty
1204 1204  
1205 -[2]=15, --ID
1187 +[2]=15, ~-~-ID
1206 1206  
1207 -[3]='WECON' --communication protocol name
1189 +[3]='WECON' ~-~-communication protocol name
1208 1208  
1209 1209  },
1210 1210  
... ... @@ -1211,7 +1211,6 @@
1211 1211  ...n communication ports and so on
1212 1212  
1213 1213  }
1214 -{{/code}}
1215 1215  
1216 1216  Failed~:// table// empty table
1217 1217  
... ... @@ -1291,9 +1291,8 @@
1291 1291  
1292 1292  Succeed: //table// one-dimensional array
1293 1293  
1294 -**For example:**
1275 +E.g:
1295 1295  
1296 -{{code language="LUA"}}
1297 1297  {
1298 1298  
1299 1299  [1]="This is the oldest message", - the first is the oldest message
... ... @@ -1305,7 +1305,6 @@
1305 1305  [n]="This is the latest message", - the last is the latest message
1306 1306  
1307 1307  }
1308 -{{/code}}
1309 1309  
1310 1310  Failede: nil
1311 1311  
... ... @@ -1323,7 +1323,7 @@
1323 1323  
1324 1324  == **https request** ==
1325 1325  
1326 -**For example:**
1305 +Example
1327 1327  
1328 1328  {{code language="LUA"}}
1329 1329  local json = require("json")
... ... @@ -1379,7 +1379,7 @@
1379 1379  
1380 1380  **Access in bit mode, the prefix is @B_HDX, the number in front of "." indicates the number of the word, and the number behind is the bit number of the word.**
1381 1381  
1382 -**For example:** @B_HDX1020.12, its meaning is to access the system data area in bit mode, the specific location is the 13th bit of the 1020th word.
1361 +For example: @B_HDX1020.12, its meaning is to access the system data area in bit mode, the specific location is the 13th bit of the 1020th word.
1383 1383  
1384 1384  (% class="box infomessage" %)
1385 1385  (((
... ... @@ -1401,7 +1401,7 @@
1401 1401  1. Access in bit mode, the number range is: "@B_HDX0.0"-"@B_HDX299999.15".
1402 1402  
1403 1403  (((
1404 -== **Special data area (HSW/HSX)** ==
1383 +== **8.2 Special data area (HSW/HSX)** ==
1405 1405  
1406 1406  (% class="box infomessage" %)
1407 1407  (((
... ... @@ -1519,19 +1519,8 @@
1519 1519  ** addr_getstring("@W_HSW191",17)
1520 1520  * Obtaining ICCID (read only)
1521 1521  ** addr_getstring("@W_HSW225",15)
1522 -* (((
1523 -TSAP settings of Siemens LOGO PLC*
1524 1524  
1525 1525  (((
1526 -addr_setword("@W_0#HSW1200",8192) means set the Local TSAP as 20.00
1527 -)))
1528 -
1529 -* (((
1530 -addr_setword("@W_0#HSW1201",4096) means set the Remote TSAP as 10.00
1531 -)))
1532 -)))
1533 -
1534 -(((
1535 1535  == **Power-down storage area (HAW/HAX)** ==
1536 1536  
1537 1537  The system storage area (HAW) is used for the system power-down hold registers:
... ... @@ -1566,7 +1566,7 @@
1566 1566  Failed: multi
1567 1567  
1568 1568  (((
1569 -== **send_sms_ucs2(string number, string message)** ==
1537 +== **9.2 send_sms_ucs2(string number, string message)** ==
1570 1570  )))
1571 1571  
1572 1572  **Function:**
... ... @@ -1715,7 +1715,7 @@
1715 1715  * number [prarm.refin]: whether each byte of the data to be measured is inverted by bit, true or false.
1716 1716  * number [prarm.refout]: after the calculation or before the heterodyning output, whether the whole data is inverted by bit, true or false.
1717 1717  
1718 -**Return:**
1686 +Return:
1719 1719  
1720 1720  Success: crc object
1721 1721  
... ... @@ -1774,7 +1774,7 @@
1774 1774  Failed: multi, error code
1775 1775  )))
1776 1776  
1777 -**For example:**
1745 +Example:
1778 1778  
1779 1779  {{code language="LUA"}}
1780 1780  function crcTest.main()
... ... @@ -1836,9 +1836,8 @@
1836 1836  ** 2: timeout
1837 1837  * Customization returns an empty table if there is no configuration, otherwise returns "field name/field content"
1838 1838  
1839 -**For example:**
1807 +For example:
1840 1840  
1841 -{{code language="LUA"}}
1842 1842  {
1843 1843  
1844 1844  [1]= {[1]=1234, [2]=1, [3]='temp', [4]='23.5'},
... ... @@ -1852,7 +1852,6 @@
1852 1852  }
1853 1853  
1854 1854  Failed: table, empty table
1855 -{{/code}}
1856 1856  
1857 1857  == **normal_setdata_byname(string name, string data)** ==
1858 1858  
... ... @@ -1868,10 +1868,12 @@
1868 1868  
1869 1869  Succeed: string: The value of the monitor point before it is written
1870 1870  
1871 -Failed: nil
1837 +Failed: mil
1872 1872  
1873 1873  == **normal_getdata_byname(string name)** ==
1874 1874  
1841 +
1842 +
1875 1875  **Function:** Read the data of the monitoring point name
1876 1876  
1877 1877  **Parameter:**
... ... @@ -1882,7 +1882,7 @@
1882 1882  
1883 1883  Succeed: string
1884 1884  
1885 -Failed: nil
1853 +Failed: mil
1886 1886  
1887 1887  = **11 MySQL database operation** =
1888 1888  
... ... @@ -1922,7 +1922,7 @@
1922 1922  
1923 1923  Succeed: status: returns the number of rows affected by SQL statement execution.
1924 1924  
1925 -Failed: nil, errorString
1893 +Failed: mil, errorString
1926 1926  
1927 1927  == **luaMySql.execWithResult(string statement)** ==
1928 1928  
... ... @@ -1936,9 +1936,9 @@
1936 1936  
1937 1937  Succeed: table: returns the result set
1938 1938  
1939 -Failed: nil, errorString
1907 +Failed: mil, errorString
1940 1940  
1941 -**For example:**
1909 +For example:
1942 1942  
1943 1943  {{code language="LUA"}}
1944 1944  mysql = require"mysqlclient"
... ... @@ -2062,82 +2062,18 @@
2062 2062  end
2063 2063  {{/code}}
2064 2064  
2065 -= **12 Message summary algorithm** =
2033 += **12 Message ssummary algorithm** =
2066 2066  
2067 2067  == **hmac(string hash_func, string key, string message)** ==
2068 2068  
2069 -**Function:** HMAC calculate
2037 +**Function:** Execute the given SQL statement returning the result set (check)
2070 2070  
2071 -**Function name**
2072 -
2073 -hash_func:
2074 -
2075 -* [md5, sha1, sha224, sha256, sha384, sha512]
2076 -* [sha512_224, sha512_256, sha3_224, sha3_256]
2077 -* [sha3_384, sha3_512]
2078 -
2079 2079  **Parameter:**
2080 2080  
2081 -key: the key
2041 +statement: the given SQL statement
2082 2082  
2083 -message: message content
2084 -
2085 2085  **Return:**
2086 2086  
2087 -Succeed: string, calculation result
2045 +Succeed: table: returns the result set
2088 2088  
2089 -Failed: nil
2090 -
2091 -**For example:**
2092 -
2093 -{{code language="LUA"}}
2094 -local sha = require"sha2"
2095 -
2096 -function hmac_test.main()
2097 -
2098 -local hmac = sha.hmac
2099 -
2100 -print(hmac(sha.sha1,
2101 -
2102 -"your key", "your message"))
2103 -
2104 -end
2105 -{{/code}}
2106 -
2107 -== **sha(string message** ==
2108 -
2109 -**Function:** SHA calculate
2110 -
2111 -**Function name:**
2112 -
2113 -sha:
2114 -
2115 -* sha1, sha224, sha256, sha384, sha512]
2116 -* [sha512_224, sha512_256, sha3_224, sha3_256]
2117 -* [sha3_384, sha3_512]
2118 -
2119 -**Parameter:**
2120 -
2121 -key: the key
2122 -
2123 -message: message content
2124 -
2125 -**Return:**
2126 -
2127 -Succeed: string, calculation result
2128 -
2129 -Failed: nil
2130 -
2131 -For example:
2132 -
2133 -{{code language="LUA"}}
2134 -local sha = require"sha2"
2135 -
2136 -function sha_test.main()
2137 -
2138 -local sha256 = sha.sha256
2139 -
2140 -print(sha256("your message"))
2141 -
2142 -end
2143 -{{/code}}
2047 +Failed: mil, errorString