Changes for page 05 Lua Script

Last modified by Devin Chen on 2025/03/04 14:07

From version 1.1
edited by Leo Wei
on 2022/06/08 12:57
Change comment: Imported from XAR
To version 21.2
edited by Hunter
on 2022/12/13 12:04
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.admin
1 +XWiki.Hunter
Content
... ... @@ -4,11 +4,11 @@
4 4  
5 5  [[Download link>>https://drive.google.com/file/d/1ji5RbQJzUn_rQ2couX062fYt_6dqQNRb/view?usp=sharing]]
6 6  
7 -= **2 MQTT** =
7 += **2 MQTT Client** =
8 8  
9 9  The example shows how to connect to the MQTT server.(Test on MaQiaTTo)
10 10  
11 -[[Download link>>https://drive.google.com/file/d/1DY-VGRMBZrxfPHF3qLrgZ-1fJBCOK-q5/view]]
11 +[[Download link>>https://drive.google.com/file/d/1LWLaOlhWB3BRSTLy3_2RC6Yb0wK7slEB/view?usp=sharing]]
12 12  
13 13  = **3 Timer** =
14 14  
... ... @@ -26,7 +26,7 @@
26 26  
27 27  The example shows the simple write and read of User Free protocol
28 28  
29 -[[Download link>>https://drive.google.com/file/d/1Afc6Eh3LyPVdIUuXaEgq9YBbMWSQIeOr/view?usp=sharing]]
29 +[[Download link>>https://drive.google.com/file/d/1v8UZvdclq3OGEajkbd78w7_XY2bY2qAe/view?usp=sharing]]
30 30  
31 31  = **6 Arabic Keypad** =
32 32  
... ... @@ -33,3 +33,185 @@
33 33  The example shows how to use the Lua to achieve the Arabic keypad. Also available for other non-English language like Cyrillic.
34 34  
35 35  [[Download link>>https://drive.google.com/file/d/1JqpTRRqj6db32aLn7tqqO8dWT6EuXBEL/view?usp=sharing]]
36 +
37 += **7 FTP Client** =
38 +
39 +The example shows how the to establish the FTP server at WIN10 OS and make the HMI as FTP client.
40 +
41 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/FTP%20Client.zip]]
42 +
43 +~1. About how to set up the FTP server in Windows PC: **[[Build an FTP Site on IIS>>https://docs.microsoft.com/en-us/iis/publish/using-the-ftp-service/scenario-build-an-ftp-site-on-iis]] **,** [[How to set up and manage an FTP server on Windows 10>>https://www.windowscentral.com/how-set-and-manage-ftp-server-windows-10]]**
44 +
45 +2. Enter PC (FTP Server) IP address and port number (Default 21).
46 +
47 +(% style="text-align:center" %)
48 +[[image:LuaFTPDemoIP&Port.png]]
49 +
50 +3. Change the filename of the file that needs to be uploaded. If run on as Offline Simulator, the simulate upload path of "udisk:1.png" will be "C:\WECON\USB\1.png" on the PC.
51 +
52 +(% style="text-align:center" %)
53 +[[image:LuaFTPDemoUpload.png]]
54 +
55 +4. Change drive letter of file save path according to drop-down list (There are three option available: Flash, UDisk and SDCard).
56 +
57 +(% style="text-align:center" %)
58 +[[image:LuaFTPDemoDropBox.png]]
59 +
60 +5. Change the filename of the file that needs to be downloaded from PC(Server).
61 +
62 +(% style="text-align:center" %)
63 +[[image:LuaFTPDemoDownload.png]]
64 +
65 +6. Set the default configuration in file "Script_BG.lua"
66 +
67 +(% style="text-align:center" %)
68 +[[image:LuaFTPDemoInitial.png]]
69 +
70 +✎Note: If want to confirm whether it is downloaded successfully, please add a File list object to check in HMI project. If saved path is root path (same to the all three drive), please set the folder as "~/~/".
71 +
72 +(% style="text-align:center" %)
73 +[[image:LuaFTPDemoFilelist.png]]
74 +
75 += **8 Telegram Notification** =
76 +
77 +The example shows how to use Bot API to push the notification to channel or group of Telegram. Please change the Token and Chat id to users' own one.
78 +
79 +[[Download link>>https://drive.google.com/file/d/1wV0O79TJ2mgUEBkKcjrb53PM8DkTQxVo/view?usp=sharing]]
80 +
81 +
82 += 9** LINE Notify** =
83 +
84 +This example shows how to use the LINE Notify to send message into LINE group. When monitoring bit "@B_HDX0.0" changes, it will trigger and send the message. Please replace with your own Token.
85 +
86 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/line.zip]]
87 +
88 +
89 += 10** How to parse value from subscribing MQTT topic** =
90 +
91 +This example shows how to parse value from subscribing MQTT topic. The testing topic name is "testtopic/test/no1/123456".
92 +And the subscribed content is like following:
93 +
94 +{{code language="json"}}
95 +{
96 + "Cluster_ID": "2",
97 + "timestamp": "07:01:45-18.02.2022",
98 + "Cust_id": "TAM-1",
99 + "Platform_id": "Pro44ead8a8dc3345ACC",
100 + "version": "1.5",
101 + "Line_active": "true",
102 + "Total_sensor": "5",
103 + "F1": [
104 + {
105 + "Counter": "0",
106 + "Value": "11"
107 + },
108 + {
109 + "Counter": "1",
110 + "Value": "21.1"
111 + },
112 + {
113 + "Counter": "2",
114 + "Value": "9"
115 + },
116 + {
117 + "Counter": "3",
118 + "Value": "0.06"
119 + },
120 + {
121 + "Counter": "4",
122 + "Value": "9"
123 + },
124 + {
125 + "Counter": "5",
126 + "Value": "19"
127 + },
128 + {
129 + "Counter": "6",
130 + "Value": "9"
131 + },
132 + {
133 + "Counter": "7",
134 + "Value": "19"
135 + },
136 + {
137 + "Counter": "8",
138 + "Value": "22.89"
139 + }
140 + ],
141 + "F2": [
142 + {
143 + "Counter": "0",
144 + "Value": "1.1"
145 + },
146 + {
147 + "Counter": "1",
148 + "Value": "21.21"
149 + },
150 + {
151 + "Counter": "2",
152 + "Value": "19"
153 + },
154 + {
155 + "Counter": "3",
156 + "Value": "0.6"
157 + },
158 + {
159 + "Counter": "4",
160 + "Value": "8"
161 + },
162 + {
163 + "Counter": "5",
164 + "Value": "19.1"
165 + },
166 + {
167 + "Counter": "6",
168 + "Value": "5.1"
169 + }
170 + ],
171 + "F4": [
172 + {
173 + "Counter": "0",
174 + "Value": "11"
175 + },
176 + {
177 + "Counter": "1",
178 + "Value": "21.1"
179 + },
180 + {
181 + "Counter": "2",
182 + "Value": "9"
183 + },
184 + {
185 + "Counter": "3",
186 + "Value": "0.06"
187 + },
188 + {
189 + "Counter": "4",
190 + "Value": "9"
191 + },
192 + {
193 + "Counter": "5",
194 + "Value": "19"
195 + },
196 + {
197 + "Counter": "6",
198 + "Value": "9"
199 + },
200 + {
201 + "Counter": "7",
202 + "Value": "12.1"
203 + },
204 + {
205 + "Counter": "8",
206 + "Value": "18.1"
207 + }
208 + ]
209 +}
210 +{{/code}}
211 +
212 + So we decode this json into lua object, and then assign the values from "Value" field into addresses HDW1~~HDW101, HDW112~~HDW202, HDW213~~HDW313, HDW324~~HDW424.
213 +
214 +(% style="text-align:center" %)
215 +[[image:MQTTScreen.png]]
216 +
217 +
LuaFTPDemoDownload.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Hunter
Size
... ... @@ -1,0 +1,1 @@
1 +26.2 KB
Content
LuaFTPDemoDropBox.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Hunter
Size
... ... @@ -1,0 +1,1 @@
1 +29.2 KB
Content
LuaFTPDemoFilelist.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Hunter
Size
... ... @@ -1,0 +1,1 @@
1 +16.5 KB
Content
LuaFTPDemoIP&Port.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Hunter
Size
... ... @@ -1,0 +1,1 @@
1 +26.4 KB
Content
LuaFTPDemoInitial.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Hunter
Size
... ... @@ -1,0 +1,1 @@
1 +55.5 KB
Content
LuaFTPDemoUpload.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Hunter
Size
... ... @@ -1,0 +1,1 @@
1 +26.6 KB
Content
MQTTScreen.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Hunter
Size
... ... @@ -1,0 +1,1 @@
1 +48.7 KB
Content
image-20221213120221-1.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Hunter
Size
... ... @@ -1,0 +1,1 @@
1 +62.4 KB
Content