DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Looping ChnOffset for a channel in different groups

Solved!
Go to solution

Hi, I am trying to loop through multiple groups having same channel structure and using ChnOffset function on a particular channel , incrementing the Offset after each iteration. The script I have seems to overwrite the offsets of the very first channel while it is expected to add the subsequent offsets to the current group called in that iteration. Below is the relevant code snippet for that part:

Call Data.Root.Clear()

Dim MyFileNames, iCount

Call FileNameGet("ANY", "FileRead", DataReadPath, "xyzData (*.xyz), *.xyz" , "All.lst", True, "Data Selection")

MyFileNames = Split(FileDlgFileName,"|")

For iCount = 0 To Ubound(MyFileNames)

Call DataFileLoad(MyFileNames(iCount))

Call ChnOffset(Data.Root.ChannelGroups(iCount+1).Channels("RR(1)").Name,Data.Root.ChannelGroups(iCount+1).Channels("RR(1)").Name,iCount*3.5,"free offset")

Next

Call Report.NewLayout()

Call Report.Refresh

Call Report.LoadLayout(MyFolders(1)&"xyz_Report_Part_to_Part.TDR")

Call Report.Refresh

Here is what it plots:

Capture.PNG

While it was supposed to add equal offset to all the plots, it kept overwriting only the channel belonging to the first group. I also tried changing the script by mentioning the specific group name as below:

Call ChnOffset(Data.Root.ChannelGroups(iCount+1).Name/Data.Root.ChannelGroups(iCount+1).Channels("RR(1)").Name,Data.Root.ChannelGroups(iCount+1).Name/Data.Root.ChannelGroups(iCount+1).Channels("RR(1)").Name,iCount*3.5,"free offset")

 

but it throws the following error:           

Capture.PNG

 

What am I doing wrong here ? Also, another question I have is:

How can I use the dialog box for selecting multiple files like the one I am using here but the files are in different folders ? Because CTRL + Click does not work for files in different folders.

Thanks

0 Kudos
Message 1 of 11
(4,247 Views)
Solution
Accepted by topic author TMaan

Your problem is that you always calculationg the first one because of referencing it by only name.

 

Call ChnOffset(Data.Root.ChannelGroups(iCount+1).Channels("RR(1)").Name,Data.Root.ChannelGroups(iCount+1).Channels("RR(1)").Name,iCount*3.5,"free offset")

you need to use the channel reference string instead.

 

 

Call ChnOffset(Data.Root.ChannelGroups(iCount+1).Channels("RR(1)").GetReference(eRefTypeIndexName),Data.Root.ChannelGroups(iCount+1).Channels("RR(1)").GetReference(eRefTypeIndexName),iCount*3.5,"free offset")

 

 

Explanation:

 

Data.Root.ChannelGroups(iCount+1).Channels("RR(1)").Name

is the same as writing

 

 

"RR(1)"
"RR(1)"
...

because this is the name of the channel.

 

 

Data.Root.ChannelGroups(iCount+1).Channels("RR(1)").GetReference(eRefTypeIndexName)

will result in

 

"[1]/RR(1)"
"[2]/RR(1)"
...

So you can also use

 

Call ChnOffset("[" & iCount+1 & "]/RR(1)","[" & iCount+1 & "]/RR(1)",iCount*3.5,"free offset")

which might be more readyable for you.

 

Message 2 of 11
(4,214 Views)
Spoiler
It worked. Thanks a lot. Could you please also answer the next part of the question:

How can I use the dialog box for selecting multiple files like the one I am using here but the files are in different folders ? Because CTRL + Click does not work for files in different folders.
0 Kudos
Message 3 of 11
(4,201 Views)
Spoiler
How can I use the dialog box for selecting multiple files like the one I am using here but the files are in different folders ? Because CTRL + Click does not work for files in different folders.

I hav never seen a File dialog beeing capable to do so.

Maybe yo can try Datafinder/Navigator and search for your files by using properties and order by.

0 Kudos
Message 4 of 11
(4,190 Views)

Something I just noticed.  When I plot the offset channel in Report, it is plotting all the channels offset during the script in one shot, no matter which offset channel you drag into the plot. While when I plot the same channel in view, it plots only the channel I dragged in, which is what is expected.

Report mode:

Capture2.PNG

And below is in view mode:

Capture.PNG

 

The channel table in view mode also list only the selected channel, don't know why when this channel is dragged in report, it plots all the offset channels, with same names though in different groups.

0 Kudos
Message 5 of 11
(4,187 Views)

TMaan,

 

Does your REPORT template use "Curve Expansion"?

 

Can you post the report template for me to check?

 

    Otmar

Otmar D. Foehner
0 Kudos
Message 6 of 11
(4,179 Views)

Hi Otmar

Here it is. Not sure about the 'Curve Expansion'.

 

0 Kudos
Message 7 of 11
(4,174 Views)
Solution
Accepted by topic author TMaan

Hello TMaan,

 

Yes, your "Curve Expansion" is turned on - thus the effect you see in REPORT when you drag your data channel into the axis system. The setting for the "Curve Expansion" feature is in the REPORT panel:

 

I currently only have DIAdem 2017 available to me, so this might be in a slightly different spot in your version of DIAdem:

 

In REPORT, go to the menu bar and select: Settings - Layout Setup - Layout parameters

 

Somewhere in the dialog that is related to that menu (maybe in the "Display" tab) there is a setting for "Expand curves" - you can turn that off. Alternatively, you can also go into the dialog for the axis system you are using (double click onto the axis system), and change a small item there. This is what the dialog looks like:

 

Curve expansion.png

 

In this dialog, if you click on the entry for the "Y-Channel" (see red circle above), you can edit the entry from "*/RR(1)" to "[1]/RR(1)" or "[2]/RR(1)", etc. The number in the square bracket references the group in the DIAdem Data Portal (on the right side of DIAdem). If you turn off the "Expand curve" setting before you drag a channel from the Data Portal into the axis system, DIAdem will automatically add the group index in front of the channel name, instead of an "*" as can been seen in the dialog above.

 

What is curve expansion?

 

Curve expansion is a useful feature if you want to automatically plot a varying number of channels that have the same name, or parts of names.

 

For example, you may run a test several times, until a failure occurs or a threshold has been reached. Each test run can be it's own file, and you can load multiple files into DIAdem, each creating it's own group or groups in the Data Portal. If you now want to compare a specific parameter from each test run, rather than having to drag each channel from each group into an axis system separately, you can drag on of the signals from one group, and curve expansion automatically adds all signals that have the same name in different groups for easy comparison.

 

Let me know if that was helpful,

 

     Otmar

Otmar D. Foehner
Message 8 of 11
(4,158 Views)

Yes Otmar, that was very helpful. Thanks for the excellent description.

0 Kudos
Message 9 of 11
(4,147 Views)

 

Hello, 

 

I am doing a similar thing, but I'd like to create a new channel within the same group for each loop. 

 

Can you explain how to do this? 

 

Call ChnEventCreateFilteredTrueChn("[13]/EventStatus_T_y ", ChnEventList1, "DeltaT", 0) 

 

Where y would be the number changing from 1 to 20 (for each loop). What would the script look like?

0 Kudos
Message 10 of 11
(2,471 Views)