4/25/2025 9:35 AM | |
Joined: 6/24/2024 Last visit: 6/24/2025 Posts: 12 Rating:
|
I was having a similar issue. I tried your code and I only change the path to C-drive and tag name. The TIAV19 Unified complained about the await function so i had to add an async. My code below. It doesn't record any tags, it shows null. Any suggestions why? async function yourFunctionName() { let timeStamp = new Date().toLocaleDateString("pt-PT").replace(/[/]/g,"_"); let day = timeStamp.substring(0,2); let month = timeStamp.substring(3,5); let year = timeStamp.substring(6); let date = year + "_" + month + "_" + day; HMIRuntime.Trace(date); let path = "C:\\Users\\Public\\TagLogFile.csv"; let delimiter = ";" let start = new Date(); let end = new Date(start.getTime() - 1000*60*60*24); HMIRuntime.Trace(start); HMIRuntime.Trace(end); let logTagSet = HMIRuntime.TagLogging.CreateLoggedTagSet(["tag:Test_Trend_Log","tag2:Data","tag3:Hora","tag4:OFNumber","tag5:TesteAlfa"]); let loggedTagsMatrix = await logTagSet.Read(start,end,0); let array=[[],[]]; let i=0; let j=0; let n=0; let m=0; HMIRuntime.Trace(loggedTagsMatrix.length); for (i = 0; i < loggedTagsMatrix.length; i++) { array[i] = new Array(1); } i=0; for (let nameCol of loggedTagsMatrix){ array[i][0] = nameCol.Name; i=i+1; } i=0; for (let loggedTag of loggedTagsMatrix){ j = 1; for(let loggedTagValue of loggedTag.Values){ array[i][j] = loggedTagValue.Value; j=j+1; } i=i+1; } HMIRuntime.Trace("i="+i+" "+"j="+j); let CSVData =""; n=0; for (n = 0; n < j; n++) { for (m = 0; m < i; m++){ CSVData += array[m][n] + delimiter; } CSVData += "\n"; } HMIRuntime.FileSystem.WriteFile(path, CSVData, "utf8").then( function(){ HMIRuntime.Trace("Write file finished successfully"); }).catch(function(errorCode) { HMIRuntime.Trace("Write failed errorcode=" + errorCode); }); HMIRuntime.Trace("Fim Função"); } ------------------------------------------------------------------------------------------ |
Last edited by: Moderator_Lan at: 04/25/2025 09:49:33New subject after splitting |
|
4/25/2025 9:50 AM | |
Joined: 7/30/2024 Last visit: 8/29/2025 Posts: 936 Rating:
|
Topic closed because the question has been posted twice. The active topic can be found here: Export Datalog to CSV (TIA19 MTP19 Unified Comfort) Kind regards, Moderator_Lan |
Follow us on