1 Star 0 Fork 0

jsshinechow/JW

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
para.c 26.70 KB
一键复制 编辑 原始数据 按行查看 历史
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
//与各种参量有关的函数
extern const u_short _ParaName[] ;
extern u_short dac_line[];
int ChannelParaInit(int mode) /*参数初始化,mode=0当前一个通道,mode=1所有通道,2所有用户*/
{
int retvalue = 1;
int i;
u_char Channel;
int nCurrentUser = GetCurrentUser();
int ChMax = 0, UserMax, temp_ch ;
Dac.num = 0;
Channel = MGetChannel();
if( Channel < C_CHMAX)temp_ch = Channel;
else temp_ch = 0;
UserMax = nCurrentUser + 1;
if(mode == 0)
{
ChMax = Channel + 1;
}
else if (mode > 0)
{
MSaveDefualtColor(0);//设置默认颜色
SystemStatus.option = 0;
SystemStatus.sys = 0;
/*返回值为当前打印机类型1\2\3\4=LQ\HP\EPSON C/P*/
MSetPrinterMode(0,0/*mode = 0*/); /*设置当前打印机类型*/
/*返回值为当前输入法类型1\2\3\4=数字\大写\小写*/
MSetInputMode(C_INPUT_DIGITAL,0/*mode = 0*/); /*设置当前输入法类型*/
/*返回值为当前系统状态1\2\3\4=正常\调节\测试版\特殊版*/
MSetSystemMode(0 ,0/*mode = 0*/); /*设置当前系统状态*/
/*返回值为当前屏幕亮度*/
MSetScreenBrightness(2,C_SETMODE_SETSAVE/*mode = 0*/); /**/
MSetDenoise(0,C_SETMODE_SETSAVE);
MSetRepeatRate(100,C_SETMODE_SETSAVE);
MSetPulseWidth(1,C_SETMODE_SETSAVE);
MSetUnitType(0);
ChMax = C_CHMAX ;
Channel = 0;
if( mode > 1)
{
nCurrentUser = 0;
UserMax = C_USERMAX;
SetUserNumber( C_USERMAX);
}
}
for( ; nCurrentUser < UserMax; nCurrentUser++)
{
if( mode > 0 )
{
SetCurrentUser(nCurrentUser);
SystemParaStore();
Channel = 0;
}
for( ;Channel < ChMax; Channel++)
{
ExpendTime(50);
//Write_Number(0,0,Channel,4,0,0);
ChannelStatus.block = 0;
ChannelStatus.Compensate_ContactLiquid = 0;
ChannelStatus.locomotive = 0;
ChannelStatus.number = 0;
ChannelStatus.object = 0;
ChannelStatus.option = 0;
ChannelStatus.status = 0;
ChannelStatus.sys = 0;
stWeldPara.type = 0;
stWeldPara.face = 0;
stWeldPara.thick1 = 200;
stWeldPara.wide = 250;
stWeldPara.thick2 = 200;
stWeldPara.high1 = 30;
stWeldPara.high2 = 20;
stWeldPara.radius = 0;
stWeldPara.angle1 = 600;
stWeldPara.angle2 = 300;
stWeldPara.deep = 200;
stWeldPara.blunt = 0;
stWeldPara.space = 20;
stWeldPara.probe = 200;
MSetAmpStdMax(80);//回波降落时的标准高度,默认80;
/*返回值为当前屏保类型*/
///MSetScrsaveMode(1,0/*mode = 0*/); /*设置当前屏保类型*/
/*返回值为当前屏保延时,不超过30分钟*/
///MSetScrsaveTime(1,0/*mode = 0*/); /*设置当前屏保延时,不超过30分钟*/
MSetSaveMode(0,C_SETMODE_SETSAVE);//关闭连续记录
MSetSaveStatus( 0,C_SETMODE_SETSAVE);
/*返回值为当前标度1\2\3=垂直\水平\距离*/
MSetScaleMode(0,2/*mode = 0\1\2*/); /*设置当前标度*/
/*返回所用当量标准:母线\判废\定量\评定 */
MSetDacMode(0,0/*mode = 0*/);
/*返回所用当量显示:dB值\孔径 */
MSetAvgMode(1,0/*mode = 0*/);
/*返回所用频带宽度:2.5\5.0\10\wide */
#if C_DEVTYPE == 4 || C_DEVTYPE == 20 || C_DEVTYPE == 5 || C_DEVTYPE == 12
MSetBandMode(3,0/*mode = 0\1\2*/);
#else
MSetBandMode(0,0/*mode = 0\1\2*/);
#endif
/*返回所用探头阻尼:50Q\400Q */
MSetDampMode(1,0/*mode = 0\1\2*/);
/*返回所用发射电压:200V\400V */
MSetPulseMode(2,0/*mode = 0\1\2*/);
/*返回所用检波方式:全波\正半波\负半波\射频 */
MSetEchoMode(0,0/*mode = 0\1\2*/);
/*返回值为当前探头模式0\1\2\3=直\斜\双晶*/
MSetProbeMode(C_APROBE,0/*mode = 0\1\2*/); /*设置探头模式*/
/*返回值为当前测试状态0\1\2\=未测\AVG\DAC\AVG*/
MSetTestStatus(C_TEST_ALL,0);
/*
以下为各种参量的获得与设置
*/
MSetGatePara(C_COORHORIUNIT * 2,C_COORHORIUNIT * 3,120,0,C_SETMODE_SETSAVE);
MSetGatePara(C_COORHORIUNIT * 7,C_COORHORIUNIT * 2,0,1,C_SETMODE_SETSAVE);
MSetGatedB(21, 0);
//设置门
/*返回值为当前通道试件声速: 无小数 */
// if( MGetProbeMode() == C_APROBE)speed = 3230;
// else speed = 5900;
// MSetSpeed(speed,0/*mode = 0\1\2*/); /*设置当前通道 */
/*返回值为当前通道试件声速: 无小数 */
if(MGetProbeMode() != 1) //非斜探头
{
if( MGetUnitType() > 0)MSetSpeed(CD_SPEED_1*1000/254,C_SETMODE_SAVE);//单位inch
else MSetSpeed(CD_SPEED_1,C_SETMODE_SAVE);
}
else
{
if( MGetUnitType() > 0)MSetSpeed(CD_SPEED_2*1000/254,C_SETMODE_SAVE);//单位inch
else MSetSpeed(CD_SPEED_2,C_SETMODE_SAVE);
}
MSetDepth(0,0);
/*返回值为当前通道折射角 一位小数*/
MSetAngle(0,0/*mode = 0\1\2*/); /*设置当前通道 */
/*返回值为当前通道探头前沿长度 一位小数 */
MSetForward(0,0/*mode = 0*/); /*设置当前通道 */
/*返回值为当前通道探头频率 一位小数 */
MSetFrequence(250,0/*mode = 0*/); /*设置当前通道 */
/*返回值为当前通道晶片尺寸 a*256+b */
MSetCrystal(13*256+13,0/*mode = 0*/); /*设置当前通道 */
/*返回值为当前通道基本增益 一位小数 */
MSetBaseGain(450,0/*mode = 0\1\2*/); /*设置当前通道 */
/*返回值为当前通道表面补偿增益 一位小数 */
MSetSurfGain(0,0/*mode = 0\1\2*/); /*设置当前通道 */
/*返回值为当前通道补偿增益 一位小数 */
MSetCompGain(0,0/*mode = 0\1\2*/); /*设置当前通道 */
/*返回值为当前通道 */
for(i = 0; i < 6 ; i++)MSetLineGain(i,0);
/*返回值为当前通道 */
if( MGetUnitType() > 0)MSetRange(5000,C_SETMODE_SETSAVE/*mode = 0\1\2*/); /*设置当前通道 */
else MSetRange(2000,C_SETMODE_SETSAVE/*mode = 0\1\2*/); /*设置当前通道 */
/*返回值为当前通道 */
MSetDelay(0,0/*mode = 0\1\2*/); /*设置当前通道 */
MSetDepthGain(0);
MSetReject(0,0);
/*返回值为当前通道 */
MSetOffset(0,0/*mode = 0\1\2*/); /*设置当前通道 */
MSetFunctionMode(0,C_FUNCTION_ALL);
/*返回所用标准 */
MSetStdMode(0,0/*mode = 0*/);
//MSetStdMode(1,C_SETMODE_SAVE);
MSetCurveNumber(3);
MSetBlock(0);
MSetThick(0);
MSetDiameter(0);
MSetChannel(Channel,0);
ChannelParaStore();
retvalue = C_TRUE;
}
}
//Write_Number(0,10,1,4,0,0);
if( mode > 1)
{
SetCurrentUser(0);
SetUserNumber( 1 );
}
//Write_Number(0,20,2,4,0,0);
MSetChannel(temp_ch,C_SETMODE_SETSAVE);
ChannelParaRestore();
//Write_Number(0,20,3,4,0,0);
MSetSurfGain(0,0/*mode = 0\1\2*/); /*设置当前通道 */
ChannelParaStore();
//Write_Number(0,20,4,4,0,0);
ExpendTime(20);
MSetSystem(); /*设置当前系统各状态*/
//Write_Number(0,20,5,4,0,0);
return retvalue;
}
//门有关的
void MSetGatePara(u_short Posi,u_short Wide,u_short High,int gatetype,int mode)
/*设置门参数,gatetype=0A门1B门*/
{
if (mode == C_SETMODE_SAVE || mode == C_SETMODE_SETSAVE)
{
if(Posi > C_HORIDOT_SCREEN )Posi = C_HORIDOT_SCREEN - 1;
if(Posi + Wide > C_HORIDOT_SCREEN )Wide = C_HORIDOT_SCREEN - 1 - Posi ;
if(High > C_COORHEIGHT )High = C_COORHEIGHT ;
if( gatetype == 0)
{
AGatePara.Position = Posi ;
AGatePara.Width = Wide ;
AGatePara.Height = High ;
}
else if( gatetype == 1)
{
BGatePara.Position = Posi ;
BGatePara.Width = Wide ;
BGatePara.Height = High ;
}
}
if (mode == C_SETMODE_SETSAVE || mode == C_SETMODE_SET)
{
GATE_PARA GatePara;
#if C_DEVLIB == 1
Posi = Posi + HoriOffsetScreen;
#endif
if( MGetEchoMode() == C_RF_WAVE)
{
Posi = ( (Posi+1)/2 ) * 2; //射频是门位必须为双
Wide = ( (Wide+1)/2 ) * 2;
High = ( (High+1)/2 ) * 2;
}
GatePara.Position = Posi ;
GatePara.Width = Wide ;
GatePara.Height = High ;
//if( (MGetBGateMode() == 1 && gatetype == 1) || gatetype == 0 )
#if C_DEVLIB == 4
SetPeakGate(MGetChannel(),&GatePara, gatetype) ;
#else
SetPeakGate(&GatePara, gatetype) ;
#endif
MSetColor(C_CR_WAVE);
//if( MGetBGateMode() != 0 && gatetype == 1)
if( gatetype == 1)
{
//ExpendTime(10);
MSetGatePara(MGetGatePara(0,0),MGetGatePara(0,1),MGetGatePara(0,2),0,C_SETMODE_SET);
}
}
}
u_short MGetGatePara(int gatetype, int paratype) /* 返回值为门参数 */
{
if(gatetype == 0 && paratype == 0)
{
if( AGatePara.Position >= C_COORWIDTH )AGatePara.Position = C_COORWIDTH;
return AGatePara.Position;
}
if(gatetype == 0 && paratype == 1)
{
if( AGatePara.Position > C_COORWIDTH )AGatePara.Position = C_COORWIDTH;
if( AGatePara.Position + AGatePara.Width >= C_GATEPOSIMAX )AGatePara.Width = C_GATEPOSIMAX - AGatePara.Position;
return AGatePara.Width;
}
if(gatetype == 0 && paratype == 2)
{
if( AGatePara.Height > C_COORHEIGHT )AGatePara.Height = C_COORHEIGHT;
return AGatePara.Height;
}
if(gatetype == 1 && paratype == 0)
{
if( BGatePara.Position >= C_COORWIDTH )BGatePara.Position = C_COORWIDTH;
return BGatePara.Position;
}
if(gatetype == 1 && paratype == 1)
{
if( BGatePara.Position > C_COORWIDTH )BGatePara.Position = C_COORWIDTH;
if( BGatePara.Position + BGatePara.Width >= C_GATEPOSIMAX )BGatePara.Width = C_GATEPOSIMAX - BGatePara.Position;
return BGatePara.Width;
}
if(gatetype == 1 && paratype == 2)
{
if( BGatePara.Height > C_COORHEIGHT )BGatePara.Height = C_COORHEIGHT;
return BGatePara.Height;
}
return 0;
}
//DAC gate
int MGetDacDb(void)
{
int offset;
u_short dac_dB;
int basegain;
basegain = MGetBaseGain() + 481.31; //基准增益
offset = C_OFF_DACDB + MGetGatePara(0,0)*C_SIZE_SHORT ; //门位
MCopyProtectedMemory(&dac_dB, (void*)offset, C_SIZE_SHORT, PM_COPY_READ);
//dacdB:在DAC母线门位处的dB值
dac_dB = basegain - dac_dB;
return dac_dB;
}
int DacGate_dBHigh(int dB,int dac_dB)//门与母线的dB差,DACdB值
{
//int offset;
int gatehigh;
MSetGatedB(dB, 0);
gatehigh = (int)pow(10,(float)(dB+dac_dB)/200.0);
if(gatehigh >= C_COORHEIGHT ) gatehigh = C_COORHEIGHT - 1 ;
return gatehigh;
}
void DacGateInit(void)
{
int offset;
int dac_dB,gate_dB;
int basegain;
int gatehigh;
int i;
int dist1,dist2;
int step = 14;
dac_dB = MGetDacDb(); //dacdB:在DAC母线门为处的dB值
gate_dB = MGetGatedB();
gatehigh = DacGate_dBHigh(gate_dB,dac_dB);//门与母线的dB差,DACdB值
MSetGatePara( MGetGatePara(0,0),MGetGatePara(0,1),gatehigh,0,C_SETMODE_SETSAVE);
basegain = MGetBaseGain() + 481.31 + gate_dB; //基准增益
offset = C_OFF_DACDB;
MCopyProtectedMemory( dac_line, (void*)offset, C_LEN_DACDB, PM_COPY_READ);
dist2 = 0;
dac_line[dist2] = (int)pow( 10,( basegain - dac_line[dist2] )/200.0) ;
while(dist2 <= C_COORWIDTH)
{
dist1 = dist2;
dist2 += step;
dac_line[dist2] = (int)pow( 10,( basegain - dac_line[dist2] )/200.0) ;
GetLine_TwoDot(dac_line,dist1,dist2);
}
for(i = 0 ; i < C_SCREEN_WIDTH; i ++ )
{
if(dac_line[i] >= C_COORHEIGHT)dac_line[i] = C_COORHEIGHT - 1;
}
offset = C_OFF_DACGATE;
MCopyProtectedMemory((void*)offset, dac_line, C_LEN_DACDB, PM_COPY_WRITE);
}
void DACGatedB(void) //DAC门dB差
{
int offset;
int basegain;
u_short Height;
u_short gatedB;
basegain = MGetBaseGain() + 481.31; //基准增益
offset = C_OFF_DACDB + MGetGatePara(0,0); //门位
MCopyProtectedMemory(&gatedB, (void*)offset, C_SIZE_SHORT, PM_COPY_READ);
Height = (int) pow(10,(basegain - gatedB)/200.0) / pow(10, MGetGatedB()/200.0) ;
}
//其他通道参量有关的函数
void MSetPara(int bgain,int cgain,int sgain,int scale,int range,int offset,int delay,int angle,int speed)
{
int mode = C_SETMODE_SETSAVE;
if( bgain >= 0 && bgain < C_MAX_BASEGAIN)MSetBaseGain(bgain,mode);
else MSetBaseGain(CD_BASEGAIN,mode);
if( cgain >= 0)MSetCompGain(cgain,mode);
else MSetCompGain(CD_COMPGAIN,mode);
if( sgain >= 0)MSetSurfGain(sgain,mode);
else MSetSurfGain(CD_SURFGAIN,mode);
if( scale >= 0 && scale < 3)MSetScaleMode(scale,mode);
else MSetScaleMode(0,mode);
if( angle >= 0 && angle < C_MAX_ANGLE)MSetAngle(angle,mode);
else MSetAngle(0,mode);
if( speed >= C_MIN_SPEED && speed < C_MAX_SPEED)MSetSpeed(speed,mode);
else if( MGetAngle(0) > 200 )MSetSpeed(CD_SPEED_1,mode);//横波
else MSetSpeed(CD_SPEED_2,mode);//纵波
if( range >= C_MIN_RANGE && range < C_MAX_RANGE )MSetRange(range,mode);
else MSetRange(CD_RANGE,mode);
if( offset >= 0 && offset < C_MAX_OFFSET)MSetOffset(offset,mode);
else MSetOffset(0,mode);
if( delay >= 0 && delay < C_MAX_DELAY)MSetDelay(delay,mode);
else MSetDelay(0,mode);
}
u_short MGetThick(void)//得到工件厚度
{
return ChannelPara.Thick;
}
void MSetThick(u_short thick)//设置工件厚度
{
ChannelPara.Thick = thick;
}
u_short MGetDiameter(void)//得到工件直径
{
return ChannelPara.Diameter;
}
void MSetDiameter(u_short Diameter)//设置工件直径
{
ChannelPara.Diameter = Diameter;
}
u_short MGetOffset(void) /*返回值为当前通道 */
{
if( ChannelPara.Offset > C_MAX_OFFSET)MSetOffset(0,C_SETMODE_SAVE);
return ChannelPara.Offset;
}
void MSetOffset(u_int Offset,int mode/*mode = 0\1\2*/) /*设置当前通道 */
{
if (mode == C_SETMODE_SAVE || mode == C_SETMODE_SETSAVE)
{
ChannelPara.Offset = Offset;
}
if (mode == C_SETMODE_SETSAVE || mode == C_SETMODE_SET)
{
Offset = ( Offset + MGetDelay(0) )/2;
if( MGetProbeMode() == C_P_TRANSMISSION)Offset /= 2;
#if C_DEVLIB == 4
SetEchoDelay(MGetChannel(), Offset) ;
#else
SetEchoDelay( Offset ) ;
#endif
}
}
u_short MGetSpeed(void) /*返回值为当前通道试件声速: 无小数 */
{
if( ChannelPara.Speed > C_MAX_SPEED)ChannelPara.Speed = C_MAX_SPEED;
else if( ChannelPara.Speed < C_MIN_SPEED)ChannelPara.Speed = C_MIN_SPEED;
// if( MGetUnitType() > 0)
{//单位inch
/// return (u_short)( ChannelPara.Speed*100/25.4+0.5);
}
// else
{//单位mm
return ChannelPara.Speed;
}
}
void MSetSpeed(u_short Speed,int mode/*mode = 0\1\2*/) /*设置当前通道 */
{
if (mode == C_SETMODE_SETSAVE || mode == C_SETMODE_SET)
{
float range = (float)(MGetRange(0) * Speed )/ (C_SAMPLE_FREQ);
MSetRange( (int)(range+0.5),C_SETMODE_SAVE);
}
if (mode == C_SETMODE_SAVE || mode == C_SETMODE_SETSAVE)
{
ChannelPara.Speed = Speed;
}
}
u_short MGetAngle(u_int mode) /*返回值为当前通道折射角0角度1正切2正弦3余弦 一位小数*/
{
u_int retvalue = ChannelPara.Angle;
float angle = (float)retvalue * C_PI/1800.0; //角度化为弧度
switch (mode)
{
case 1://k值
retvalue = (int)(tanf(angle) * 10000.0 + 0.5);
break;
case 2://水平
retvalue = (int)(sinf(angle) * 10000.0 + 0.5);
break;
case 3://垂直
retvalue = (int)(cosf(angle) * 10000.0 + 0.5);
break;
case 4://k值
retvalue = (int)(sinf(angle) * 10000.0/cosf(angle) + 0.5);
break;
}
return retvalue;
}
void MSetAngle(u_short Angle,int mode) /*设置当前通道 */
{
ChannelPara.Angle = Angle;
}
int MGetDepth()
{
return ChannelPara.depth;
}
void MSetDepth(int depth,int mode)
{
ChannelPara.depth = depth;
}
u_short MGetKvalue(void) /*返回值为当前通道K值 两位小数 */
{
float Angle = ChannelPara.Angle;
if( Angle > 810 ) return 999;
else
{
Angle = (ChannelPara.Angle)*C_PI/1800.0;
return (int)(tan(Angle)*100+0.5);
}
}
void MSetKvalue(u_short Kvalue,int mode/*mode = 0\1\2*/) /*设置当前通道 */
{
ChannelPara.Angle = (int)( atan( (float)Kvalue/100.0) *1800/C_PI + 0.5);
}
u_short MGetForward(void) /*返回值为当前通道探头前沿长度 一位小数 */
{
return ChannelPara.Forward;
}
void MSetForward(u_short Forward,int mode/*mode = 0*/) /*设置当前通道 */
{
ChannelPara.Forward = Forward;
}
u_short MGetFrequence(void) /*返回值为当前通道探头频率 一位小数 */
{
if( ChannelPara.Frequence > 0)
return ChannelPara.Frequence;
else return 5;
}
void MSetFrequence(u_short Frequence,int mode/*mode = 0*/) /*设置当前通道 */
{
ChannelPara.Frequence = Frequence;
if( C_DEVLIB != 3)
{
if( Frequence < 400 )MSetBandMode(0,C_SETMODE_SETSAVE);
else if( Frequence < 800 )MSetBandMode(1,C_SETMODE_SETSAVE);
else if( Frequence < 1200 )MSetBandMode(2,C_SETMODE_SETSAVE);
else MSetBandMode(3,C_SETMODE_SETSAVE);
}
}
u_short MGetCrystal(void) /*返回值为当前通道晶片尺寸 a*256+b */
{
return ChannelPara.Crystal;
}
void MSetCrystal(u_short Crystal,int mode/*mode = 0*/) /*设置当前通道 */
{
ChannelPara.Crystal = Crystal;
}
int MGetNearField(void) //得到近场区长度
{
short number = MGetCrystal()/256; //晶片尺寸的低8位,如为0则是直探头,用直径计算
if( number == 0)number = MGetCrystal()%256;
if( ( MGetCrystal()%256 ) == 0)number *= ( MGetCrystal()/256 ) ;
else number *= ( MGetCrystal()%256 ) ;
if( number == 0)number = 25;
if( MGetUnitType() > 0)
{//单位inch
return ( 100 * number * MGetFrequence() )/(4 * MGetSpeed()*254/1000 );
}
else
{
return ( 100 * number * MGetFrequence() )/(4 * MGetSpeed() );
}
}
float MGetAttenuate(int depth)
{
float att = 0;
return att;
}
u_int MGetRange(int mode) /*返回值为当前标度下的声程范围 */
{
if( ChannelPara.Range > C_MAX_RANGE)MSetRange(1000,C_SETMODE_SAVE);
u_int retvalue = ChannelPara.Range ; //
if( mode == -1)
{//展宽前声程
retvalue = ChannelPara.OldRange ;
}
else if( mode == -2)
{//展宽前声程
retvalue = ChannelPara.Range ;
}
if(mode > 0) //返回当前标度下声程
{
if( mode == 3)return retvalue; //返回距离声程
else if( mode == 4)return (retvalue * MGetAngle(3))/10000; //余弦,垂直
else if( mode == 5)return (retvalue * MGetAngle(2))/10000; //正弦,水平
switch ( MGetScaleMode() )
{
case 0: //垂直
retvalue = (retvalue * MGetAngle(3))/10000; //余弦
break;
case 1: //水平
retvalue = (retvalue * MGetAngle(2))/10000; //正弦
break;
case 2: //距离
break;
}
}
else if( mode == 0)
{ //返回声程点
int offset = C_OFF_TEMP+42;
CopyProtectedMemory( &retvalue, (void*)offset, C_SIZE_INT, PM_COPY_READ);
}
if( MGetUnitType() > 0)
{//单位inch
/// retvalue = (u_int)( retvalue*100/25.4+0.5);
}
return retvalue;
}
extern int iItem;
///extern AXLE_PROBE probe;
void MSetRange(int Range,int mode/*mode = 0\1\2*/) /*设置当前通道 */
{
if( mode == -1)
{//展宽前声程
ChannelPara.OldRange = Range;
return;
}
else if( mode == -2)
{
ChannelPara.Range = Range;
return;
}
switch ( MGetScaleMode() )
{
case 0: //垂直
Range = (u_int)( Range * 10000.0 / MGetAngle(3) + 0.5); //余弦
break;
case 1: //水平
Range = (u_int)( Range * 10000.0 / MGetAngle(2) + 0.5); //正弦
break;
case 2: //距离
break;
}
if (mode == C_SETMODE_SAVE || mode == C_SETMODE_SETSAVE)
{
if(Range >= C_MAX_RANGE) Range = C_MAX_RANGE;
ChannelPara.Range = Range;
}
if (mode == C_SETMODE_SETSAVE || mode == C_SETMODE_SET)
{
u_int speed = MGetSpeed();
u_int rm = C_MAX_RANGE*90/100;
if( MGetSpeed() < CD_SPEED_2 * 110/100 && MGetProbeMode() == C_APROBE)rm /= 2;
if(Range >= rm) Range = rm + (Range - rm)*60/100;
if((iItem==7/*||probe.Part==7*/)/*&&Range>=42000*/) Range = (200*50 * Range + speed/2)/speed;
else Range = (C_SAMPLE_FREQ * Range + speed/2)/speed;
if( MGetProbeMode() == C_P_TRANSMISSION)Range >>= 1;
MSetEchoRange(Range);
MSetColor(C_CR_WAVE);
int offset = C_OFF_TEMP+42;
MCopyProtectedMemory( (void*)offset, &Range, C_SIZE_INT, PM_COPY_WRITE);
}
}
u_int MGetDelay(int mode) /*返回值为当前通道 */
{
if( ChannelPara.Delay > C_MAX_DELAY ) MSetDelay(0,C_SETMODE_SAVE);
u_int retvalue = ChannelPara.Delay ; //延时时间,单位1/80 000 ms
if( mode == -1)return ChannelPara.OldDelay;//展宽前延时
else if( mode == -2)return ChannelPara.Delay;
if(mode != 0) //返回当前标度下延时距离
{
retvalue = retvalue * MGetSpeed() /( C_SAMPLE_FREQ ); //单位为mm,带一位小数
if(mode == 3)return retvalue; //此模式下直接返回延时距离
switch ( MGetScaleMode() )
{
case 0: //垂直
retvalue = retvalue * MGetAngle(3)/10000; //余弦
break;
case 1: //水平
retvalue = retvalue * MGetAngle(2)/10000; //正弦
break;
case 2: //距离
break;
}
}
return retvalue;
}
void MSetDelay(int Delay,int mode/*mode = 0\1\2*/) /*设置当前通道 */
{
if( mode == -1 )
{//展宽前延时
ChannelPara.OldDelay = Delay;
return;
}
else if( mode == -2)
{
ChannelPara.Delay = Delay;
return;
}
if (mode == C_SETMODE_SAVE || mode == C_SETMODE_SETSAVE)
{
ChannelPara.Delay = Delay;
}
if (mode == C_SETMODE_SETSAVE || mode == C_SETMODE_SET)
{
MSetSystemDelay();
}
}
void MSetScaleDelay(int Delay,int mode/*mode = 0\1\2*/) /*设置当前标度下的延时距离 */
{
switch ( MGetScaleMode() )
{
case 0: //垂直
Delay = ( Delay * 10000 + MGetAngle(3)/2 ) / MGetAngle(3); //余弦
break;
case 1: //水平
Delay = ( Delay * 10000 + MGetAngle(2)/2 ) / MGetAngle(2); //正弦
break;
case 2: //距离
break;
}
//if( Delay + MGetRange(3) > C_MAX_RANGE) Delay = C_MAX_RANGE - MGetRange(3);
Delay = ( Delay * C_SAMPLE_FREQ + MGetSpeed()/2 )/(int)MGetSpeed();
MSetDelay(Delay,mode);
}
u_short MGetReject(void) /*返回值为当前通道 */
{
if( ChannelPara.Reject < C_MAX_REJECT)return ChannelPara.Reject;
else return C_MAX_REJECT;
}
void MSetReject(u_short Reject,int mode/*mode = 0\1\2*/) /*设置当前通道 */
{
if( Reject > 800 )Reject = 800;
if (mode == C_SETMODE_SAVE || mode == C_SETMODE_SETSAVE)
{
ChannelPara.Reject = Reject;
}
if (mode == C_SETMODE_SETSAVE || mode == C_SETMODE_SET)
{
#if C_DEVLIB == 4
SetEchoReject(MGetChannel(), Reject);
#else
SetEchoReject(Reject);
#endif
}
}
u_short MGetSysGain(void) //得到总体增益
{
if( ChannelPara.SurfGain + ChannelPara.BaseGain + ChannelPara.CompGain > C_MAX_SYSGAIN)
{
ChannelPara.SurfGain = ChannelPara.CompGain = 0;
ChannelPara.BaseGain = 450;
}
return ( ChannelPara.SurfGain + ChannelPara.BaseGain + ChannelPara.CompGain );
}
u_short MGetSurfGain(void) /*返回值为当前通道表面补偿增益 一位小数 */
{
if (ChannelPara.SurfGain > C_MAX_SURFGAIN)ChannelPara.SurfGain = 0;
return ChannelPara.SurfGain;
}
int MSetSurfGain(u_short SurfGain,int mode/*mode = 0\1\2*/) /*设置当前通道 */
{
if (SurfGain > C_MAX_SURFGAIN)
{
ChannelPara.SurfGain = 0;
return C_FALSE;
}
if ( (MGetBaseGain() + MGetCompGain() + SurfGain ) > C_MAX_BASEGAIN)return C_FALSE;
if (mode == C_SETMODE_SAVE || mode == C_SETMODE_SETSAVE)
{
ChannelPara.SurfGain = SurfGain;
}
if (mode == C_SETMODE_SETSAVE || mode == C_SETMODE_SET)
{
MSetSystemGain();
}
return C_TRUE;
}
u_short MGetBaseGain(void) /*返回值为当前通道基本增益 一位小数 */
{
return ( ( ChannelPara.BaseGain > C_MAX_BASEGAIN)? C_MAX_BASEGAIN : ChannelPara.BaseGain );
}
int MSetBaseGain(short BaseGain,int mode/*mode = 0\1\2*/) /*设置当前通道 */
{
if( BaseGain < 0 )BaseGain = 0;
if( BaseGain > C_MAX_BASEGAIN )BaseGain = C_MAX_BASEGAIN ;
if (mode == C_SETMODE_SAVE || mode == C_SETMODE_SETSAVE)
{
ChannelPara.BaseGain = BaseGain;
}
if (mode == C_SETMODE_SETSAVE || mode == C_SETMODE_SET)
{
u_short gain = BaseGain + MGetSurfGain() + MGetCompGain() ;
if (gain > C_MAX_BASEGAIN)gain = C_MAX_BASEGAIN;
// if (gain > 1000)gain = 1000 + (gain - 1000)/2;
// if (gain > 900)gain = 900 + (gain - 900)/2;
// if (gain > MAX_GAIN_DB)gain = MAX_GAIN_DB;
MSetAmplifierGain(gain);
}
return C_TRUE;
}
short MGetGatedB(void) /*返回值为当前通道DAC门 一位小数*/
{
return ChannelPara.gatedB;
}
void MSetGatedB(short gatedB, int mode/*mode = 0*/) //DAC门dB差
{
ChannelPara.gatedB = gatedB;
}
short MGetCompGain(void) /*返回值为当前通道补偿增益 一位小数 */
{
return ( ( ChannelPara.CompGain > C_MAX_BASEGAIN)? C_MAX_BASEGAIN : ChannelPara.CompGain );
}
int MSetCompGain(short CompGain,int mode/*mode = 0\1\2*/) /*设置当前通道 */
{
if( CompGain > C_MAX_BASEGAIN)CompGain = C_MAX_BASEGAIN;
if (mode == C_SETMODE_SAVE || mode == C_SETMODE_SETSAVE)
{
ChannelPara.CompGain = CompGain;
}
if (mode == C_SETMODE_SETSAVE || mode == C_SETMODE_SET)
{
MSetSystemGain();
u_short gain = CompGain + MGetSurfGain() + MGetBaseGain();
if (gain > C_MAX_BASEGAIN)gain = C_MAX_BASEGAIN;
// if (gain > 1000)gain = 1000 + (gain - 1000)/2;
// if (gain > 900)gain = 900 + (gain - 900)/2;
// if (gain > MAX_GAIN_DB)gain = MAX_GAIN_DB;
MSetAmplifierGain(gain);
}
return 0;
}
u_short MGetDepthGain(void)
{
return ChannelPara.DepthGain;
}
void MSetDepthGain(u_short gain)//设置无DAC/AVG时深度补偿值
{
if( gain > 300 )gain = 300;
ChannelPara.DepthGain = gain;
}
short MGetLineGain(int line)//得到曲线的偏移量
{
line %= 6;
return ChannelPara.lineGain[line] ;
}
void MSetLineGain(int line,short gain)//设置曲线的偏移量
{
int i;
line %= 6;
ChannelPara.lineGain[line] = gain ;
for( i = line+1; i < 6 ; i++)
{
if( ChannelPara.lineGain[i] > gain ) ChannelPara.lineGain[i] = gain;
}
for( i = line-1; i >= 0 ; i--)
{
if( ChannelPara.lineGain[i] < gain ) ChannelPara.lineGain[i] = gain;
}
}
void MSetSystemGain(void) /*设置当前增益 */
{
u_short gain = MGetBaseGain() + MGetSurfGain() + MGetCompGain() ;
//; if (gain > 1100)gain = 1100 + (gain - 1100)/2;
//; if (gain > 1000)gain = 1000 + (gain - 1000)/2;
//; if (gain > C_MAX_BASEGAIN)gain = C_MAX_BASEGAIN;
MSetAmplifierGain(gain);
}
void MSetSystemRange(void) /*设置当前声程 */
{ /*SAMPLE_FREQ*1000*RANGE/SPEED */
u_int range = MGetRange(3);
u_int speed = MGetSpeed();
u_int rm = C_MAX_RANGE*90/100;
if( MGetSpeed() < CD_SPEED_2 * 110/100 && MGetProbeMode() == C_APROBE)rm /= 2;
if(range >= rm) range = rm + (range - rm)*60/100;
range = (C_SAMPLE_FREQ * range + speed/2)/speed;
if( MGetProbeMode() == C_P_TRANSMISSION)range >>= 1;
MSetEchoRange( range ) ;
MSetColor(C_CR_WAVE);
}
void MSetSystemDelay(void) /*设置当前延时或零点 */
{
u_int edelay = ( MGetDelay(0) + MGetOffset() ) /2;
if( MGetProbeMode() == C_P_TRANSMISSION)edelay /= 2;
#if C_DEVLIB == 4
SetEchoDelay(MGetChannel(), edelay ) ;
#else
SetEchoDelay( edelay ) ;
#endif
}
void MSetSystemBright(void) /*设置当前屏幕亮度*/
{
u_int cur_bright = 0,obj_bright = C_BRIGHTNESS_COM;
int mode;
cur_bright = 0;
obj_bright = C_BRIGHTNESS_COM;
mode = 0;
#if C_DEVLIB == 1 || C_DEVLIB == 3 || C_DEVLIB == 23 || C_DEVLIB == 24
switch ( MGetScreenBrightness() )
{
case 0:
obj_bright = C_BRIGHTNESS_MIN;
break;
case 1:
obj_bright = C_BRIGHTNESS_COM;
break;
case 2:
obj_bright = C_BRIGHTNESS_MID;
break;
case 3:
obj_bright = C_BRIGHTNESS_MAX;
break;
}
#endif
#if C_DEVLIB == 1
do
{
cur_bright = AdjustBrightness(0) ;/*得到当前亮度*/
mode = obj_bright - cur_bright;
AdjustBrightness(mode) ;
}while( mode != 0 );
#elif C_DEVLIB == 3
//Write_Number(10,30,1,4,0,0);
SetLCDBrightness(obj_bright) ;
#elif C_DEVLIB == 24
SetELBrightness(obj_bright) ;
#endif
}
int MSetSystemProbe(void)
{
int Ax = MGetProbeMode() -0 ;
int i;
if (Ax != C_DPROBE)
{
Ax = T_T_SINGLE;
for(i=0;i<=120;i++)GainTable[i] = c_gaintable[0][i];//初试化增益表
}
else
{
Ax = T_R_DUAL;
for(i=0;i<=120;i++)GainTable[i] = c_gaintable[1][i];//初试化增益表
}
#if C_DEVLIB == 4
SetProbeMode( MGetChannel(), Ax) ;
#else
SetProbeMode(Ax) ;
#endif
return C_TRUE;
}
void MSetSystem(void) /*设置当前系统各状态*/
{
#if C_DEVLIB == 4
SetEchoReject(MGetChannel(), MGetReject());
#else
SetEchoReject(MGetReject());
#endif
#if C_DEVLIB != 3
#if C_DEVLIB == 4
SetAmplifierBand( MGetChannel(), MGetBandMode() + AMP_BAND_NARROW_1);
#else
SetAmplifierBand( MGetBandMode() + AMP_BAND_NARROW_1);
#endif
MSetPulseMode( MGetPulseMode(), C_SETMODE_SET);
//SetTransmitterVoltage( MGetPulseMode() + LOW_PULSE ) ;
#else
if( MGetPulseMode() > 0)SetTransmitterVoltage(HIGH_PULSE) ;
else SetTransmitterVoltage(LOW_PULSE) ;
#endif
#if C_DEVLIB == 4
SetProbeDamping( MGetChannel(), MGetDampMode() + LOW_DAMPING) ;
#else
MSetDampMode( MGetDampMode() ,C_SETMODE_SET) ;
#endif
#if C_DEVLIB == 4
SetEchoMode( MGetChannel(), MGetEchoMode() + FULL_WAVE ) ;
#elif C_DEVLIB == 3
if( MGetEchoMode() == 0 )SetEchoMode( FULL_WAVE ) ;
else SetEchoMode( RF_WAVE ) ;
#else
SetEchoMode( MGetEchoMode() + FULL_WAVE ) ;
#if C_DEVLIB == 23 || C_DEVLIB == 24
if( MGetEchoMode()%4 == 3)SetEchoBaseLine( c_RFBaseLine);
else SetEchoBaseLine( c_FWBaseLine);
#endif
#endif
MSetGatePara( MGetGatePara(1,0),MGetGatePara(1,1),MGetGatePara(1,2),1,C_SETMODE_SETSAVE);
MSetGatePara( MGetGatePara(0,0),MGetGatePara(0,1),MGetGatePara(0,2),0,C_SETMODE_SETSAVE);
MSetSystemGain();
MSetSystemRange();
MSetSystemDelay();
MSetSystemBright();
MSetSystemProbe();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jsshinechow/JW.git
[email protected]:jsshinechow/JW.git
jsshinechow
JW
JW
master

搜索帮助