Changes for page 05 Lua Script

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

From version 39.1
edited by Hunter
on 2023/07/10 14:03
Change comment: There is no comment for this version
To version 55.1
edited by Theodore Xu
on 2024/01/23 14:03
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.Hunter
1 +XWiki.AiXia
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  
... ... @@ -522,3 +522,63 @@
522 522  
523 523  (% style="text-align:center" %)
524 524  [[image:WeatherHTTPtestdisplay.png]]
525 +
526 += 17 **CSV File Reading** =
527 +
528 +The example shows how to read the csv file into HMI, and then display as table.
529 +
530 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/csvRead.zip]]
531 +
532 +The core code is from file readcsv.lua:
533 +
534 +1) The file path is set as Sheet_2023_06_13_15_29_45.csv at the root path for USB;
535 +
536 +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;
537 +
538 +(% style="text-align:center" %)
539 +[[image:CSVreadwithsemicolon.png]]
540 +
541 +3) The reading content is a two-dimensional table, can use the table index to locate the specify data cell;
542 +
543 +For example, want to read the 2nd row C column from the table, the table index will be like table[2][3].
544 +
545 +(% style="text-align:center" %)
546 +[[image:celllocation.png]]
547 +
548 += 18 How to convert a number to a string =
549 +
550 +The example shows how to convert a number to a string using the "tostring()" function.
551 +
552 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Number%20to%20string.zip]]
553 +
554 +Note:This demo converts a 64-bit floating to a string,you can change the data format of "@W_HDW0" depand on requirements
555 +
556 +The core code is from file convert.lua:
557 +
558 +(% style="text-align:center" %)
559 +[[image:convert.lua.png]]
560 +
561 +The HMI offline simulator result:
562 +
563 +(% style="text-align:center" %)
564 +[[image:Converttestdisplay.png]]
565 +
566 += 19 HUAWEI CLOUD & OpenCloud =
567 +
568 +About the details, please check the powerpoint or video of Lua MQTT & OpenCloud [[Jump To>>doc:PIStudio.Download.1 Manual.WebHome]]
569 +
570 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/HuaweiMQ%281%29.zip]]
571 +
572 += 20 UDP Multicast =
573 +
574 +The example shows how to use UDP multicast feature to send and receive data.
575 +
576 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/UDP%20Multicast.zip]]
577 +
578 +About the details, please check the [[UDP module>>https://docs.we-con.com.cn/bin/view/PIStudio/09%20Lua%20Editor/Lua%20Script/#HUDPmodule-1]]
579 +
580 += 21 ATC module **send SMS** =
581 +
582 +The example shows how to use HMI to customize communication with the ATC SMS module via Lua script to send SMS.
583 +
584 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/SMS.zip]]
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
luacsvfilereadcontent.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Hunter
Size
... ... @@ -1,0 +1,1 @@
1 +46.5 KB
Content