Changes for page 01 Lua Functions

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

From version 5.28
edited by Stone Wu
on 2022/07/12 10:35
Change comment: (Autosaved)
To version 5.30
edited by Stone Wu
on 2022/07/12 10:42
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1727,20 +1727,95 @@
1727 1727  (% class="wikigeneratedid" %)
1728 1728  Table 9-1
1729 1729  
1730 -(% class="wikigeneratedid" %)
1731 1731  == **crc:calc(string crcValue)** ==
1732 1732  
1733 1733  **Function:** Calculate CRC result
1734 1734  
1735 -**parameter:**
1734 +**Parameter:**
1736 1736  
1737 1737  crcValue: the value to be calculated
1738 1738  
1739 1739  **Return:**
1740 1740  
1741 -Succeed: calcul
1740 +Succeed: calculated result
1742 1742  
1743 -Failed: multi
1742 +Failed: multi, error code
1744 1744  )))
1745 1745  
1746 -
1745 +Example:
1746 +
1747 +{{code language="LUA"}}
1748 +function crcTest.main()
1749 +
1750 +local param = {
1751 +
1752 +name = '',
1753 +
1754 +width = 64,
1755 +
1756 +poly = 0x42F0E1EBA9EA3693,
1757 +
1758 +init = 0xFFFFFFFFFFFFFFFF,
1759 +
1760 +xorout = 0xFFFFFFFFFFFFFFFF,
1761 +
1762 +refin = 1,
1763 +
1764 +refout = 1
1765 +
1766 +}
1767 +
1768 +crc64,err = crc.init(param)
1769 +
1770 +if not crc64 then
1771 +
1772 +print("Crc init failed:", err)
1773 +else
1774 +
1775 +crcvalue = crc64:calc("123456789")
1776 +
1777 +print(string.format("crc64 calc :0X%16X", crcvalue))
1778 +
1779 +end
1780 +
1781 +end
1782 +{{/code}}
1783 +
1784 += **11 Special function for V-NET** =
1785 +
1786 +**normal_get_alldata()**
1787 +
1788 +**Function: **Obtain the data of all the monitoring points
1789 +
1790 +**Parameter: None**
1791 +
1792 +**Return:**
1793 +
1794 +Succeed: table two-dimensional arrays, as follows:
1795 +
1796 +* Each item is a monitoring point and contains 4 attributes:
1797 +** 1: ID
1798 +** 2: status
1799 +** 3: tag name
1800 +** 4: value
1801 +* Status contains 3 enumerated values
1802 +** 0: offline
1803 +** 1: online
1804 +** 2: timeout
1805 +* Customization returns an empty table if there is no configuration, otherwise returns "field name/field content"
1806 +
1807 +For example:
1808 +
1809 +{
1810 +
1811 +[1]= {[1]=1234, [2]=1, [3]='temp', [4]='23.5'},
1812 +
1813 +[2]= {[1]=1235, [2]=1, [3]='humi', [4]='67'},
1814 +
1815 +...
1816 +
1817 +[n]= {[1]=xxxx, [2]=x, [3]='xxxx', [4]='xx.x'},
1818 +
1819 +}
1820 +
1821 +Failed: table, empty table