Exports 24 hours of logged values to CSV | Runtime Script | WinCC Unified

免费

由 HMIx AI 生成器创建

此资源由 ai.hmix.tech 上的 AI 创建。描述您的需求,几分钟内即可免费生成您自己的 HMI 控件。

WinCC Unified Runtime Script

When the button is pressed, the last 24 hours of both logging tags are written to one CSV file. Export_Status now also names any logging tag that returned no data.

Minimum version: WinCC Unified V20 and later.

What starts it and where it goes

When the button Btn_ExportCsv is pressed.

In the Pressed event of the button Btn_ExportCsv.

How it works

  • Sets folder, logging tags, period and format. Holds the target folder, the two logging tags, the 24-hour period, the column separator and the decimal comma.
  • Prepares date and number writing. Writes dates with fixed digits and numbers with a decimal comma or point, as chosen above.
  • Works out period and file name. Takes the last 24 hours up to now and builds a file name from the current date and the hour and minute.
  • Shows progress and asks for the values. Writes "Exporting..." to Export_Status and asks the data log for the values of both logging tags.
  • Builds the CSV lines. Puts the values of both logging tags into one list sorted by time and makes a header and one line per value. Logging tags that cannot be read are noted.
  • Creates the folder and writes the file. Creates the folder if needed and writes the file once, then hands on the number of values and the failed logging tags.
  • Reports success. Notes the number of values in the trace and writes it with the file name to Export_Status, naming any logging tag without data.
  • Reports a failure. If reading or writing fails, it writes the reason to the trace and to Export_Status.

Values you adapt

  • Export folder: The folder on the device where the file is written. (in the script: C:\Users\Public\HMIx-Exports)
  • Logging tag 1: HMI tag, a colon, then logging tag; find it in HMI tags, table Logging tags. (in the script: Tank1_Level:Tank1_Level_Log)
  • Logging tag 2: HMI tag, a colon, then logging tag; find it in HMI tags, table Logging tags. (in the script: Tank1_Temp:Tank1_Temp_Log)
  • Period in hours: How far back the export goes. (in the script: 24)
  • Column separator: The character between columns in the file. (in the script: ;)
  • Status tag: The HMI tag that shows the progress and the result. (in the script: Export_Status)

What must exist in your project

The script names these inside a call. Each must exist in your project under exactly this name (capitals included); if yours is called otherwise, change the name in the script.

  • Logging tag Tank1_Level:Tank1_Level_Log (in TIA Portal: HMI tags › Logging tags › Name)
  • Logging tag Tank1_Temp:Tank1_Temp_Log (in TIA Portal: HMI tags › Logging tags › Name)

Minimum version

Minimum version: WinCC Unified V20. It runs on WinCC Unified V20 and every later version; older versions were not checked. Its folders are those of a Unified panel.

  • Tag.Write: From V16 (Siemens' V16 system manual)
  • TagLogging.CreateLoggedTagSet: From V16 (Siemens' V16 system manual)
  • Trace: From V16 (Siemens' V16 system manual)
  • FileSystem.CreateDirectory: From V16 (Siemens' V16 system manual)
  • FileSystem.WriteFile: From V16 (Siemens' V16 system manual)
  • GetDetailedErrorDescription: From V20 (Siemens' object model; older versions not checked)

Before you use it

  • Check that the folder exists or can be created on the device, and that Runtime may write there.

In the package

  • The script, with a header that says where it goes and which values to adapt.
  • Its documentation as PDF and as an editable ODT: purpose, example, the TIA Portal steps, the script part by part.
  • A README with the same in one page.

⚠️ AI-Generated: This script was written with AI and checked against Siemens' documentation, not on a device. Test it on your own HMI before using it in production.

分享此资源:
版本:v2
最后更新:2026年12月4日
已发布:2026年12月4日
布局:SIEMENS - SIMATIC

产品评价 (0)

问答 (0)

您可能还喜欢

免费