A Single Script For An Entire Group


Recommended Posts

Hello,

I was wondering if there was an easy way to have a sequence to map one group of channels to another group of channels. However the channels are not in numerical order.

For an instance:

GROUP A

Channel1

Channel2

Channel3

...

Channel30

Map it into

GROUP B

Channel1_DUP

Channel2_DUP

Channel3_DUP

...

Channel30_DUP

Also is there an easy way to rename the groups?

Lexington

Link to comment
Share on other sites

Sure, there are a number of ways. I'm not exactly sure why you want to do this, so can't address the best way. But, if, for example, your GROUP A was a bunch of input channels and GROUP B was a bunch of outputs, and you wanted to duplicate the reading from GROUP A to the output of GROUP B, and the names didn't match up by number, you can do it with arrays. I'm going to assume that although you numbered your channels above in your example, that the channel names actually aren't numbered. If they are numbered, and the numbers link up between the groups, then a different technique can be used.


private string groupA = {"Channel1", "Channel2", "Channel3"}
private string groupB = {"Channel1_Dup", "Channel2_Dup", Channel3_Dup"}

for (private i = 0, i < numrows(groupa), i++)
execute(groupB[i] + " = " + groupA[i] + "[0]")
endfor

[/CODE]

I'm not sure what you mean by rename the groups.

Link to comment
Share on other sites

I'm assuming these are Channel Groups?

If so, then yes:


function renameGroup(string oldName, string newName)

private string ch = channel.listall(oldName)
for (private i = 0, i < numrows(ch), i++)
execute(ch[i] + ".strGroup = '" + newName + "'")
endfor

[/CODE]

Put in a sequence named RenameGroup, then call with:

renameGroup("group b", "group b minute")

Note that it is case sensitive (the group names), at least in this function.

Link to comment
Share on other sites

Hello,

It looks like I am having trouble getting the script to work. Currently I have the following:

private nextTime=floor(systime()/60)*60+60 //start of next minute

private string groupA = {"TH1F1","TH2F1","TH3F1","TH4F1","TH5F1","TH6F1","TH7F1","TH8F1","TH1F2","TH2F2"\
,"TH3F2","TH4F2","TH5F2","TH6F2","TH7F2","TH8F2"}

private string groupB = {"TH1F1_DUP","TH2F1_DUP","TH3F1_DUP","TH4F1_DUP","TH5F1_DUP","TH6F1_DUP","TH7F1_DUP"\
,"TH8F1_DUP","TH1F2_DUP","TH2F2_DUP","TH3F2_DUP","TH4F2_DUP","TH5F2_DUP","TH6F2_DUP","TH7F2_DUP","TH8F2_DUP"}

while(1)
waituntil(nextTime) //waits until start time
for (private i=0,i private average=mean(groupA[i][nextTime,nextTime-3599.999]) //can't exactly be a minute
average.time=nextTime //Adds the minute time stamp to the value
groupB[i].AddValue(average) //Adds value to the point listed
endfor
nextTime+=60 //waits until next minute
endwhile

But I get an error on line 12. I guess I have some trouble understanding the group. I thought it was merely a matrix and I could specify the parts of the matrix that I wanted.

Lexington

Link to comment
Share on other sites

I don't know what you are doing. You are combining two completely different things. GroupA is simply a string. If you want to subset the channel with the name that matches that string you have to use evaluate:

evaluate(groupA + "[nexttime, nextTime - 3599.999]")

Same with your addValue, except use execute():

execute(groupB + ".addValue(average)")

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.