Changes for page 05 Lua Script
Last modified by Devin Chen on 2025/03/04 14:07
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Attachments (0 modified, 0 added, 10 removed)
Details
- Page properties
-
- Content
-
... ... @@ -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/1 v8UZvdclq3OGEajkbd78w7_XY2bY2qAe/view?usp=sharing]]29 +[[Download link>>https://drive.google.com/file/d/1NZoKRbXL66wTnEOz1yW7ebAjZm_hjBT1/view?usp=sharing]] 30 30 31 31 = **6 Arabic Keypad** = 32 32 ... ... @@ -38,193 +38,18 @@ 38 38 39 39 The example shows how the to establish the FTP server at WIN10 OS and make the HMI as FTP client. 40 40 41 - [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/FTP%20Client.zip]]41 +Step1: 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]]** 42 42 43 - ~1. Aboutow to setuptheFTP serverinWindowsPC: **[[Buildan FTP Site onIIS>>https://docs.microsoft.com/en-us/iis/publish/using-the-ftp-service/scenario-build-an-ftp-site-on-iis]] **,** [[Howtoset up and managean FTPserver on Windows10>>https://www.windowscentral.com/how-set-and-manage-ftp-server-windows-10]]**43 +Step2: Change the IP, port, username and password in Script_BG.lua, to connect user's own server. 44 44 45 - 2. EnterPC(FTP Server)IPaddressandport number(Default21).45 +Step3: Change the filename want to download or upload in Script_BG.lua 46 46 47 -(% style="text-align:center" %) 48 -[[image:LuaFTPDemoIP&Port.png]] 47 +Step4: Change the string "udisk:smtp.jpg", into the storage path user want to download from FTP server save to HMI, in function Main_download() in Main.lua. 49 49 50 - 3. Change the filenameof the file thatneedso be uploaded.If runas OfflineSimulator, the simulate upload path of "udisk:1.png" will be"C:\WECON\USB\1.png" onthe PC.49 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/FTP%20Client.zip]] 51 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 75 = **8 Telegram Notification** = 76 76 77 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 78 79 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. Get the value and calculate the average value for group F1, F2, F3 and F4. The testing topic name is "testtopic/test/no1/123456". 92 - 93 -Download link 94 - 95 -And the subscribed content is like following: 96 - 97 -{{code language="json"}} 98 -{ 99 - "Cluster_ID": "2", 100 - "timestamp": "07:01:45-18.02.2022", 101 - "Cust_id": "TAM-1", 102 - "Platform_id": "Pro44ead8a8dc3345ACC", 103 - "version": "1.5", 104 - "Line_active": "true", 105 - "Total_sensor": "5", 106 - "F1": [ 107 - { 108 - "Counter": "0", 109 - "Value": "11" 110 - }, 111 - { 112 - "Counter": "1", 113 - "Value": "21.1" 114 - }, 115 - { 116 - "Counter": "2", 117 - "Value": "9" 118 - }, 119 - { 120 - "Counter": "3", 121 - "Value": "0.06" 122 - }, 123 - { 124 - "Counter": "4", 125 - "Value": "9" 126 - }, 127 - { 128 - "Counter": "5", 129 - "Value": "19" 130 - }, 131 - { 132 - "Counter": "6", 133 - "Value": "9" 134 - }, 135 - { 136 - "Counter": "7", 137 - "Value": "19" 138 - }, 139 - { 140 - "Counter": "8", 141 - "Value": "22.89" 142 - } 143 - ], 144 - "F2": [ 145 - { 146 - "Counter": "0", 147 - "Value": "1.1" 148 - }, 149 - { 150 - "Counter": "1", 151 - "Value": "21.21" 152 - }, 153 - { 154 - "Counter": "2", 155 - "Value": "19" 156 - }, 157 - { 158 - "Counter": "3", 159 - "Value": "0.6" 160 - }, 161 - { 162 - "Counter": "4", 163 - "Value": "8" 164 - }, 165 - { 166 - "Counter": "5", 167 - "Value": "19.1" 168 - }, 169 - { 170 - "Counter": "6", 171 - "Value": "5.1" 172 - } 173 - ], 174 - "F4": [ 175 - { 176 - "Counter": "0", 177 - "Value": "11" 178 - }, 179 - { 180 - "Counter": "1", 181 - "Value": "21.1" 182 - }, 183 - { 184 - "Counter": "2", 185 - "Value": "9" 186 - }, 187 - { 188 - "Counter": "3", 189 - "Value": "0.06" 190 - }, 191 - { 192 - "Counter": "4", 193 - "Value": "9" 194 - }, 195 - { 196 - "Counter": "5", 197 - "Value": "19" 198 - }, 199 - { 200 - "Counter": "6", 201 - "Value": "9" 202 - }, 203 - { 204 - "Counter": "7", 205 - "Value": "12.1" 206 - }, 207 - { 208 - "Counter": "8", 209 - "Value": "18.1" 210 - } 211 - ] 212 -} 213 -{{/code}} 214 - 215 - So we decode this json into lua object, and then assign the values from "Value" field into table (addresses HDW1~~HDW101, HDW112~~HDW202, HDW213~~HDW313, HDW324~~HDW424). 216 - 217 -(% style="text-align:center" %) 218 -[[image:MQTTScreen.png]] 219 - 220 -Due to the MQTT code is not able to running on the simulator from PC, following picture is the testing result from actual HMI screen: 221 - 222 -(% style="text-align:center" %) 223 -[[image:MQTTactualtestingresult.png]] 224 - 225 -The JSON parser function is located on mqttAction.lua, called mqtt_msg_callback. 226 - 227 -(% style="text-align:center" %) 228 -[[image:MQTTJSONparsefunction.png]] 229 - 230 -
- LuaFTPDemoDownload.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Hunter - Size
-
... ... @@ -1,1 +1,0 @@ 1 -26.2 KB - Content
- LuaFTPDemoDropBox.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Hunter - Size
-
... ... @@ -1,1 +1,0 @@ 1 -29.2 KB - Content
- LuaFTPDemoFilelist.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Hunter - Size
-
... ... @@ -1,1 +1,0 @@ 1 -16.5 KB - Content
- LuaFTPDemoIP&Port.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Hunter - Size
-
... ... @@ -1,1 +1,0 @@ 1 -26.4 KB - Content
- LuaFTPDemoInitial.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Hunter - Size
-
... ... @@ -1,1 +1,0 @@ 1 -55.5 KB - Content
- LuaFTPDemoUpload.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Hunter - Size
-
... ... @@ -1,1 +1,0 @@ 1 -26.6 KB - Content
- MQTTJSONparsefunction.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Hunter - Size
-
... ... @@ -1,1 +1,0 @@ 1 -124.0 KB - Content
- MQTTScreen.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Hunter - Size
-
... ... @@ -1,1 +1,0 @@ 1 -48.7 KB - Content
- MQTTactualtestingresult.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Hunter - Size
-
... ... @@ -1,1 +1,0 @@ 1 -945.6 KB - Content
- image-20221213120221-1.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.Hunter - Size
-
... ... @@ -1,1 +1,0 @@ 1 -62.4 KB - Content