DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

mit for-Schleife zwei Kanäle verrechnen zu neuem

Hallo Ihr Lieben,
Ich möchte die Formel aus dem Anhang in DiademSCRIPT umsetzen.
Und zwar sollen damit die einzelnen Werte (n) zweier Kanäle (Kanal a, Kanal b) zu einem neuen Kanal (F) verrechnet werden.

Ich habe leider noch kaum Erfahrung mit Diadem & VBS, daher komme ich nicht auf die benötigte Syntax für die Lösung des Problems.

Vielleicht kann mir einer von euch helfen. Ich habe nämlich keinen Ansatz gefunden unterschiedliche Kanäle bezogen auf die einzelnen Datenpunkte zu verrechnen.
Das man das ganze in einer for-Schleife umsetzt ist wahrscheinlich das sinnvollste.

LG Felix 

0 Kudos
Message 1 of 2
(2,018 Views)

I speak English, not German, but I will try to help. It is not clear to me exactly what you want to do with two channels, but I have prepared an script for you that will hopefully assist you with your task.

 

Ich spreche Englisch, nicht Deutsch, aber ich werde versuchen zu helfen. Mir ist nicht genau klar, was Sie mit zwei Kanälen machen wollen, aber ich habe ein Skript für Sie vorbereitet, das Sie hoffentlich bei Ihrer Aufgabe unterstützen wird.

 

See more solutions at http://www.savvydiademsolutions.com/

 

'-------------------------------------------------------------------------------
'-- VBS script file
'-- Author: Mechatronic Solutions LLC
' Mark W Kiehl
' www.SavvyDiademSolutions.com
' www.MechatronicSolutionsLLC.com
'-- License: http://www.savvydiademsolutions.com/license.php
'-- Comment:
'-------------------------------------------------------------------------------
Option Explicit

'Load a single numeric time channel + three numeric data channels "Speed","RPM","Torque"
Call Data.Root.Clear(): Portal.NoOfGroupsToExpand = 1
If FileExist(sFilePathDIAdemExample("Example.tdm")) Then
Call DataFileLoadSel(sFilePathDIAdemExample("Example.tdm"),"TDM","[1]/[1,2,4]")
ElseIf FileExist(sFilePathDIAdemExample("Example.tdms")) Then
Call DataFileLoadSel(sFilePathDIAdemExample("Example.tdms"),"TDMS","[1]/[1,2,4]")
ElseIf FileExist(sFilePathDIAdemExample("Example_data.tdm")) Then
Call DataFileLoadSel(sFilePathDIAdemExample("Example_data.tdm"),"TDM","[1]/[1,2,4]")
Else
Call LogFileWrite("DIAdem example files cannot be found")
End If

'ChnDeltaCalc - difference between two successive channel values (by row)

Dim oChnA, oChnB, oChnDeltaA, oChnDeltaB, oChnF, sFormula
Set oChnA = Data.Root.ChannelGroups("Example").Channels("Speed")
Set oChnDeltaA = Data.Root.ChannelGroups("Example").Channels.Add("SpeedDelta",DataTypeChnFloat64)
'Calculate row by row difference in oChnA using command ChnDeltaCalc and assign the result to oChnDeltaA
Call ChnDeltaCalc(oChnA, oChnDeltaA)

'Calculate row by row difference in oChnB using command ChnDeltaCalc and assign the result to oChnDeltaB
Set oChnB = Data.Root.ChannelGroups("Example").Channels("Torque")
Set oChnDeltaB = Data.Root.ChannelGroups("Example").Channels.Add("TorqueDelta",DataTypeChnFloat64)
Call ChnDeltaCalc(oChnB, oChnDeltaB)

Set oChnF = Data.Root.ChannelGroups("Example").Channels.Add("DeltaAdivDeltaB",DataTypeChnFloat64)
sFormula = "F = A / B"
ReDim arrSymbols(2): ReDim arrValues(2)

arrSymbols(0) = "F"
Set arrValues(0) = oChnF

arrSymbols(1) = "A"
Set arrValues(1) = oChnDeltaA

arrSymbols(2) = "B"
Set arrValues(2) = oChnDeltaB

Call Calculate(sFormula, arrSymbols, arrValues)


'-------------------------------------------------------------------------------

Function sFilePathDIAdemExample(ByVal sFilename)
'Returns the full absolute file/path for the location of the DIAdem
'example (TDM/TDMS) file sFilename. Looks in the usual places.
'Returns "" if the file cannot be found.
sFilePathDIAdemExample = ""
Dim arrFilePaths, sFilePath, sFolder
ReDim arrFolders(1)
arrFolders(0) = ProgramDrv
arrFolders(1) = CommonDocumentsPath
Call MsgLineDisp("Searching DIAdem examples for file '" & sFilename & "'..")
For Each sFolder In arrFolders
arrFilePaths = DirListGet(sFolder,sFilename,"Date/Time","FullFilenamesRecursive")
If IsArray(arrFilePaths) Then
For Each sFilePath In arrFilePaths
If InStr(1,sFilePath,"Libr",vbTextCompare) = 0 Then
sFilePathDIAdemExample = sFilePath
Exit For
End If
Next
End If
If Len(sFilePathDIAdemExample) > 0 Then Exit For
Next
If IsArray(arrFilePaths) Then Call Erase(arrFilePaths)
If IsArray(arrFolders) Then Call Erase(arrFolders)
Call MsgLineDisp(vbTab)
End Function 'sFilePathDIAdemExample()

0 Kudos
Message 2 of 2
(1,972 Views)