Changes for page 05 Lua Script

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

From version 41.1
edited by Hunter
on 2023/07/31 17:06
Change comment: There is no comment for this version
To version 58.2
edited by Joe
on 2024/09/06 11:14
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.Hunter
1 +XWiki.joe
Content
... ... @@ -38,7 +38,7 @@
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 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/FTP%20ClientV2.zip]]
42 42  
43 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 44  
... ... @@ -67,11 +67,50 @@
67 67  (% style="text-align:center" %)
68 68  [[image:LuaFTPDemoInitial.png]]
69 69  
70 +(% class="box infomessage" %)
71 +(((
70 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 "~/~/".
73 +)))
71 71  
72 72  (% style="text-align:center" %)
73 73  [[image:LuaFTPDemoFilelist.png]]
74 74  
78 +**Common error:**
79 +
80 + In the demo project, if there are some errors in HMI for testing, please check the following steps.
81 +
82 +Error 1: 550 Access is denied
83 +
84 +Open Windows Settings → Update & Security→ Windows Security→ Firewall & network protection→ Advanced setting→ Inbound Rules→ New Rules→ Next → choose "This program path"→ input ‘’C:\Windows\System32\svchost.exe‘’→ Click “NEXT” continuously
85 +
86 +(% style="text-align:center" %)
87 +[[image:qCzqnKTUhp.png]]
88 +
89 +(% style="text-align:center" %)
90 +[[image:vfrt3NElMX.png]]
91 +
92 +(% style="text-align:center" %)
93 +[[image:dAuz25bdvM.png]]
94 +
95 +(% style="text-align:center" %)
96 +[[image:rxQIJkX8ll.png]]
97 +
98 +(% style="text-align:center" %)
99 +[[image:vmG8WGu5P2.png]]
100 +
101 +
102 +Error 2: No route to host
103 +
104 +The previous steps are the same as Error 1 → Port → specific local ports→ input port number “21”→ Click “NEXT” continuously
105 +
106 +(% style="text-align:center" %)
107 +[[image:fdsxie8WHc.png]]
108 +
109 +(% style="text-align:center" %)
110 +[[image:4ALQq7niTV.png]]
111 +
112 +
113 +
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.
... ... @@ -529,7 +529,72 @@
529 529  
530 530  [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/csvRead.zip]]
531 531  
532 -The core code is from file readcsv.lua, and file path is set as Sheet_2023_06_13_15_29_45.csv at the root path for USB.
571 +The core code is from file readcsv.lua:
533 533  
573 +1) The file path is set as Sheet_2023_06_13_15_29_45.csv at the root path for USB;
574 +
575 +2) Remember to change csv separator in the second parameter from function csv_csvToTable according to user's need, this demo is using **semicolon** as separator;
576 +
534 534  (% style="text-align:center" %)
535 -[[image:luacsvfilereadcontent.png]]
578 +[[image:CSVreadwithsemicolon.png]]
579 +
580 +3) The reading content is a two-dimensional table, can use the table index to locate the specify data cell;
581 +
582 +For example, want to read the 2nd row C column from the table, the table index will be like table[2][3].
583 +
584 +(% style="text-align:center" %)
585 +[[image:celllocation.png]]
586 +
587 += 18 How to convert a number to a string =
588 +
589 +The example shows how to convert a number to a string using the "tostring()" function.
590 +
591 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Number%20to%20string.zip]]
592 +
593 +Note:This demo converts a 64-bit floating to a string,you can change the data format of "@W_HDW0" depand on requirements
594 +
595 +The core code is from file convert.lua:
596 +
597 +(% style="text-align:center" %)
598 +[[image:convert.lua.png]]
599 +
600 +The HMI offline simulator result:
601 +
602 +(% style="text-align:center" %)
603 +[[image:Converttestdisplay.png]]
604 +
605 += 19 HUAWEI CLOUD & OpenCloud =
606 +
607 +About the details, please check the powerpoint or video of Lua MQTT & OpenCloud [[Jump To>>doc:PIStudio.Download.1 Manual.WebHome]]
608 +
609 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/HuaweiMQ%281%29.zip]]
610 +
611 += 20 UDP Multicast =
612 +
613 +The example shows how to use UDP multicast feature to send and receive data.
614 +
615 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/UDP%20Multicast.zip]]
616 +
617 +About the details, please check the [[UDP module>>https://docs.we-con.com.cn/bin/view/PIStudio/09%20Lua%20Editor/Lua%20Script/#HUDPmodule-1]]
618 +
619 += 21 ATC module **send SMS** =
620 +
621 +The example shows how to use HMI to customize communication with the ATC SMS module via Lua script to send SMS.
622 +
623 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/SMS.zip]]
624 +
625 += 22 TCP Client =
626 +
627 +The example shows how to use the Lua Socket TCP module to connect with a TCP server.
628 +
629 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/TCP%20ClientV1.1.zip]]
630 +
631 +~1. Set the initial values of Server IP and port number.
632 +
633 +(% style="text-align:center" %)
634 +[[image:vcbt6CE6EL.png]]
635 +
636 +2. Set the actual receive length of TCP message according to the actual needs.
637 +
638 +(% style="text-align:center" %)
639 +[[image:tPN1mbz7ny.png]]
1721298723226-463.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Hunter
Size
... ... @@ -1,0 +1,1 @@
1 +33.9 KB
Content
4ALQq7niTV.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.joe
Size
... ... @@ -1,0 +1,1 @@
1 +20.7 KB
Content
CSVreadwithsemicolon.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Hunter
Size
... ... @@ -1,0 +1,1 @@
1 +51.3 KB
Content
Converttestdisplay.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.DevinChen
Size
... ... @@ -1,0 +1,1 @@
1 +37.0 KB
Content
celllocation.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Hunter
Size
... ... @@ -1,0 +1,1 @@
1 +12.6 KB
Content
convert.lua.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.DevinChen
Size
... ... @@ -1,0 +1,1 @@
1 +28.6 KB
Content
dAuz25bdvM.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.joe
Size
... ... @@ -1,0 +1,1 @@
1 +245.8 KB
Content
fdsxie8WHc.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.joe
Size
... ... @@ -1,0 +1,1 @@
1 +22.4 KB
Content
qCzqnKTUhp.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.joe
Size
... ... @@ -1,0 +1,1 @@
1 +30.0 KB
Content
rxQIJkX8ll.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.joe
Size
... ... @@ -1,0 +1,1 @@
1 +22.1 KB
Content
tPN1mbz7ny.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Hunter
Size
... ... @@ -1,0 +1,1 @@
1 +59.4 KB
Content
vcbt6CE6EL.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Hunter
Size
... ... @@ -1,0 +1,1 @@
1 +33.9 KB
Content
vfrt3NElMX.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.joe
Size
... ... @@ -1,0 +1,1 @@
1 +234.9 KB
Content
vmG8WGu5P2.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.joe
Size
... ... @@ -1,0 +1,1 @@
1 +22.1 KB
Content