10-18-2017 10:41 AM - edited 10-18-2017 10:44 AM
DIADEM 2014 (32Bit)
I want to use a script to import some csv-Files into the data portal. The csv file contains only one data row. As result i want to have one channel group containing all the data (one channel for each imported file) and i want to change to property of the group (only the name) and the properties of the channels (Name, Unit, ....).
This is what i have right now:
Dim RunFile_Path, RunChannelObj, iLoop iLoop = 0 for Each ArrayElement in Runlist_3310 RunFile_Path = Data_Path & string(4 - Len(Volume_ID), "0") & Volume_ID & string(4 - Len(Runlist_3310(iLoop)), "0") & Runlist_3310(iLoop) & ".T24" Set RunChannelObj = DataFileLoad(RunFile_Path,"CSV","Load") Call ChnPropValSet(iLoop+1,"Name",Runlist_3310(iLoop) & "-LOBSTx") iLoop = iLoop + 1 Next
As result i have a channel-group for each imported file/channel.
How can i add the second file/data to the channel-group i created in the first loop?
Is it possible to change the name of the new channel right after the DataFileLoad?
How can i change the other properties of the channel?
Thank you all in advance for your help.
10-19-2017 01:52 AM
In your case you can simplyfy your life by using
DataFileLoadSel
Which will return the channel object directly and not create a new group on its own.
So you do not have to use the move method.
It returns a list of loaded elements. Be aware that I put
(1)
at the end of the line always selcting the first element.
Option Explicit
data.Root.Clear
dim grpO : set grpO = data.Root.ChannelGroups.Add("target")
grpO.Activate
dim chO : set chO = DataFileLoadSel(CommonDocumentsPath & "Data\example.csv","CSV","[1]/[1]","Load")(1)
chO.Name = "one"
chO.properties("description").value = "one description"
set chO = DataFileLoadSel(CommonDocumentsPath & "Data\example.csv","CSV","[1]/[1]","Load")(1)
chO.Name = "two"
chO.properties("description").value = "two description"
10-19-2017 02:18 AM
Thank you, that was i was looking for. Works fine.
10-19-2017 04:07 AM
Now I have a lot of generated groups with the right channels.
Some of the groups are shown expanded, some are shown collapsed in the data portal.
Is there a vb command the collapse/expand the group nodes?
10-19-2017 05:14 AM
I assume not by command but there is context menue entry in the portal.
10-20-2017 04:15 AM - edited 10-20-2017 04:35 AM
Now I want to make FFTs of some Channel-Groups.
So I create a new group and set them active. After that I want to loop through the channel group, make the FFT and rename the resulting 2 channels (frequeny and amplitude).
dim grp3310LOBSTzFFT : set grp3310LOBSTzFFT = data.Root.ChannelGroups.Add("3310-LOBSTz_FFT")
FFTIndexChn = 0
'----------- Window Functions -----------
FFTWndFct = "Hanning"
FFTWndPara = 10
FFTWndChn = "[1]/Time_RoughRoad"
FFTWndCorrectTyp = "Random"
'------------ FFT Functions -------------
FFTCalc = 0
FFTAmpl = 1
FFTPhase = 0
FFTCepstrum = 0
FFTAmplType = "Ampl.Peak"
FFTAverageType = "arithmetic"
FFTAmplExt = "No"
FFTAmplFirst = "Amplitude"
'------------ Time Intervals ------------
FFTIntervUser = "LengthStartOverl"
FFTIntervOverl = 50
FFTNoV = 0
FFTIntervPara(1) = 7
FFTIntervPara(2) = 1024
FFTIntervPara(3) = 1
Dim i
grp3310LOBSTzFFT.Activate
for i = 1 to grp3310LOBSTz.Channels.Count
Call ChnFFT1("[1]/Time_RoughRoad", ????????
Next
How can I loop through all channels in the group called grp3310LOBSTz ?
10-20-2017 05:18 AM
Please have a look at the help entry "root object" wheer you will find some examples.
Object: Root <Data>
(ChannelGroup | Data | ElementList | Property ) > Object: Root <Data>
Option Explicit
dim chO : for each chO in data.Root.ChannelGroups("grp3310LOBSTz").Channels
chO.Properties("description").Value = "abc"
Next
10-20-2017 06:52 AM
Thank you for this hint.
How is it possible to loop through the channels of a group and make a FFT?
Call ChnFFT1("[1]/Time_RoughRoad", grp3310LOBSTz(1))
Sure, that doesn't work. Is there a pointer/reference to the first, second, third,... element of the channel group?
10-20-2017 07:08 AM - edited 10-20-2017 07:23 AM
My solution looks like this now:
for each ch0 in data.Root.ChannelGroups("3310-LOBSTz").Channels
chName = ch0.Properties("Name").Value
'--Call ChnFFT1("[1]/Time_RoughRoad", chName)
Call ChnFFT1("Time_RoughRoad", chName)
Next
What is the difference between the statement "[1]/Time_RoughRoad" and "Time_RoughRoad"?
I want to rename the two channels (frequency and amplitude) that are created by the ChnFFT1 command.
Is it possible to do it in the same for each..next loop?
If not I have to do it after FFT creation in a second loop..correct?
10-20-2017 08:02 AM
chO.GetReference(eRefTypeIndexIndex)
will return a string to be used.
If you use just the channel name it will always refer to the active group.
Be aware that [1] will always use the first group.