到这里我们有了一个taper类,它通过父类的形式交给程序来调用,并且它需要的两个参数也已经输入了。这时各位看官该关心dllParTemplate这个文件了,这是个文本文件,用记事本或者vim什么打开,这里把关于taper的部分贴出来。
TAPER :\n taper amplitudes on top or bottom or both sides. #模块名 说明文字
@radio,Choose Taper Side|Top|Bottom|Both Sides,2; #用@分隔,后面为参数表
#参数间用分号;分隔
int,Taper Length(ms),200&
其中第一个参数的外观为Radio button的形式,它的标签为choose taper side,它有三个选项,默认选项为2;第二个参数为int形式,标签taper length(ms),默认为200。GeoSong从dllParTemplate中读取到了这些信息,为这个模块创建外观如下。
这是一个动态的过程,也就是说你可以根据需要在dllParTemplate中规定自己模块的形式,而独立于GeoSong程序本身。GeoSong目前提供有整数,浮点数,字符串,文本,输入文件路径,输出文件路径,单选,多选和表格等形式,基本上可以实现各种参数输入的需要。上面的例子使用了其中单选和整数两种形式。
当选择top时,系统给模块传递0,选择bottom时传递1,选择both时传递2。参数传递由GeoSong来完成,那么我们就专心写好自己的执行程序就好。这个模块的实现过程很简单。
TAPER::TAPER()
{
option=2;
taperLength=0;
}
TAPER::~TAPER()
{
}
int TAPER::exec(Gs10_gather **gatherIN, Gs10_gather **gatherOUT, Gs10_gather **gatherTMP)
{
if((*gatherIN)==0||(*gatherIN)->traceNum==0) return 0;
(*gatherIN)->scanMuTime();
int traceNum=(*gatherIN)->traceNum;
int sampleNum=(*gatherIN)->sampleNum;
int traceSampleNum=sampleNum+60;
int intervalUM=(*gatherIN)->intervalUM;
int taperSamples=taperLength*1000/intervalUM;
float *buff=(float *)(*gatherIN)->traces;
int startSample,endSample;
float scaller[taperSamples];
for(int i=0;i<taperSamples;i++)
scaller
=(float)(i+1)/taperSamples;
if(option==0||option==2)
for(int i=0;i<traceNum;i++)
{
startSample=(*gatherIN)->getHeader2I(i+1,111)*1000/intervalUM;
endSample =(startSample+taperSamples-1<sampleNum-1)?startSample+taperSamples-1:sampleNum-1;
for(int j=startSample;j<=endSample;j++)
buff[i*traceSampleNum+j+60]*=scaller[j-startSample];
}
if(option==1||option==2)
for(int i=0;i<traceNum;i++)
{
endSample=(*gatherIN)->getHeader2I(i+1,113)*1000/intervalUM;
startSample =(endSample-taperSamples+1>0)?endSample-taperSamples+1:0;
for(int j=startSample;j<=endSample;j++)
buff[i*traceSampleNum+j+60]*=scaller[endSample-j];
}
*gatherOUT=*gatherIN;
return 1;
}
这么看来,做一个模块是不是很简单啊,对于一个新使用GeoSong的朋友来说,唯一一点点的麻烦就是exec函数的第二行用到Gs10_gather类的scanMuTime函数,去翻看一下这个函数的意义而已。