WinCC Unified: export multiple logged tags as a daily .CSV report
Автор: DerHecht4.0
Загружено: 2021-11-17
Просмотров: 19865
Описание:
In this Video I show you how you create with JavaScript and the method "CreateLoggedTagSet" a daily report of multiple logged tags from the last 24h.
You can easy change the script more logged values of differnt time range like the last week add to the end date "*7".
00:00 Intro
00:30 Solution
00:47 how does it work
02:34 add an additional tag
Video for single export:
WinCC Unified V16: export logged tags as a daily .CSV report (last 24 hours)
• WinCC Unified V16: export logged tags as a...
//Asynchronous JavaScript code
let timeStamp = new Date().toLocaleDateString().replace(/[/]/g, "_");
let path = "C:\\Users\\Public\\Export_" + timeStamp +".csv";
let delimiter =",";
let start = new Date(); //now
let end = new Date(start.getTime() - 1000 * 60 * 60 * 24);//last 24h
let CSVData = "Time Stamp:" + delimiter +"Tag name:" + delimiter +"Value:" + "\n"; //header
let logTagSet = HMIRuntime.TagLogging.CreateLoggedTagSet(["Flow:LoggingTag_Flow", "Speed:LoggingTag_Speed", "Velocity:LoggingTag_Velocity"]);
let loggedTagsMatrix = await logTagSet.Read(start, end, 0);
for(let loggedTag of loggedTagsMatrix)
{
for(let loggedTagValue of loggedTag.Values)
{
CSVData += new Date(loggedTagValue.TimeStamp) + delimiter + loggedTag.Name + delimiter + loggedTagValue.Value + "\n";
HMIRuntime.FileSystem.WriteFile(path, CSVData, "utf8").then(
function() {
HMIRuntime.Trace("Write file finished successfully");
}).catch(function(errorCode) {
HMIRuntime.Trace("Write failed errorcode=" + errorCode);
#DerHecht #WinCC #Unified #TIAPortal #JavaScript
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: