代码拉取完成,页面将自动刷新
// display.c
/*
int DrawPower(u_char powerlevel,int mode) //画电量指示,mode = 0立即1每分钟更新一次
void SysParaDisp(void) //显示通道号、探头类型、频带等
*/
#include "Globe.h"
#include "display.h"
#include "sysdef.h"
#include "common.h"
#include "main.h"
extern int g_nDenoise;
GATE_AMPMAX stGateAmpMax;
;
CURVE_AMEND stCurveAmend;
extern u_short dac_line[];
extern WELD_PARA stWeldPara;
extern ADJUST_TIME AdjustTime;
extern int HoriOffsetScreen ; //所有写在屏幕上的内容,水平方向开始点
extern int VertOffsetScreen ; //所有写在屏幕上的内容,水平方向开始点
extern DAC Dac;
extern int extend ;
//色彩
extern CHANNEL_PARAMETER ChannelPara; /*15*2*/
extern int curr_cr;
u_char crPara[C_CR_MAX+10];
const u_int c_crPara[] =
{
0x007,//红
0x0c7,//粉红
0x03f,//黄
0x038,//绿
0x0f8,//青
0x0c0,//蓝
0x084,//紫
0x0ff,//白
0x000,//黑
};
/*
颜色设置
1。回波
2。包络
3。菜单
4。参量
5。坐标
6。门A
7。门B
8。提示
9。曲线
红粉黄绿青兰紫白
//*/
extern const u_char PowerTable[] ;
extern const u_int _RANGEVALUE[];
extern const u_int _ParaName[];
u_char tempvalue;
int DrawPower(u_char powerlevel,int mode) //画电量指示,mode = 0立即1每分钟更新一次
{
u_int xpos,ypos;
int startchargetime;
int offset;
int elapsedtime = GetElapsedTime() / 1000; //当前时间,单位s
/* get the return value from battery management
the return vaule: b0 -> battery charge fast(1) or trickle(0) ,;
b1 -> battery charge on(1) or off(0) ;
b2 -> battery connected(1) or disconnected(0) ;
b3 -> DC adapter connected(1) or disconnected(0) ;
b8-b15 -> battery capacity value < 32
低8位与高8位应交换
*/
///if( MGetSystemMode() == 1)return -1;
if( MGetAcquisitionEnable() != 1)return -1;
if (elapsedtime < 60 )return 0; //开机60s之内
if( mode != 0 ) //没有要求立即更新
{
//if (elapsedtime < 60 || elapsedtime%60 > 1 )return 0; //开机60s之内、不是整分钟
if( MGetSystemMode() == 1 )return 0; //测试状态不画电池
}
///Write_Number(10,30,GetBatteryStatus()%256,4,0,0);
///Write_Number(10,40,GetBatteryStatus()/256,4,0,0);
u_char powerstatus = (GetBatteryStatus() / 256)%16; //得到电池状态,d3-d0
int i,j;
offset = C_OFF_BATTERY + 40; //开始充电时间
MCopyProtectedMemory( &startchargetime, (void*)offset, C_SIZE_INT, PM_COPY_READ);
MSetColor(C_CR_MENU);
MEraseWindow(C_POWER_HPOSI, C_POWER_VPOSI, C_POWER_HPOSI + 10, C_POWER_VPOSI + 28) ;
xpos = C_POWER_HPOSI;
ypos = C_POWER_VPOSI + 7 ;
DrawRectangle(xpos,ypos,xpos + 10,ypos+20); //画电池反壳
for(i = 1 ; i < 5; i++)
{
MDrawLine( xpos + 1, ypos + 4 * i ,xpos + 1, ypos + 4 * i );
}
xpos += 2;
ypos += 20;
#if C_DEVLIB == 3
//V1,电池信息与其他不同
///if( ( powerstatus & 0x1 ) != 0 ) //d1表示在充电
if( false )
#else
if( ( powerstatus & 0x2 ) != 0 ) //d1表示在充电d0表示快充
#endif
{
int chargedtime = (elapsedtime - startchargetime)/60; //已充时间,单位为分钟
if (( powerstatus & 0x1 ) != 0)
{
//在快充
i = chargedtime / 6 + 1; //快充一般为100-120分钟
if( i > 16 ) i = 16;
j = chargedtime/60;
if(j > 2 )j = 0;
else j = 2 - j;
}
else
{
//为慢充
if(chargedtime > 60 * 3)i = 19; //充电长达3小时,应已充满
else if(chargedtime > 150)i = 18;
else i = 17;
j = 0;
}
for( ; i > 0; i--) //画电量
MDrawLine(xpos,ypos - i,xpos+7,ypos - i);
xpos = C_POWER_HPOSI + 5 ;
ypos = C_POWER_VPOSI ;
while( ypos < C_POWER_VPOSI + 5 -j)
{
MDrawLine(xpos - j,ypos,xpos + j,ypos);
ypos++;
}
for(i=j+1; i >= 0 ; i--,ypos++)
MDrawLine(xpos - i,ypos,xpos + i,ypos);
// for(i=0;i<= 2 * j ;i++)
// MDrawLine(xpos,ypos+i,xpos + 2 * j,ypos+i);
}
else //不在充电
{
for(i=0; i < 10; i++)
{
if( powerlevel >= PowerTable[i] )break;
}
//if( i >= 10 && ( (powerstatus & 0x0c) == 0 ) && powerlevel > 0 ) DisplayPrompt(1); //d3=0表示未联充电器//提示电量不足
if( i >= 10 && ( (powerstatus & 0x08) == 0 ) && powerlevel > 0 && elapsedtime >= 60 * 2)
DisplayPrompt(1); //d3=0表示未联充电器//提示电量不足
if( i > 0) i = ( 10 - i) * 2 ; //反过来,从下往上画
else i = 19; //满电
MSetColor(C_CR_PARA);
for( ; i > 0; i--) //画电量
MDrawLine(xpos,ypos - i,xpos+7,ypos - i);
xpos = C_POWER_HPOSI + 4;
ypos = C_POWER_VPOSI + 4;
MSetColor(C_CR_MENU);
MDrawLine(xpos,ypos,xpos+2,ypos);
MDrawLine(xpos,ypos+1,xpos,ypos+2);
MDrawLine(xpos+2,ypos+1,xpos+2,ypos+2);
}
if( extend == 0)
{
xpos = C_POWER_HPOSI;
ypos = C_COORVPOSI+1 ;
Write_Number(xpos,ypos,powerlevel,2,0,0);
}
return 1;
}
const char _ProbeFace[] =
{
0x00,0x00,0x07,0x04,0x04,0x04,0x04,0x3f,
0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,
0x00,0x00,0xf0,0x10,0x10,0x10,0x10,0xfe,
0x80,0x80,0x80,0xc0,0xc0,0x80,0x00,0x00,
0x00,0x00,0x07,0x04,0x04,0x04,0x04,0x3f,
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xf0,0x10,0x10,0x10,0x10,0xfe,
0x00,0x80,0x40,0x20,0x18,0x18,0x00,0x00,
0x00,0x00,0x3e,0x22,0x22,0x22,0x7f,0x10,
0x08,0x04,0x02,0x01,0x07,0x00,0x00,0x00,
0x00,0x00,0x3e,0x22,0x22,0x22,0x7f,0x08,
0x10,0x20,0x40,0x80,0xe0,0x00,0x00,0x00,
0x00,0x00,0x03,0x02,0x02,0x0f,0x00,0x00,
0x00,0x0f,0x02,0x02,0x03,0x00,0x00,0x00,
0x00,0x00,0xe0,0x20,0x20,0xf8,0x80,0x80,
0x80,0xf8,0x20,0x20,0xe0,0x00,0x00,0x00
};
const unsigned char _KeyLock[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x08,
0x08,0x08,0x08,0x08,0x08,0x0f,0x00,0x00,
0x00,0x00,0x30,0x48,0x48,0x40,0xf0,0x10,
0x10,0x10,0x10,0x10,0x10,0xf0,0x00,0x00,
0x00,0x00,0x01,0x02,0x02,0x02,0x0f,0x08,
0x08,0x08,0x08,0x08,0x08,0x0f,0x00,0x00,
0x00,0x00,0x80,0x40,0x40,0x40,0xf0,0x10,
0x10,0x10,0x10,0x10,0x10,0xf0,0x00,0x00,
};
extern const u_char _ParaMenu_AD3[] ;
//输入8* X的字符
void MUserDotsOut(short x,short y, u_char *pDots, u_int ydots)
{
MEraseWindow(x,y,x+8,y+ydots);
{
int i,j;
for( i = 0 ; i < ydots; i++)
{
for( j = 7; j >= 0; j--)
{
if( ((pDots[i] >> j)&0x01) > 0)MDrawPixel(x+7-j,y,DP_SET);
}
y++;
}
}
}
void SysParaDisp(void) //显示通道号、探头类型、频带等
{
int rect_xpos,rect_ypos; //框所再位置
int xpos,ypos;
u_short pzChn[] = {CH(4508),CH(2132)}; //通道
u_short *cpText;
u_char *epText;
int i;
int char_len,char_row,char_height;
u_short Channel = MGetChannel();
//if( MGetSystemMode() == 1 )return; //测试状态不显示相关信息
rect_xpos = C_COORWIDTH ;
rect_ypos = C_COORVPOSI ;
// MDrawLine( rect_xpos , rect_ypos ,rect_xpos , rect_ypos + 198 );
MEraseWindow(C_COORWIDTH+1, C_COORVPOSI+1, C_HORIDOT_VIDEO-10, C_COORVPOSI + C_COORHEIGHT - 2) ;
DrawPower( ( GetBatteryStatus()%256 ) ,0); //立即更新电池
ypos = rect_ypos + 40;
MSetColor(C_CR_MENU);
for(i = 4; i <= 28 ; i += 4)
MDrawLine( C_COORWIDTH + i , C_COORVPOSI+40,C_COORWIDTH + i+1, C_COORVPOSI+40 );
char_len = 1;
char_row = 2,char_height = 20;
cpText = pzChn;
///CMenuOut(xpos,ypos,cpText,char_len,char_row,char_height);//写通道两字
xpos = C_CHANNEL_HPOSI;
ypos = C_CHANNEL_VPOSI-40;
epText = (u_char *)_KeyLock+MGetKeyLock()*32;
cpText = (u_short *)(_KeyLock+MGetKeyLock()*32);
/*for (i = 0; i < 1; i++)
{
#if C_DEVLIB != 23
UserECharOut(xpos + HoriOffsetScreen, ypos , (char*)(epText+i*16)) ;
UserECharOut(xpos + HoriOffsetScreen, ypos +8, (char*)(epText+8+i*16)) ;
UserECharOut(xpos + HoriOffsetScreen+8, ypos , (char*)(epText+1*16)) ;
UserECharOut(xpos + HoriOffsetScreen+8, ypos +8, (char*)(epText+8+1*16)) ;
#else
MUserDotsOut(xpos,ypos,(u_char*)(epText+i*8),8);
MUserDotsOut(xpos,ypos+8,(u_char*)(epText+i*8+8),8);
MUserDotsOut(xpos+8,ypos,(u_char*)(epText+i*16+16),8);
MUserDotsOut(xpos+8,ypos+8,(u_char*)(epText+i*16+24),8);
#endif
xpos += 8;
}//显示键盘锁*/
ypos = rect_ypos + 80;
for(i = 4; i <= 28 ; i += 4)
MDrawLine( rect_xpos+i , ypos,rect_xpos + i+1, ypos );
////////////
xpos = C_CHANNEL_HPOSI;
ypos = C_CHANNEL_VPOSI;
MSetColor(C_CR_PARA);
if(Channel >= 10)
Write_Number(xpos,ypos +4,Channel,2,0,0);
else
{
Channel = CH(Channel+316); //316为0的区位码
cpText = &Channel;
char_row = 1;
CMenuOut(xpos,ypos,cpText,char_len,char_row,char_height);
} //以上为写通道号
ypos = ypos + char_height;
WriteProbe(MGetProbeMode()-0, xpos, ypos);
ypos = rect_ypos + 40*3;
for(i = 4; i <= 28 ; i += 4)
MDrawLine( rect_xpos+i , ypos,rect_xpos + i, ypos );
xpos -= 4;
MSetColor(C_CR_MENU);
METextOut(xpos+4,ypos+10,"FB",2);
ypos = ypos + char_height+4;
//char_height = 12;
epText = (u_char*)_ParaMenu_AD3 + ( (MGetBandMode()-0)*9+3 );
MSetColor(C_CR_PARA);
EMenuOut(xpos,ypos,epText,3,1,char_height); // 频带宽度:2.5\5.0\10\wide
ypos = rect_ypos + 40*4+1;
for(i = 4; i <= 28 ; i += 4)
MDrawLine( rect_xpos+i , ypos,rect_xpos + i+1, ypos );
MSetColor(C_CR_MENU);
METextOut(xpos,ypos+10,"REJ",3);
ypos = ypos + char_height + 4;
i = ( MGetReject() + 1)/2;
MSetColor(C_CR_PARA);
if( i < 10)
{
METextOut(xpos,ypos," ",3);
Write_Number(xpos+4,ypos,i,1,0,0);
MSetColor(C_CR_MENU);
METextOut(xpos+12,ypos,"%",1);
}
else
{
Write_Number(xpos,ypos,i,2,0,0);
MSetColor(C_CR_MENU);
METextOut(xpos+16,ypos,"%",1);
}
}
void WriteProbe(int type, int xpos, int ypos)
{
if(type>=3) return;///机务只显示直 斜 双晶
int i,v,h;
// int x,y;
u_char *probe;
probe = (u_char *)_ProbeFace + type * 32;
v = xpos;//+HoriOffsetScreen;
h = ypos + VertOffsetScreen;
for (i = 0; i < 2; i++)
{
#if C_DEVLIB != 23
UserECharOut(v, h, (char*)(probe+i*16)) ;
UserECharOut(v, h+8, (char*)(probe+8+i*16)) ;
#else
MUserDotsOut(v,h,(u_char*)(probe+i*16),16);
#endif
v+= 8;
}
}
//各种参量调节函数
int MAdjustGain(u_int type,u_int mode,short low,short high)
/*调节增益,type=0系统增益=1补偿;mode=0立即此值越大自动调节所需时间越长,high高度*/
{
u_int gatetype = 0;
int gain ;
int retvalue = C_FALSE;
int step = 1;
short gateamp;
int TC_GateAmpMax = 230;
int TC_HighMax;
int TC_LowMin;
//short preamp;
if( low == high)
{
low--;
high++;
}
TC_HighMax = (high*110)/100 ;
TC_LowMin = (low*90)/100;
TC_HighMax = ( TC_HighMax < TC_GateAmpMax ) ? TC_HighMax : TC_GateAmpMax;
gateamp = Mabsi( MGetAmpMax(gatetype) );
if( mode > 0)
{
if( gateamp > 100 )AdjustTime.GainPlusTime = 0;//波高大于100,小于140不自动调节波高
if( gateamp <140 )AdjustTime.GainMinusTime = 0;
}
if ( AdjustTime.GainMinusTime >= ( mode * C_GAINMINUSTIME) || gateamp > TC_GateAmpMax) /*增益减*/
{
gain = ( type == 0)? MGetBaseGain() : MGetSysGain();
if( gateamp > high && gain >0)
{
while(gain > 0 && MGetSysGain() > 0 )
{
AdjustTime.amp_total = AdjustTime.amp_total2 = 0;
AdjustTime.time = AdjustTime.time2 = 0;
gateamp = Mabsi( MGetAmpMax(gatetype));
if(gateamp <= high)break;
ExpendTime(5);
if(gateamp > TC_GateAmpMax) step = 20;
else if(gateamp > TC_HighMax)step = 5;
else step = 1;
if(type == 0)
{
BaseGainMinus(step);
WriteBaseGain(C_BASEGAIN_HPOSI,C_BASEGAIN_VPOSI);
gain = MGetBaseGain();
}
else
{
CompGainMinus(step);
WriteCompGain(C_COMPGAIN_HPOSI,C_COMPGAIN_VPOSI);
gain = MGetSysGain();
}
MParaRenovate(0);
if(MGetKeyCode(5) == C_KEYCOD_RETURN)break;
// if( Mabsi(pregain - gain) > 10 && Mabsi(preamp - gateamp) < 5 && preamp > 10 )break;
//当增益变化大于1dB时,波高变化小于5且原波高大于10则退出
}
AdjustTime.GainMinusTime = 0;
retvalue = C_TRUE;
}
}
if ( retvalue == C_FALSE && ( AdjustTime.GainPlusTime >= mode * C_GAINPLUSTIME ) ) /*增益加*/
{
gain = MGetSysGain();
if( gateamp < low && gain < C_MAX_BASEGAIN && gain < C_MAX_ADJUSTGAIN)
{
while( gateamp < low && gain < C_MAX_ADJUSTGAIN)
{
ExpendTime(5);
AdjustTime.amp_total = AdjustTime.amp_total2 = 0;
AdjustTime.time = AdjustTime.time2 = 0;
gateamp = Mabsi( MGetAmpMax(gatetype) ) ;
if(gateamp < 10 )step = 20;
else if( gateamp < TC_LowMin)step = 5;
else step = 1;
if(type == 0)
{
BaseGainPlus(step);
WriteBaseGain(C_BASEGAIN_HPOSI,C_BASEGAIN_VPOSI);
MParaRenovate(0);
}
else
{
CompGainPlus(step);
WriteCompGain(C_COMPGAIN_HPOSI,C_COMPGAIN_VPOSI);
MParaRenovate(0);
}
gain = MGetSysGain();
if(MGetKeyCode(5) == C_KEYCOD_RETURN)break;
// if( Mabsi(pregain - gain) > 10 && Mabsi(preamp - gateamp) < 5 && preamp > 10 )break;
}
AdjustTime.GainPlusTime = 0;
retvalue = C_TRUE;
}
}
if( retvalue == C_TRUE)MSetColor(C_CR_WAVE);
return retvalue;
}
void WriteParaName(u_int ParaIndex) /*根据参量索引号写参量名*/
{
u_short* pzText;
MEraseWindow(0, 0, 17*C_ECHAR_HDOT, 17) ;
pzText = (u_short*)_ParaName + ParaIndex*4;
DisplayPrompt(15);
MSetColor(C_CR_MENU);
CMenuOut(0,0,pzText,4,1,24); /*在指定位置根据每行字符数、行数、行高写菜单*/
}
int MSelectPrompt(int keycode)//在退出参数调节时判断是否要显示提示
{
switch( keycode)
{
case C_KEYCOD_OFFSET:
case C_KEYCOD_ANGLE:
case C_KEYCOD_BASEGAIN:
case C_KEYCOD_RANGE:
case C_KEYCOD_SPEED:
case C_KEYCOD_GATE:
case C_KEYCOD_DELAY:
return 1;
default :
DisplayPrompt(16);
return 0;
}
}
int ChannelChange(void)
{
int xpos,ypos;
int keycode,rotary;
u_short Channel;
xpos = C_CHANNEL_HPOSI;
ypos = C_CHANNEL_VPOSI;
MInvertWindow(C_CHANNEL_HPOSI, C_CHANNEL_VPOSI-2, C_CHANNEL_HPOSI+C_CCHAR_HDOT, C_CHANNEL_VPOSI+20*1-2) ;
SystemParaStore();
ChannelParaStore();
//ExpendTime(30);
while(1)
{
ExpendTime(10);
keycode = MGetKeyCode(0);
MParaRenovate(0);
if(keycode == C_KEYCODMAX)
{
rotary = MGetRotary(-1);
if( rotary >= 128)
{
rotary = 0;
keycode = C_KEYCOD_CONFIRM;
}
else if( rotary > 0 )keycode = C_KEYCOD_PLUS;
else if( rotary < 0)keycode = C_KEYCOD_MINUS;
else continue;
}
if(GetNoKeyTime() > 60 && MGetSystemMode() == 1)break;
//在自动测试状态下未按超过60s则超出参量调节状态
/*有按键*/
if(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS )
{
MSetDacShowMode( 0,C_SETMODE_SAVE);
Channel = MGetChannel();
if(keycode == C_KEYCOD_PLUS )Channel++;
else
{
#if C_MAKELIB == 1
if( Channel == 0)Channel = C_CHMAX/2;
#else
if( Channel == 0)Channel = C_CHMAX;
#endif
Channel--;
}
#if C_MAKELIB == 1
if( Channel >= C_CHMAX/2)Channel = 0;
#else
if( Channel >= C_CHMAX)Channel = 0;
#endif
SystemParaRestore();
MSetChannel( Channel,C_SETMODE_SETSAVE);
SystemParaStore();
ChannelParaRestore();
MActivateDac(MGetFunctionMode(C_DEPTH_COMPENSATE) ) ;
MSetSystem();
ScreenRenovate(); /*屏幕刷新*/
MSaveSystemElapsedTime( GetElapsedTime() / (1000*60), C_TIME_MINUTE );
DrawDac(0);
MInvertWindow(C_CHANNEL_HPOSI, C_CHANNEL_VPOSI-2, C_CHANNEL_HPOSI+C_CCHAR_HDOT, C_CHANNEL_VPOSI+20*1-2) ;
}
else
{
if(keycode == C_KEYCOD_CHANNEL || keycode == C_KEYCOD_CONFIRM)
{
//MInvertWindow(C_CHANNEL_HPOSI, C_CHANNEL_VPOSI-2, C_CHANNEL_HPOSI+C_CCHAR_HDOT, C_CHANNEL_VPOSI+20*3-2) ;
///if( MGetParaLock(1,C_LOCK_CHANNEL) != 1)
{
ChannelMenu();
return -1;
}
}
else if(keycode < C_KEYCODMAX && keycode >=0)
{
MSelectPrompt(keycode);
MInvertWindow(C_CHANNEL_HPOSI, C_CHANNEL_VPOSI-2, C_CHANNEL_HPOSI+C_CCHAR_HDOT, C_CHANNEL_VPOSI+20*1-2) ;
return keycode;
}
}
}
MInvertWindow(C_CHANNEL_HPOSI, C_CHANNEL_VPOSI-2, C_CHANNEL_HPOSI+C_CCHAR_HDOT, C_CHANNEL_VPOSI+20*1-2) ;
return keycode;
}
int BaseGainPlus(int step) /*增益根据步长增加*/
{
int retvalue = C_TRUE;
int basegain = MGetBaseGain();
int elsegain = MGetSurfGain() + MGetCompGain();
if( step < 0)BaseGainMinus( -1 * step);
else
{
basegain += step;
if (basegain + elsegain > C_MAX_BASEGAIN)
{
basegain = C_MAX_BASEGAIN - elsegain;
DisplayPrompt(3);
retvalue = C_FALSE;
}
MSetBaseGain(basegain,C_SETMODE_SETSAVE) ;
}
return retvalue;
}
int BaseGainMinus(int step) /*增益根据步长*/
{
int retvalue = C_TRUE;
int basegain = MGetBaseGain();
int elsegain = MGetSurfGain() + MGetCompGain();
if( step < 0)BaseGainPlus( -1 * step);
else
{
if (basegain < step || (basegain+elsegain < step) )
{
basegain = step;
DisplayPrompt(3);
retvalue = C_FALSE;
}
basegain -= step;
if (basegain + elsegain < 0 )basegain = 0 - elsegain ;
MSetBaseGain(basegain,C_SETMODE_SETSAVE) ;
}
return retvalue;
}
int CompGainPlus(int step) /*增益根据步长增加*/
{
int retvalue = C_TRUE;
if( step < 0)CompGainMinus( -1 * step);
else
{
if( step == 0)
{
// MAdjustGain(1,0,120,120);
}
else
{
int compgain = MGetCompGain() ;
int elsegain = MGetSurfGain() + MGetBaseGain();
compgain += step;
if (compgain + elsegain > C_MAX_BASEGAIN)
{
compgain = C_MAX_BASEGAIN - elsegain;
DisplayPrompt(3);
retvalue = C_FALSE;
}
MSetCompGain(compgain,C_SETMODE_SETSAVE) ;
}
}
return retvalue;
}
int CompGainMinus(int step) /*增益根据步长*/
{
int retvalue = C_TRUE;
int compgain = MGetCompGain() ;
int elsegain = MGetSurfGain() + MGetBaseGain();
if( step < 0)CompGainPlus( -1 * step);
else
{
if( step == 0)
{
// compgain = 0;
}
else
{
if (compgain+elsegain < step)
{
compgain = step - elsegain;
DisplayPrompt(3);
retvalue = C_FALSE;
}
compgain -= step;
}
MSetCompGain(compgain,C_SETMODE_SETSAVE) ;
}
return retvalue;
}
int GainChange(void)
{
int retvalue = C_TRUE;
int keycode,rotary;
//int prekeycode = C_KEYCODMAX;
int step = MGetParaStep(C_BASEGAIN);
//int type = MGetParaSort(C_BASEGAIN); //代改参数0系统,1补偿
int type ;
//int inv_xpos,inv_ypos;
u_int time = 20;
if( MGetEquivalentDays(1) > 0 )type = 0;
else type = MGetParaSort(C_BASEGAIN); //代改参数0系统,1补偿;
ClearEnvelope(); //清包络或峰值
if(type == 0)
{
if(step == 0)step = ParaStepChange(C_BASEGAIN); //系统增益步长不设为0
InvertBytes(C_BASEGAIN_HPOSI, C_BASEGAIN_VPOSI, 4) ;
}
else
{
//扫查增益开始步长固定0
step = 0;
InvertBytes(C_COMPGAIN_HPOSI, C_COMPGAIN_VPOSI, 5) ;
}
if( MGetStdMode() == C_STD_AWS_NUM )type = 1;
while(1)
{
if(type == 0)
WriteParaName(C_BASEGAIN);
else
WriteParaName(C_COMPGAIN);
Write_Number(4*C_CCHAR_HDOT,C_ECHAR_VDOT,step,3,1,0);
while(1)
{
keycode = MGetKeyCode(0);
if(GetNoKeyTime() > 60 && MGetSystemMode() == 1)return retvalue;
//在自动测试状态下未按超过60s则超出参量调节状态
MParaRenovate(1);
if(keycode == C_KEYCODMAX)
{
continue;
}
else rotary = 1;
time = 10;
/*有按键*/
time = C_KEYDELAY;
if(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS )
{
if(MGetFunctionMode(C_DAC_GATE))MDrawGate(0,0,-1,0);
if(type == 0||type == 1)DrawDac(1);
do
{
if( step == 1)
{
}
else rotary = step;
if( MGetTestStatus(C_TEST_DAC) == 0 && MGetTestStatus(C_TEST_AVG) == 0)
{
if(time > 20)time -= 5;
else time -= 3;
if(time < 5)time = 5;
if(step > 1)time = 20;
}
else
{
if( type == 0 )time = 5;
}
ExpendTime(time);
if(type == 0)
{
if(keycode == C_KEYCOD_PLUS)BaseGainPlus(rotary);
else BaseGainMinus(rotary);
WriteBaseGain(C_BASEGAIN_HPOSI,C_BASEGAIN_VPOSI);
InvertBytes(C_BASEGAIN_HPOSI, C_BASEGAIN_VPOSI, 4) ;
}
else
{
if(keycode == C_KEYCOD_PLUS)
{
if( step == 0)
{
MAdjustGain(1,0,MGetAmpStdMax(),MGetAmpStdMax());
}
else CompGainPlus(rotary);
}
else
{
if( step == 0)MSetCompGain(0,C_SETMODE_SETSAVE);
else CompGainMinus(rotary);
}
WriteCompGain(C_COMPGAIN_HPOSI,C_COMPGAIN_VPOSI);
InvertBytes(C_COMPGAIN_HPOSI, C_COMPGAIN_VPOSI, 5);
}
//if( keycode != MGetKeyCode(0) )break;
if( keycode != MGetKey2() )break;
}
while( true );
if(type == 0||type==1)DrawDac(0);
if( MGetFunctionMode(C_DAC_GATE) == 1)
{
DacGateInit();
//;MGateDraw();
MDrawGate(0,0,-1,0);//改为只变A门,即DAC门
}
continue;
}
else
{
if(keycode == C_KEYCOD_BASEGAIN)
{
if(type == 0 )step = ParaStepChange(C_BASEGAIN); //系统增益步长不设为0
else if( type == 1 )step = ParaStepChange(C_COMPGAIN); //设置待调节参量步长
ExpendTime(20);
}
else if(keycode == C_KEYCOD_CONFIRM )//&& !MGetSystemMode() ) //设置成测试状态)
{
MSetParaSort(type + 1,C_BASEGAIN);
type = MGetParaSort(C_BASEGAIN); //代改参数0系统,1补偿
if(type == 0 )step = MGetParaStep(C_BASEGAIN);
if(type == 1 )step = 0;//变为调节增益时步长改为0
InvertBytes(C_BASEGAIN_HPOSI, C_BASEGAIN_VPOSI, 4) ;
InvertBytes(C_COMPGAIN_HPOSI, C_COMPGAIN_VPOSI, 5) ;
ExpendTime(20);
}
else if(keycode == C_KEYCOD_CONFIRM && type != 0 )//&& MGetSystemMode()) //设置成测试状态)
{
MSetParaSort(0,C_BASEGAIN);
type = 0; //代改参数0系统,1补偿
step = MGetParaStep(C_BASEGAIN);
InvertBytes(C_BASEGAIN_HPOSI, C_BASEGAIN_VPOSI, 4) ;
InvertBytes(C_COMPGAIN_HPOSI, C_COMPGAIN_VPOSI, 5) ;
ExpendTime(20);
}
else
{
MSelectPrompt(keycode);
retvalue = false;
}
break;
}
break;
}
if( !retvalue ) break;
}
if(type == 0)
WriteBaseGain(C_BASEGAIN_HPOSI,C_BASEGAIN_VPOSI);
else
WriteCompGain(C_COMPGAIN_HPOSI,C_COMPGAIN_VPOSI);
if(keycode == C_KEYCOD_RETURN || keycode == C_KEYCOD_CONFIRM)
{
keycode = -1;
DisplayPrompt(16);
}
else DisplayPrompt(15);
ClearEnvelope(); //清包络或峰值
return keycode;
}
int RejectChange(void)
{
int retvalue = C_TRUE;
int keycode,rotary;
int step = 1;
u_int time = C_KEYDELAY;
ClearEnvelope(); //清包络或峰值
WriteParaName(C_REJECT);
EMenuOut(C_CCHAR_HDOT * 4, C_ECHAR_VDOT,"%",1,1,12);
ExpendTime(30);
do
{
WriteReject(4*C_CCHAR_HDOT,0);
SysParaDisp();
while(1)
{
time=C_KEYDELAY;
ExpendTime(time);
keycode = MGetKeyCode(0);
MParaRenovate(1);
if(GetNoKeyTime() > 60 && MGetSystemMode() == 1)return -1;
//在自动测试状态下未按超过60s则超出参量调节状态
if(keycode == C_KEYCODMAX)
{
#if C_ROTARY > 0
rotary = MGetRotary(-1);
if( rotary >= 128)
{
rotary = 0;
keycode = C_KEYCOD_CONFIRM;
}
else if( rotary > 0 )
{
keycode = C_KEYCOD_PLUS;
}
else if( rotary < 0)
{
keycode = C_KEYCOD_MINUS;
rotary = (-1) * rotary;
}
else continue;
#else
continue;
#endif
}
else rotary = 1;
///if(keycode < C_KEYCODMAX && keycode >=0)
{
/*有按键*/
if(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS )
{
do
{
if(time > 20)time -= 5;
else time -= 3;
if(time < 3)time = 2;
ExpendTime(time);
if(keycode == C_KEYCOD_PLUS)RejectPlus(rotary*step);
else RejectMinus(rotary*step);
WriteReject(4*C_CCHAR_HDOT,0);
ExpendTime(5);
MParaRenovate(1);
if( keycode != MGetKeyCode(0) )break;
}
while( true );
}
else
{
if( ( keycode == C_KEYCOD_REJECT || keycode == C_KEYCOD_CONFIRM) && MGetSystemMode() != 1)
{
keycode = DelayChange(1);
if( keycode == C_KEYCOD_CONFIRM)break;
else
{
MSelectPrompt(keycode);
SysParaDisp();
return keycode;
}
}
else
{
MSelectPrompt(keycode);
SysParaDisp();
return keycode;
}
break;
}
break;
}
}
if( !retvalue ) break;
}
while (1);
if(keycode == C_KEYCOD_RETURN || keycode == C_KEYCOD_CONFIRM)
{
keycode = -1;
DisplayPrompt(16);
}
else DisplayPrompt(15);
SysParaDisp();
return keycode;
}
int RejectPlus(int step)
{
u_int reject = MGetReject();
if (reject >= C_MAX_REJECT)
{
DisplayPrompt(3);
MSetReject(C_MAX_REJECT,C_SETMODE_SETSAVE) ;
return C_FALSE;
}
reject++;
MSetReject(reject,C_SETMODE_SETSAVE) ;
return C_TRUE;
}
int RejectMinus(int step)
{
u_int reject = MGetReject();
if (reject == 0)
{
DisplayPrompt(3);
MSetReject(0,C_SETMODE_SETSAVE) ;
return C_FALSE;
}
reject--;
MSetReject(reject,C_SETMODE_SETSAVE) ;
return C_TRUE;
}
int OffsetChange(void)
{
if( MGetParaLock(1,C_LOCK_OFFSET) == 1)
{
TestMenu(); //开始调校程序
DisplayPrompt(16);
return -1;
}
int retvalue = C_TRUE;
int keycode,rotary=1;
int step = 1;
u_int time = C_KEYDELAY;
ClearEnvelope(); //清包络或峰值
WriteParaName(C_OFFSET);
EMenuOut(C_CCHAR_HDOT * 4, C_ECHAR_VDOT,"us",2,1,12);
//ExpendTime(10);
do
{
WriteRange(C_RANGE_HPOSI,C_RANGE_VPOSI);
//InvertBytes(C_RANGE_HPOSI, C_RANGE_VPOSI, 5) ;
WriteOffset(4*C_CCHAR_HDOT,0);
if(step==1)
{
TextOut(7*C_CCHAR_HDOT+4,0,1,4,8,"0.01",0);
}
else
{
TextOut(7*C_CCHAR_HDOT+4,0,1,4,8,"0.1 ",0);
}
while(1)
{
time=C_KEYDELAY;
ExpendTime(time);
MParaRenovate(1);
keycode = MGetKeyCode(0);
if(keycode == C_KEYCODMAX)
{
continue;
}
else rotary = 1;
if(GetNoKeyTime() > 60 && MGetSystemMode() == 1)return -1;
//在自动测试状态下未按超过60s则超出参量调节状态
/*有按键*/
if(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS )
{
do
{
if(time > 20)time -= 5;
else time -= 3;
if(time < 3)time = 2;
ExpendTime(time);
///if( rotary < 3)rotary = 1;
///else if( rotary < 8)rotary = 10;
///else rotary = 20;
if(keycode == C_KEYCOD_PLUS)
{
OffsetPlus(rotary*step);
///if(step==1)
///{
/// Write_Number(4*C_CCHAR_HDOT,0,MGetOffset()*10/16+1,5,2,0);
///}
///else WriteOffset(4*C_CCHAR_HDOT,0);
}
else
{
OffsetMinus(rotary*step);
///if(step==1)
///{
/// Write_Number(4*C_CCHAR_HDOT,0,MGetOffset()*10/16-1,5,2,0);
///}
///else WriteOffset(4*C_CCHAR_HDOT,0);
}
WriteOffset(4*C_CCHAR_HDOT,0);
MParaRenovate(1);
if( keycode != MGetKeyCode(0) )break;
}
while( true );
MKeyRlx();
}
else if(keycode == C_KEYCOD_OFFSET)
{
if(step==1) step=16;
else if(step==16) step=1;
}
else
{
if( ( /*keycode == C_KEYCOD_OFFSET || */keycode == C_KEYCOD_CONFIRM) && MGetSystemMode() != 1)
{
DisplayPrompt(15);
///TestMenu(); //开始调校程序
DisplayPrompt(16);
return -1;
}
else
{
MSelectPrompt(keycode);
return keycode;
}
break;
}
break;
}
if( !retvalue ) break;
}
while (1);
if(keycode == C_KEYCOD_RETURN || keycode == C_KEYCOD_CONFIRM)
{
keycode = -1;
DisplayPrompt(16);
}
else DisplayPrompt(15);
return retvalue;
}
int OffsetPlus(int step)
{
u_int offset = MGetOffset();
if (offset >= C_MAX_OFFSET)
{
DisplayPrompt(3);
MSetOffset(C_MAX_OFFSET,C_SETMODE_SETSAVE) ;
return C_FALSE;
}
offset += step;
MSetOffset(offset,C_SETMODE_SETSAVE) ;
MSetTestStatus(C_TEST_OFFSET,0); //设置测试状态,零点声速未测
return C_TRUE;
}
int OffsetMinus(int step)
{
u_int offset = MGetOffset();
if (offset <= step)
{
DisplayPrompt(3);
MSetOffset(0,C_SETMODE_SETSAVE) ;
return C_FALSE;
}
offset -= step;
MSetOffset(offset,C_SETMODE_SETSAVE) ;
MSetTestStatus(C_TEST_OFFSET,0); //设置测试状态,零点声速未测
return C_TRUE;
}
int SpeedChange(int stdok)
{
if( MGetParaLock(1,C_LOCK_OFFSET) == 1)
{
STDMenu(); //开始调校程序
DisplayPrompt(16);
return -1;
}
int retvalue = C_TRUE;
int keycode,rotary;
u_int time = C_KEYDELAY;
int step = MGetParaStep(C_SPEED);
ClearEnvelope(); //清包络或峰值
WriteParaName(C_SPEED);
do
{
WriteSpeed(8*C_ECHAR_HDOT,0);
Write_Ascii(4*C_CCHAR_HDOT,C_ECHAR_VDOT,'-');
Write_Number(4*C_CCHAR_HDOT+C_ECHAR_HDOT,C_ECHAR_VDOT,step,1,0,0);
WriteRange(C_RANGE_HPOSI,C_RANGE_VPOSI);
while(1)
{
time = C_KEYDELAY;
ExpendTime(time);
MParaRenovate(1);
keycode = MGetKeyCode(0);
if(keycode == C_KEYCODMAX)
{
#if C_ROTARY > 0
rotary = MGetRotary(-1);
if( rotary >= 128)
{
rotary = 0;
keycode = C_KEYCOD_CONFIRM;
}
else if( rotary > 0 )
{
keycode = C_KEYCOD_PLUS;
}
else if( rotary < 0)
{
keycode = C_KEYCOD_MINUS;
rotary = (-1) * rotary;
}
else continue;
#else
continue;
#endif
}
else rotary = 1;
if(GetNoKeyTime() > 60 && MGetSystemMode() == 1)return -1;
//在自动测试状态下未按超过60s则超出参量调节状态
//if(keycode < C_KEYCODMAX && keycode >=0)
{
/*有按键*/
if(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS )
{
do
{
if( step == 1)
{
/// if( rotary <= 2)rotary = 1;
/// else if( rotary <=8)rotary = 10;
/// else rotary = 20;
}
else if( step == 2)
{
rotary = 50;
}
else
{
step = 1;
rotary = 1;
}
if(keycode == C_KEYCOD_PLUS)SpeedPlus(rotary * step);
else SpeedMinus(rotary*step);
WriteSpeed(8*C_ECHAR_HDOT,0);
Write_Ascii(4*C_CCHAR_HDOT,C_ECHAR_VDOT,'-');
Write_Number(4*C_CCHAR_HDOT+C_ECHAR_HDOT,C_ECHAR_VDOT,step,1,0,0);
WriteRange(C_RANGE_HPOSI,C_RANGE_VPOSI);
WriteScale();
if(time > 20)time -= 5;
else time -= 3;
if(time < 3)time = 2;
ExpendTime(time);
if( keycode != MGetKeyCode(0) )break;
}
while( true );
}
else
{
if(keycode == C_KEYCOD_SPEED)
step = ParaStepChange(C_SPEED); //设置待调节参量步长
else if( keycode == C_KEYCOD_CONFIRM && stdok)
{
DisplayPrompt(15);
STDMenu(); //开始调校程序
DisplayPrompt(16);
return -1;
}
else
{
MSelectPrompt(keycode);
return keycode;
}
break;
}
break;
}
}
if( !retvalue ) break;
}
while (1);
//InvertBytes(22*C_ECHAR_HDOT,0, 4) ;
if(keycode == C_KEYCOD_RETURN || (keycode == C_KEYCOD_CONFIRM&&stdok))
{
keycode = -1;
DisplayPrompt(16);
}
else DisplayPrompt(15);
ClearEnvelope(); //清包络或峰值
return retvalue;
}
int SpeedPlus(int step)
{
u_int speed = MGetSpeed();
speed += step;
if (speed >= C_MAX_SPEED)
{
DisplayPrompt(3);
speed = C_MAX_SPEED;
}
MSetSpeed(speed,C_SETMODE_SETSAVE);
MSetTestStatus(C_TEST_OFFSET,0); //设置测试状态,零点声速未测
return C_TRUE;
}
int SpeedMinus(int step)
{
u_int speed = MGetSpeed();
if (speed < C_MIN_SPEED)
{
DisplayPrompt(3);
return C_FALSE;
}
speed -= step;
MSetSpeed(speed,C_SETMODE_SETSAVE) ;
MSetTestStatus(C_TEST_OFFSET,0); //设置测试状态,零点声速未测
return C_TRUE;
}
int RangeChange(void)
{
int retvalue = C_TRUE;
//int keycode,prekeycode = C_KEYCODMAX;
int keycode,rotary;
int step = MGetParaStep(C_RANGE);
int time = 15;
ClearEnvelope(); //清包络或峰值
do
{
WriteParaName(C_RANGE + MGetScaleMode() );
Write_Ascii(4*C_CCHAR_HDOT,C_ECHAR_VDOT,'-');
Write_Number(4*C_CCHAR_HDOT+C_ECHAR_HDOT,C_ECHAR_VDOT,step,1,0,0);
InvertBytes(C_RANGE_HPOSI, C_RANGE_VPOSI, 5) ;
while(1)
{
time = C_KEYDELAY;
ExpendTime(time);
keycode = MGetKeyCode(0);
MParaRenovate(1);
if(keycode == C_KEYCODMAX)
{
continue;
}
else rotary = 1;
if(GetNoKeyTime() > 60 && MGetSystemMode() == 1)return -1;
//在自动测试状态下未按超过60s则超出参量调节状态
/*有按键*/
if(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS )
{
if(MGetFunctionMode(C_DAC_GATE))MDrawGate(0,0,-1,0);
DrawDac(1);
do
{
if( rotary < 3 || step == 2)rotary = 1;
if(keycode == C_KEYCOD_PLUS)RangePlus(rotary*step);
else RangeMinus(rotary*step);
WriteRange(C_RANGE_HPOSI,C_RANGE_VPOSI);
// InvertBytes(C_RANGE_HPOSI, C_RANGE_VPOSI, 5) ;
WriteScale(); //标度
if(time > 20)time -= 5;
else time -= 3;
if(time < 3)time = 2;
ExpendTime(time);
if( keycode != MGetKeyCode(0) )break;
}
while( true );
DrawDac(0);
if( MGetFunctionMode(C_DAC_GATE) == 1)
{
DacGateInit();
MDrawGate(0,0,-1,0);
}
}
else if(keycode == C_KEYCOD_RANGE)
{
step = ParaStepChange(C_RANGE); //设置待调节参量步长
InvertBytes(C_RANGE_HPOSI, C_RANGE_VPOSI, 5) ;
}
else if(keycode == C_KEYCOD_CONFIRM)
{
//if( MGetAngle(0) == 0)MSetScaleMode(0,0);
//else MSetScaleMode(MGetScaleMode()+0,0);
MSetScaleMode(MGetScaleMode()+1,0);
u_char ch;
switch (MGetScaleMode() )
{
case 0:
Write_Ascii(C_RANGE_HPOSI + 8 * C_ECHAR_HDOT,C_RANGE_VPOSI+ 0,'Y');
ch = 'z' + 11;
break;
case 1:
Write_Ascii(C_RANGE_HPOSI + 8 * C_ECHAR_HDOT,C_RANGE_VPOSI+ 0,'X');
ch = 'z' + 10;
break;
default:
Write_Ascii(C_RANGE_HPOSI + 8 * C_ECHAR_HDOT,C_RANGE_VPOSI+ 0,'S');
ch = 'z' + 9;
break;
}
if( MGetBGateMode() ==1 )
{
Write_Ascii(2*8,C_COORVPOSI - 10,ch);
Write_Ascii(22*8,C_COORVPOSI - 10,ch);
}
MParaRenovate(1);
WriteParaName(C_RANGE + MGetScaleMode() - 0);
WriteRange(C_RANGE_HPOSI,C_RANGE_VPOSI);
ExpendTime(20);
}
else
{
WriteRange(C_RANGE_HPOSI,C_RANGE_VPOSI);
MSelectPrompt(keycode);
return keycode;
}
break;
}
if( !retvalue ) break;
WriteScale(); //标度
}
while (1);
if(keycode == C_KEYCOD_RETURN || keycode == C_KEYCOD_CONFIRM)
{
keycode = -1;
DisplayPrompt(16);
}
else DisplayPrompt(15);
;
WriteRange(C_RANGE_HPOSI,C_RANGE_VPOSI);
ClearEnvelope(); //清包络或峰值
return retvalue;
}
extern int iItem;
int RangePlus(int step) /*根据步长增加*/
{
u_int range = MGetRange(1);
if (step == 2)
{
if (range >= 3000)
{
if(iItem!=7&&range<=42000)
{
if( (range + 20)%1000 < 20 )range = (range + 20); /*>300时以100为步长,如320-400-500*/
range = ( range/1000 + 1) * 1000;
}
else if(iItem==7)
{
if( (range + 20)%1000 < 20 )range = (range + 20); /*>300时以100为步长,如320-400-500*/
range = ( range/1000 + 1) * 1000;
}
}
else
{
step = 1;
while ( range + 5 > (u_int)_RANGEVALUE[step])
{
step++;
}
range = (u_int)_RANGEVALUE[step];
}
}
else if( range <= 30000)
{
range = range + step*10;
}
else if( range <= 60000)
{
range = range + step*20;
}
else if(iItem!=7&&range<=42000)
{
range = range + step*50;
}
else if(iItem==7)
{
range = range + step*50;
}
MSetRange(range,C_SETMODE_SETSAVE) ;
if ( ( MGetEchoMode() != C_RF_WAVE && MGetRange(3) + MGetDelay(3) >= C_MAX_RANGE ) || ( MGetEchoMode() == C_RF_WAVE && MGetRange(3) + MGetDelay(3) > C_MAX_RF_RANGE) )
{
int scale = MGetScaleMode();
MSetScaleMode(2,0);
if( MGetEchoMode() != C_RF_WAVE)MSetRange(C_MAX_RANGE - MGetDelay(3), C_SETMODE_SETSAVE) ;
else MSetRange(C_MAX_RF_RANGE - MGetDelay(3), C_SETMODE_SETSAVE) ;
MSetScaleMode(scale,0);
DisplayPrompt(3);
return C_FALSE;
}
else if( MGetSpeed() < CD_SPEED_2 * 110/100 && MGetProbeMode() == C_APROBE && MGetRange(3) + MGetDelay(3) >= C_MAX_RANGE/2+10000)
{
int scale = MGetScaleMode();
MSetScaleMode(2,0);
MSetRange(C_MAX_RANGE/2+10000 - MGetDelay(3), C_SETMODE_SETSAVE) ;
MSetScaleMode(scale,0);
DisplayPrompt(3);
return C_FALSE;
}
return C_TRUE;
}
int RangeMinus(int step) /*根据步长*/
{
u_int range = MGetRange(0);
if (range <= C_MIN_TIMERANGE)
{
DisplayPrompt(3);
return C_FALSE;
}
range = MGetRange(1);
if (range <= C_MIN_RANGE)
{
DisplayPrompt(3);
return C_FALSE;
}
if (step == 2 )
{
if (range > 3000)
{
if( range%1000 < 20 )range = ( range/1000 ) * 1000;; /*>300时以100为步长,如320-400-500*/
if( range%1000 == 0 )range = range - 1000; /*>300时以100为步长,如320-400-500*/
else range = ( range/1000 ) * 1000;
}
else
{
step = 1; //暂用step作指针
while ( range > (u_int)_RANGEVALUE[step])
{
step++;
}
range = (u_int)_RANGEVALUE[step -1];
}
}
else if( range <= 30000)
{
range = range - step*10;
}
else if( range <= 60000)
{
range = range - step*20;
}
else
{
range = range - step*50;
}
MSetRange(range,C_SETMODE_SETSAVE) ;
return C_TRUE;
}
int DelayChange(int rejok)
{
int retvalue = C_TRUE;
int keycode,rotary;
int step = MGetParaStep(C_DELAY);
u_int time = 20;
ClearEnvelope(); //清包络或峰值
WriteParaName(C_DELAY + MGetScaleMode() - 0);
InvertBytes(0, C_COORVPOSI+C_COORHEIGHT+3, 5) ;
do
{
Write_Ascii(4*C_CCHAR_HDOT,C_ECHAR_VDOT,'-');
Write_Number(4*C_CCHAR_HDOT+C_ECHAR_HDOT,C_ECHAR_VDOT,step,1,0,0);
while(1)
{
time = C_KEYDELAY;
ExpendTime(time);
MParaRenovate(1);
keycode = MGetKeyCode(0);
if(keycode == C_KEYCODMAX)
{
#if C_ROTARY > 0
rotary = MGetRotary(-1);
if( rotary >= 128)
{
rotary = 0;
keycode = C_KEYCOD_CONFIRM;
}
else if( rotary > 0 )
{
keycode = C_KEYCOD_PLUS;
}
else if( rotary < 0)
{
keycode = C_KEYCOD_MINUS;
rotary = (-1) * rotary;
}
else continue;
#else
continue;
#endif
}
else rotary = 1;
if(GetNoKeyTime() > 60 && MGetSystemMode() == 1)return -1;
//在自动测试状态下未按超过60s则超出参量调节状态
/// if(keycode < C_KEYCODMAX && keycode >=0)
{
/*有按键*/
if(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS )
{
if(MGetFunctionMode(C_DAC_GATE)) MGateDraw();
DrawDac(1);
do
{
if(time > 20)time -= 5;
else time -= 3;
if(time < 2)time = 1;
ExpendTime(time);
if( step == 2)rotary = 1;
if( rotary <= 3)rotary = 1;
//else rotary *= 2;
if(keycode == C_KEYCOD_MINUS ) DelayMinus(rotary*step);
else DelayPlus(rotary*step);
WriteScale();
InvertBytes(0, C_COORVPOSI+C_COORHEIGHT+3, 5) ;
#if C_ROTARY > 0
rotary = MGetKeyCode(0);
if(rotary == C_KEYCODMAX)
{
rotary = MGetRotary(-1);
if( rotary >= 128)
{
rotary = 0;
keycode = C_KEYCOD_CONFIRM;
}
else if( rotary > 0 )
{
keycode = C_KEYCOD_PLUS;
}
else if( rotary < 0)
{
keycode = C_KEYCOD_MINUS;
rotary = -1 * rotary;
}
else break;
///step = rotary;
}
else rotary = 1;
if( keycode != rotary )break;
#else
if( keycode != MGetKeyCode(0) )break;
#endif
}
while( true );
DrawDac(0);
if( MGetFunctionMode(C_DAC_GATE) == 1)
{
DacGateInit();
MGateDraw();
}
}
else if(keycode == C_KEYCOD_DELAY)
step = ParaStepChange(C_DELAY); //设置待调节参量步长
else if( keycode == C_KEYCOD_CONFIRM&&rejok)// && MGetSystemMode() != 1)
{
WriteScale(); //标度
ExpendTime(20);
#if C_ROTARY > 0
MGetRotary(-1);
#endif
if( (keycode = RejectChange()) == C_KEYCOD_CONFIRM)break;
else return keycode;
}
else
{
MSelectPrompt(keycode);
WriteScale(); //标度
return keycode;
}
break;
}
}
if( !retvalue ) break;
}
while (1);
WriteScale(); //标度
if(keycode == C_KEYCOD_RETURN || (keycode == C_KEYCOD_CONFIRM&&rejok))
{
keycode = -1;
DisplayPrompt(16);
}
else DisplayPrompt(15);
;
return keycode;
}
int DelayPlus(int step) /*根据步长增加*/
{
u_int delay = MGetDelay(1); //得到当前标度下的延时距离
if (step == 2 )
{
step = 0;
delay += MGetRange(1)/2; //当前标度下探测范围的一半
}
else
{
delay += step*2;
}
MSetScaleDelay(delay,C_SETMODE_SETSAVE) ;
if ( MGetRange(3) + MGetDelay(3) >= C_MAX_RANGE)
{
int scale = MGetScaleMode();
MSetScaleMode(2,0);
MSetScaleDelay(C_MAX_RANGE - MGetRange(3), C_SETMODE_SETSAVE) ;
MSetScaleMode(scale,0);
DisplayPrompt(3);
return C_FALSE;
}
else if( MGetSpeed() < CD_SPEED_2 * 110/100 && MGetProbeMode() == C_APROBE && MGetRange(3) + MGetDelay(3) >= C_MAX_RANGE/2)
{
int scale = MGetScaleMode();
MSetScaleMode(2,0);
MSetScaleDelay(C_MAX_RANGE - MGetRange(3), C_SETMODE_SETSAVE) ;
MSetScaleMode(scale,0);
DisplayPrompt(3);
return C_FALSE;
}
return C_TRUE;
}
int DelayMinus(int step) /*根据步长*/
{
int delay = MGetDelay(1);
if( step == 2)
{
if(delay > MGetRange(1)/2 )
delay -= MGetRange(1)/2; //当前标度下探测范围的一半
else delay = 0;
}
else
{
delay -= step*2;
}
if ( delay <= 0 )
{
DisplayPrompt(3);
MSetDelay(0,C_SETMODE_SETSAVE) ;
return C_FALSE;
}
MSetScaleDelay(delay,C_SETMODE_SETSAVE) ;
return C_TRUE;
}
int AngleChange(void)
{
if( MGetParaLock(1,C_LOCK_OFFSET) == 1)
{
#if C_DEVTYPE == 1 || C_DEVTYPE == 9 || C_DEVTYPE == 11
ParaMenu(1);
#elif C_COLOR == 1
///ColorMenu();
#endif
DisplayPrompt(16);
return -1;
}
int retvalue = C_TRUE;
int keycode,rotary;
int step = 1;
u_int time = C_KEYDELAY;
ClearEnvelope(); //清包络或峰值
WriteParaName(C_ANGLE);
//ExpendTime(30);
do
{
WriteAngle(3*C_CCHAR_HDOT,0);
Write_Ascii(3*C_CCHAR_HDOT + 4 * C_ECHAR_HDOT,0 ,130);
Write_Number(3*C_CCHAR_HDOT,8,( MGetAngle(1) + 50)/100,4,2,0);
Write_Number(C_RANGE_HPOSI + 12 * C_ECHAR_HDOT, C_ECHAR_HDOT + 1, (MGetAngle(1) + 50)/100, 4,2,0);
WriteRange(C_RANGE_HPOSI,C_RANGE_VPOSI);
//InvertBytes(C_RANGE_HPOSI, C_RANGE_VPOSI, 5) ;
while(1)
{
time = C_KEYDELAY;
ExpendTime(time);
MParaRenovate(2);
keycode = MGetKeyCode(0);
if(keycode == C_KEYCODMAX)
{
#if C_ROTARY > 0
rotary = MGetRotary(-1);
if( rotary >= 128)
{
rotary = 0;
keycode = C_KEYCOD_CONFIRM;
}
else if( rotary > 0 )
{
keycode = C_KEYCOD_PLUS;
}
else if( rotary < 0)
{
keycode = C_KEYCOD_MINUS;
rotary = -1 * rotary;
}
else continue;
#else
continue;
#endif
}
else rotary = 1;
if(GetNoKeyTime() > 60 && MGetSystemMode() == 1)return -1;
//在自动测试状态下未按超过60s则超出参量调节状态
//if(keycode != C_KEYCODMAX)BuzzerOn(1);
///if(keycode < C_KEYCODMAX && keycode >=0)
{
/*有按键*/
if(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS )
{
do
{
if(time > 20)time -= 5;
else time -= 3;
if(time < 3)time = 2;
ExpendTime(time);
if( rotary <= 2)rotary = 1;
else if( rotary <=8)rotary = 10;
else rotary = 20;
if(keycode == C_KEYCOD_PLUS)AnglePlus(rotary*step);
else AngleMinus(rotary*step);
//WriteAngle(175,8);
WriteAngle(3*C_CCHAR_HDOT,0);
Write_Number(3*C_CCHAR_HDOT,8 ,( MGetAngle(1) + 50)/100,4,2,0);
Write_Number(C_RANGE_HPOSI + 12 * C_ECHAR_HDOT, C_ECHAR_HDOT + 1, (MGetAngle(1) + 50)/100, 4,2,0);
#if C_ROTARY > 0
rotary = MGetKeyCode(0);
if(rotary == C_KEYCODMAX)
{
rotary = MGetRotary(-1);
if( rotary >= 128)
{
rotary = 0;
keycode = C_KEYCOD_CONFIRM;
}
else if( rotary > 0 )
{
keycode = C_KEYCOD_PLUS;
}
else if( rotary < 0)
{
keycode = C_KEYCOD_MINUS;
rotary = -1 * rotary;
}
else break;
///step = rotary;
}
else rotary = 1;
if( keycode != rotary )break;
#else
if( keycode != MGetKeyCode(0) )break;
#endif
}
while( true );
}
else
{
if( ( keycode == C_KEYCOD_ANGLE || keycode == C_KEYCOD_CONFIRM))// && MGetSystemMode() != 1)
{
#if C_COLOR == 1
///ColorMenu();
#elif C_DEVTYPE == 1 || C_DEVTYPE == 9 || C_DEVTYPE == 11
ParaMenu(1);
#endif
if( C_DEVTYPE != 3)
{
DisplayPrompt(16);
return - 1;
}
}
else
{
MSelectPrompt(keycode);
return keycode;
}
break;
}
break;
}
}
if( !retvalue ) break;
}
while (1);
if(keycode == C_KEYCOD_RETURN || keycode == C_KEYCOD_CONFIRM)
{
keycode = -1;
DisplayPrompt(16);
}
else DisplayPrompt(15);
;
return retvalue;
}
int AnglePlus(int step)
{
u_int angle = MGetAngle(0);
if (angle >= C_MAX_ANGLE)
{
DisplayPrompt(3);
return C_FALSE;
}
angle += step;
MSetAngle(angle,C_SETMODE_SETSAVE) ;
MSetTestStatus(C_TEST_ANGLE,0); //设置测试状态,K值未测
return C_TRUE;
}
int AngleMinus(int step)
{
u_int angle = MGetAngle(0);
if (angle < step)
{
DisplayPrompt(3);
MSetAngle(0,C_SETMODE_SETSAVE) ;
return C_FALSE;
}
angle -= step;
MSetAngle(angle,C_SETMODE_SETSAVE) ;
MSetTestStatus(C_TEST_ANGLE,0); //设置测试状态,K值未测
return C_TRUE;
}
void MDACGateChange(int keycode, int type) /* 门改变*/
{
int offset;
//u_short dac_line[C_LEN_DACDB];
//u_short VPosi = C_COORVPOSI + 200;
int rotary;
u_short time = 0;
u_short HPosi ;
u_short Height ;
u_short Width ;
u_short xpos = 16 * 3 ;
u_short ypos = 0 ;
offset = C_OFF_DACGATE;
MCopyProtectedMemory( dac_line, (void*)offset, C_LEN_DACDB, PM_COPY_READ);
HPosi = MGetGatePara(0, 0); /* 水平位置 */
Width = MGetGatePara(0, 1);
Height = MGetGatePara(0, 2);
switch (type)
{
case 0://加减门位
do
{
if(keycode == C_KEYCOD_MINUS)
{
if(HPosi < 1)
{
DisplayPrompt(3);
break ;
}
DrawGateCurver( dac_line, HPosi , Width,1);
HPosi --;
DrawGateCurver( dac_line, HPosi + Width, 1,-1);
DrawGateCurver( dac_line, HPosi, 1,-1);
DrawGateCurver( dac_line, HPosi, Width, 1);
}
else if(keycode == C_KEYCOD_PLUS )
{
if((HPosi + Width) > 279 )
{
DisplayPrompt(3);
break ;
}
DrawGateCurver( dac_line, HPosi , Width,1);
DrawGateCurver( dac_line, HPosi, 1,-1);
DrawGateCurver( dac_line, HPosi + Width, 1,-1);
HPosi ++;
DrawGateCurver( dac_line, HPosi , Width,1);
}
MSetGatePara(HPosi,Width,Height,0,C_SETMODE_SETSAVE);
Write_Number(xpos, ypos, HPosi*MGetRange(1)/(C_COORHORIUNIT*10), 5, 1,0) ;
keycode = MGetKeyCode(time);
if(keycode == C_KEYCODMAX)
{
rotary = MGetRotary(-1);
if( rotary >= 128)
{
rotary = 0;
keycode = C_KEYCOD_CONFIRM;
}
else if( rotary > 0 )keycode = C_KEYCOD_PLUS;
else if( rotary < 0)
{
keycode = C_KEYCOD_MINUS;
rotary = -1 * rotary;
}
}
if(GetSameKeyTime() > 5)time = 0;
else if(GetSameKeyTime() > 3)time = 3;
else time = 5;
}
while(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS) ;
break;
case 1://加减门宽
do
{
if(keycode == C_KEYCOD_MINUS )
{
if(Width < 1)
{
DisplayPrompt(3);
break;
}
DrawGateCurver( dac_line, HPosi , Width,3);
Width --;
DrawGateCurver( dac_line, HPosi + Width,1, -1);
DrawGateCurver( dac_line, HPosi , Width,3);
}
else if(keycode == C_KEYCOD_PLUS )
{
if((HPosi + Width) > 279 )
{
DisplayPrompt(3);
break ;
}
DrawGateCurver( dac_line, HPosi , Width,3);
DrawGateCurver( dac_line, HPosi + Width, 1, -1);
Width ++;
DrawGateCurver( dac_line, HPosi , Width,3);
}
MSetGatePara(HPosi,Width,Height,0,C_SETMODE_SETSAVE);
Write_Number(xpos, ypos, Width*MGetRange(1)/(C_COORHORIUNIT*10), 5, 1, 0) ;
keycode = MGetKeyCode(time);
if(keycode == C_KEYCODMAX)
{
rotary = MGetRotary(-1);
if( rotary >= 128)
{
rotary = 0;
keycode = C_KEYCOD_CONFIRM;
}
else if( rotary > 0 )keycode = C_KEYCOD_PLUS;
else if( rotary < 0)keycode = C_KEYCOD_MINUS;
;
}
if(GetSameKeyTime() > 5)time = 0;
else if(GetSameKeyTime() > 3)time = 3;
else time = 5;
}
while(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS) ;
break;
case 2://加减门高
DrawGateCurver( dac_line, MGetGatePara(0, 0), Width,0);
do
{
if(keycode == C_KEYCOD_MINUS )
{
Height = DacGate_dBHigh(MGetGatedB()-2,MGetDacDb());//门与母线的dB差,DACdB值
}
else if(keycode == C_KEYCOD_PLUS )
{
Height = DacGate_dBHigh(MGetGatedB()+2,MGetDacDb());//门与母线的dB差,DACdB值
}
MSetGatePara(HPosi,Width,Height,0,C_SETMODE_SETSAVE);
Write_Number(xpos, ypos, MGetGatedB(), 4,1,1) ;
keycode = MGetKeyCode(time);
if(keycode == C_KEYCODMAX)
{
rotary = MGetRotary(-1);
if( rotary >= 128)
{
rotary = 0;
keycode = C_KEYCOD_CONFIRM;
}
else if( rotary > 0 )keycode = C_KEYCOD_PLUS;
else if( rotary < 0)keycode = C_KEYCOD_MINUS;
;
}
if(GetSameKeyTime() > 5)time = 0;
else if(GetSameKeyTime() > 3)time = 3;
else time = 5;
}
while(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS) ;
DacGateInit();
DrawDacGate();
break;
}
}
extern int iTwoScreen;
int GateChange(void) /*改变门*/
{
int keycode ;
int rotary =0;
u_short HPosi ;
u_short Height ;
u_short Width ;
u_short xpos,ypos;
u_short char_len,row_number,row_height; /*字符数和字符行数*/
u_char mode = MGetParaSort(C_AGATEPOSI) ;
char gatetype;
xpos = 0;
ypos = 0;
char_len = 3;
row_number = 1;
row_height = 24;
ClearEnvelope(); //清包络或峰值
// mode = 0;
#if C_DEVTYPE == 4 || C_DEVTYPE == 20 || C_DEVTYPE == 5
mode %= 3;
#endif
do
{
if( mode > 3 )gatetype = 1;
else gatetype = 0;
HPosi = MGetGatePara(gatetype, 0) ; /* 水平位置 */
Width = MGetGatePara(gatetype, 1) ;
Height = MGetGatePara(gatetype, 2) ;
MSetGatePara( MGetGatePara(gatetype, 0),MGetGatePara(gatetype, 1),MGetGatePara(gatetype, 2),gatetype , C_SETMODE_SET);
WriteParaName(C_AGATEPOSI + mode);
u_short posmax;
if( MGetTestStatus(C_TEST_DAC) == 0 && MGetTestStatus(C_TEST_AVG) == 0 ) posmax = C_GATEPOSIMAX;
else posmax = C_COORWIDTH;
switch (mode)
{
case 0:
Write_Number(xpos + 16 * 3, ypos, HPosi*MGetRange(1)/(C_COORHORIUNIT*10), 5, 1,0) ;
EMenuOut(xpos + 16 * 3, ypos+ C_ECHAR_VDOT,"mm",2,1,12);
break;
case 1:
Write_Number(xpos + 16 * 3, ypos, Width*MGetRange(1)/(C_COORHORIUNIT*10), 5, 1, 0) ;
EMenuOut(xpos + 16 * 3, ypos+ C_ECHAR_VDOT,"mm",2,1,12);
break;
case 2:
if ((MGetTestStatus(C_TEST_DAC) == 1 || MGetTestStatus(C_TEST_AVG) == 1) && MGetEchoMode() != C_RF_WAVE && MGetFunctionMode(C_DAC_GATE) == 1)
{
Write_Number(xpos + 16 * 3, ypos, MGetGatedB(), 4,1,1) ;
EMenuOut(xpos + 16 * 3, ypos+ C_ECHAR_VDOT+1,"dB",2,1,12);
}
else
{
Write_Number(xpos + 16 * 3, ypos, Height*5, 4, 1,0) ;
EMenuOut(xpos + 16 * 3, ypos+ C_ECHAR_VDOT,"% ",2,1,12);
}
break;
case 4:
Write_Number(xpos + 16 * 3, ypos, HPosi*MGetRange(1)/(C_COORHORIUNIT*10), 5, 1,0) ;
EMenuOut(xpos + 16 * 3, ypos+ C_ECHAR_VDOT,"mm",2,1,12);
break;
case 5:
Write_Number(xpos + 16 * 3, ypos, Width*MGetRange(1)/(C_COORHORIUNIT*10), 5, 1, 0) ;
EMenuOut(xpos + 16 * 3, ypos+ C_ECHAR_VDOT,"mm",2,1,12);
break;
case 6:
Write_Number(xpos + 16 * 3, ypos, Height*5, 4, 1,0) ;
EMenuOut(xpos + 16 * 3, ypos+ C_ECHAR_VDOT,"% ",2,1,12);
break;
}
///ExpendTime(20);
do
{
ExpendTime(10);
MParaRenovate(1);
keycode = MGetKeyCode(0);
if( MGetDacShowMode() > 0) MAdjustGain(0,0,MGetAmpStdMax(),MGetAmpStdMax() );
if(keycode == C_KEYCODMAX)
continue;
else rotary = 1;
if(GetNoKeyTime() > 60 && MGetSystemMode() == 1)break;
//在自动测试状态下未按超过60s则超出参量调节状态
}
while(keycode == C_KEYCODMAX);
if(GetNoKeyTime() > 60 && MGetSystemMode() == 1)break;
//BuzzerOn(1);
switch (keycode)
{
#ifdef C_KEYCOD_GATEB
//有门B键定义
case C_KEYCOD_GATEB:
if( mode >= 4)mode = 4+(mode + 1 )%3;
else mode = 4 + mode%3;
MSetParaSort(mode,C_AGATEPOSI); //待调节参量名(门A/门B),系统增益/补偿增益
ExpendTime(20); /*消耗时间,以10ms为单位*/
break ;
case C_KEYCOD_GATE:
if( mode < 3)mode = (mode + 1 )%3;
else mode = mode%3;
MSetParaSort(mode,C_AGATEPOSI); //待调节参量名(门A/门B),系统增益/补偿增益
ExpendTime(20); /*消耗时间,以10ms为单位*/
break ;
#else
//未定义门B键
case C_KEYCOD_GATE:
if( mode < 3)mode = (mode + 1 )%3;
else mode = 4 + (mode+1)%3;
MSetParaSort(mode,C_AGATEPOSI); //待调节参量名(门A/门B),系统增益/补偿增益
ExpendTime(20); /*消耗时间,以10ms为单位*/
break ;
case C_KEYCOD_CONFIRM:
#if C_DEVTYPE == 4 || C_DEVTYPE == 20
MSetFunctionMode( MGetFunctionMode(C_GATE_ALARM)+1,C_GATE_ALARM);
MKeyRlx();
#elif C_DEVTYPE != 5
if( !MGetSystemMode() )
{
mode = (mode + 4)%8 ;
MSetParaSort(mode,C_AGATEPOSI); //待调节参量名(门A/门B),系统增益/补偿增益
ExpendTime(20); /*消耗时间,以10ms为单位*/
}
#endif
break ;
#endif
case C_KEYCOD_PLUS:
case C_KEYCOD_MINUS:
if ((MGetTestStatus(C_TEST_DAC) == 1 || MGetTestStatus(C_TEST_AVG) == 1) && MGetEchoMode() != C_RF_WAVE && MGetFunctionMode(C_DAC_GATE) == 1 && mode < 3)
{
MDACGateChange(keycode,mode);
break;
}
switch (mode)
{
case 0:
MGatePosi(keycode,0,rotary) ;
break ;
case 1:
MGateWide(keycode,0,rotary) ;
break ;
case 2:
MGateHigh(keycode,0,rotary) ;
break ;
case 4:
MGatePosi(keycode,1,rotary) ;
break ;
case 5:
MGateWide(keycode,1,rotary) ;
break ;
case 6:
MGateHigh(keycode,1,rotary) ;
break ;
}
MSetColor(C_CR_WAVE);
break ;
}
#ifdef C_KEYCOD_GATEB
//有门B键定义
}
while( keycode == C_KEYCOD_CONFIRM ||keycode == C_KEYCOD_GATE ||keycode == C_KEYCOD_GATEB || keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS || keycode == C_KEYCODMAX );
#else
//未定义门B键
}
while( keycode == C_KEYCOD_CONFIRM ||keycode == C_KEYCOD_GATE || keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS || keycode == C_KEYCODMAX );
#endif
if(keycode == C_KEYCOD_RETURN || keycode == C_KEYCOD_CONFIRM)
{
if(iTwoScreen!=1)
DisplayPrompt(16);
else
{
TextOut(0,0,1,12,16," ",4);
}
}
else DisplayPrompt(15);
;
MSetGatePara(MGetGatePara(0,0),MGetGatePara(0,1),MGetGatePara(0,2),0,C_SETMODE_SET);
return keycode;
}
//
void MGatePosi(int keycode, int gatetype,int step) /* 门位改变*/
{
// u_short VPosi = C_COORVPOSI + 200;
u_short HPosi ;
u_short Height ;
u_short Width ;
// u_short HPosi1 ;
// u_short Height1 ;
// u_short Width1 ;
// int time = 10;
int rotary;
int i;
rotary = 0;
u_int xpos = 16 * 3;
u_int ypos = 0;
i = 0;
//step = 1;
HPosi = MGetGatePara(gatetype, 0); /* 水平位置 */
Width = MGetGatePara(gatetype, 1);
Height = MGetGatePara(gatetype, 2) ;
u_short posmax;
if( MGetTestStatus(C_TEST_DAC) == 0 && MGetTestStatus(C_TEST_AVG) == 0 ) posmax = C_GATEPOSIMAX;
else posmax = C_WAVEWIDTH;
do
{
if(keycode == C_KEYCOD_PLUS)
{
//#if C_ROTARY > 0
MDrawGate(gatetype,0, -1, 0);
HPosi += step;
if( (HPosi + Width) >= posmax || ( gatetype == 0 && (HPosi + Width) > MGetGatePara(1, 0) && MGetBGateMode() == 1) )
{
DisplayPrompt(3);
if ( gatetype == 0 && (HPosi + Width) > MGetGatePara(1, 0) && MGetBGateMode() == 1)
{
HPosi = MGetGatePara(1, 0) - Width -1 ;
}
else
{
if( HPosi > C_WAVEWIDTH )HPosi = C_WAVEWIDTH;
if( HPosi + Width > posmax)HPosi = posmax - Width;
}
}
MSetGatePara( HPosi,Width,Height,gatetype,C_SETMODE_SETSAVE);
MDrawGate(gatetype,0, -1, 0);
ExpendTime(20);///
}
else if(keycode == C_KEYCOD_MINUS)
{
//#if C_ROTARY > 0
MDrawGate(gatetype,0, -1, 0);
if( HPosi > step+1)HPosi -= step;
else HPosi = 2;
if( gatetype == 1 && HPosi < (MGetGatePara(0, 0) + MGetGatePara(0, 1) ) && MGetBGateMode() == 1)
{
HPosi = (MGetGatePara(0, 0) + MGetGatePara(0, 1) ) + 1;
}
if( HPosi <= 2)
{
DisplayPrompt(3);
}
MSetGatePara( HPosi,Width,Height,gatetype,C_SETMODE_SETSAVE);
MDrawGate(gatetype,0, -1, 0);
ExpendTime(20);///
}
Write_Number(xpos, ypos, HPosi*MGetRange(1)/(C_COORHORIUNIT*10), 5, 1,0) ;
rotary = MGetKey();//MGetKeyCode(0);
if( keycode == rotary )
{
step *= 2;
ExpendTime(2);
}
else
{
keycode = rotary;
step = 1;
}
// keycode = MGetKeyCode(time);
// if(GetSameKeyTime() > 5)time = 1;
// else if(GetSameKeyTime() > 3)time = 3;
// else time = 5;
#if C_ROTARY > 0
if(keycode == C_KEYCODMAX)
{
rotary = MGetRotary(-1);
if( rotary >= 128)
{
rotary = 0;
keycode = C_KEYCOD_CONFIRM;
}
else if( rotary > 0 )keycode = C_KEYCOD_PLUS;
else if( rotary < 0)
{
keycode = C_KEYCOD_MINUS;
rotary = -1 * rotary;
}
step = rotary;
;
}
else step = 1;
#endif
if( C_DEVLIB == 1 || C_DEVLIB == 24)
{
if( step > 4)step = 4;
//ExpendTime(5);
step = 1;
}
else if( C_DEVLIB == 2 || C_DEVLIB == 23)
{
if( step > 4)step = 4;
}
else if( C_DEVLIB == 3)
{
if( step > 64)step = 64+((step-64) >> 3);
else if( step > 16)step = 16+( (step - 16) >> 2);
else if( step > 1)step = (step >> 1);
}
//MSetGatePara( HPosi,Width,Height,gatetype,C_SETMODE_SETSAVE);
}
while(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS) ;
/// Write_Number(xpos, ypos, HPosi*MGetRange(1)/(C_COORHORIUNIT*10), 5, 1,0) ;
MSetGatePara( HPosi,Width,Height,gatetype,C_SETMODE_SETSAVE);
}
void MGateWide(int keycode, int gatetype,int step) /*门宽改变*/
{
// u_short VPosi = C_COORVPOSI + 200;
u_short HPosi ;
u_short Height ;
u_short Width ;
// u_short HPosi1 = 0;
// u_short Height1 = 0;
// u_short Width1 = 0;
// u_int time = 10;
u_int xpos = 16 * 3 ;
u_int ypos = 0 ;
int rotary;
int i;
rotary = 0;
//step = 1;
i = 0;
u_short posmax;
if( MGetTestStatus(C_TEST_DAC) == 0 && MGetTestStatus(C_TEST_AVG) == 0 ) posmax = C_GATEPOSIMAX;
else posmax = C_WAVEWIDTH;
do
{
HPosi = MGetGatePara(gatetype, 0); /* 水平位置 */
Width = MGetGatePara(gatetype, 1);
Height = MGetGatePara(gatetype, 2) ;
if(keycode == C_KEYCOD_PLUS )
{
///#if C_ROTARY > 0
if( Width > 0)MDrawGate(gatetype,0, -1, 0);
Width += step;
if( (HPosi + Width ) >= posmax || ( gatetype == 0 && (HPosi + Width) > MGetGatePara(1, 0) && MGetBGateMode() == 1) )
{
DisplayPrompt(3);
if ( gatetype == 0 && (HPosi + Width) > MGetGatePara(1, 0) && MGetBGateMode() == 1)
{
Width = MGetGatePara(1, 0) - HPosi -1 ;
}
else
{
if( HPosi > C_WAVEWIDTH )HPosi = C_WAVEWIDTH;
if( HPosi + Width > posmax)Width = posmax - HPosi;
}
}
MSetGatePara( HPosi,Width,Height,gatetype,C_SETMODE_SETSAVE);
MDrawGate(gatetype,0, -1, 0);
ExpendTime(20);///
}
else if(keycode == C_KEYCOD_MINUS )
{
if( Width > 0)MDrawGate(gatetype,0, -1, 0);
if( Width > step )Width -= step;
else Width = 1;
if( Width == 1 )
{
DisplayPrompt(3);
}
MSetGatePara( HPosi,Width,Height,gatetype,C_SETMODE_SETSAVE);
MDrawGate(gatetype,0, -1, 0);
ExpendTime(20);///
}
Write_Number(xpos, ypos, Width*MGetRange(1)/(C_COORHORIUNIT*10), 5, 1, 0) ;
rotary = MGetKey();//MGetKeyCode(0);
if( keycode == rotary )
{
step *= 2;
ExpendTime(2);
}
else
{
keycode = rotary;
step = 1;
}
#if C_ROTARY > 0
if(keycode == C_KEYCODMAX)
{
rotary = MGetRotary(-1);
if( rotary >= 128)
{
rotary = 0;
keycode = C_KEYCOD_CONFIRM;
}
else if( rotary > 0 )keycode = C_KEYCOD_PLUS;
else if( rotary < 0)
{
keycode = C_KEYCOD_MINUS;
rotary = -1 * rotary;
}
step = rotary;
;
}
else step = 1;
#endif
if( C_DEVLIB == 1 || C_DEVLIB == 24)
{
if( step > 4)step = 4;
//ExpendTime(5);
//step = 1;
}
else if( C_DEVLIB == 2 || C_DEVLIB == 23)
{
if( step > 4)step = 4;
}
else if( C_DEVLIB == 3)
{
if( step > 100)step = (step >> 3);
else if( step > 40)step = (step >> 2);
else if( step > 20)step = (step >> 1);
}
//MSetGatePara( HPosi,Width,Height,gatetype,C_SETMODE_SETSAVE);
}
while(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS) ;
/// Write_Number(xpos, ypos, Width*MGetRange(1)/(C_COORHORIUNIT*10), 5, 1, 0) ;
MSetGatePara( HPosi,Width,Height,gatetype,C_SETMODE_SETSAVE);
}
void MGateHigh(int keycode, int gatetype,int step) /* 门高改变*/
{
// u_short VPosi = C_COORVPOSI + 200;
u_short HPosi ;
u_short Height ;
u_short Width ;
u_int time = 10;
int rotary;
u_int xpos = 16 * 3 ;
u_int ypos = 0 ;
rotary = 0;
step = 1;
do
{
HPosi = MGetGatePara(gatetype, 0); /* 水平位置 */
Width = MGetGatePara(gatetype, 1);
Height = MGetGatePara(gatetype, 2) ;
if(keycode == C_KEYCOD_MINUS)
{
if(Height < 4 || Height < step)
{
DisplayPrompt(3);
break;
}
if(gatetype == 1 &&( Height < step || Height < 5) )
{
//门很低隐藏B门
MDrawGate(gatetype,0,-1,0);
Height = 0;
MSetGatePara( HPosi,Width,Height,gatetype,C_SETMODE_SETSAVE);
}
else
{
MDrawGate(gatetype,0,-1,0);
Height-= step;
MSetGatePara( HPosi,Width,Height,gatetype,C_SETMODE_SETSAVE);
MDrawGate(gatetype,0,-1,0);
}
ExpendTime(20);///
}
else if(keycode == C_KEYCOD_PLUS )
{
if(Height + step > 199)
{
DisplayPrompt(3);
break;
}
if(gatetype == 1 && Height < 5)
{
Height = 5;
MSetGatePara( HPosi,Width,Height,gatetype,C_SETMODE_SETSAVE);
MDrawGate(gatetype,0,-1,0);
}
else
{
MDrawGate(gatetype,0,-1,0);
Height+= step;
MSetGatePara( HPosi,Width,Height,gatetype,C_SETMODE_SETSAVE);
MDrawGate(gatetype,0,-1,0);
}
ExpendTime(20);///
}
Write_Number(xpos,ypos, Height * 5, 4,1,0) ;
// keycode = MGetKey();//MGetKeyCode(0);
keycode = MGetKeyCode(time);
if(GetSameKeyTime() > 5)time = 1;
else if(GetSameKeyTime() > 3)time = 3;
else time = 5;
#if C_ROTARY > 0
if(keycode == C_KEYCODMAX)
{
rotary = MGetRotary(-1);
if( rotary >= 128)
{
rotary = 0;
keycode = C_KEYCOD_CONFIRM;
}
else if( rotary > 0 )keycode = C_KEYCOD_PLUS;
else if( rotary < 0)
{
keycode = C_KEYCOD_MINUS;
rotary = -1*rotary;
}
step = rotary;
;
}
else step = 1;
#endif
}
while(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS) ;
MSetGatePara( HPosi,Width,Height,gatetype,C_SETMODE_SETSAVE);
}
/*显示各参数值*/
void WriteBaseGain(u_int xpos,u_int ypos) //基本增益
{
Write_Number(xpos,ypos,MGetBaseGain(),4,1,0);
}
void WriteCompGain(u_int xpos,u_int ypos) //补偿增益
{
Write_Number(xpos,ypos,MGetCompGain(),5,1,1);
}
void WriteSurfGain(u_int xpos,u_int ypos) //表面补偿
{
Write_Number(xpos,ypos,MGetSurfGain(),5,1,1);
}
void WriteRange(u_int xpos,u_int ypos) //声程范围
{
if( MGetUnitType() > 0)
{
//单位inch
Write_Number(xpos,ypos,MGetRange(1),5,3,0);
}
else
{
Write_Number(xpos,ypos,MGetRange(1),5,1,0);
}
}
void WriteSpeed(u_int xpos,u_int ypos) //声速
{
if( MGetUnitType() > 0)
{
//单位inch
Write_Number(xpos,ypos,MGetSpeed(),5,2,0);
EMenuOut(xpos + 5 * C_ECHAR_VDOT,ypos,"in/ms",5,1,8);
}
else
{
Write_Number(xpos,ypos,MGetSpeed(),5,0,0);
EMenuOut(xpos + 5 * C_ECHAR_VDOT,ypos,"m/s ",5,1,8);
}
}
void WriteOffset(u_int xpos,u_int ypos)//零点
{
Write_Number(xpos,ypos,MGetOffset()*10/16,5,2,0);
// Write_Number(xpos,ypos,MGetOffset(),5,2,0);
}
void WriteReject(u_int xpos,u_int ypos)//抑制
{
Write_Number(xpos,ypos,MGetReject()*5,4,1,0);
}
void WriteDelay(u_int xpos,u_int ypos) //延时
{
if( MGetUnitType() > 0)
{
//单位inch
Write_Number(xpos,ypos,MGetDelay(1),5,3,0);
}
else
{
Write_Number(xpos,ypos,MGetDelay(1),5,1,0);
}
}
void WriteAngle(u_int xpos,u_int ypos) //角度
{
Write_Number(xpos,ypos,MGetAngle(0),4,1,0);
}
void WriteScale(void) //标度
{
u_int xpos = 0,ypos = C_COORVPOSI+C_COORHEIGHT+3;
u_int i;
u_int number = MGetDelay(1); //得到当前标度下的延时距离
int range;
range = MGetRange(1)/5; //得到当前标度下的探测范围
// if( MGetProbeMode() == C_P_TRANSMISSION)range *= 2;
if( MGetUnitType() > 0)
{
//单位inch
Write_Number(xpos,ypos,number,5,3,0);
for(i=0; i<4 ; i++)
{
xpos += C_COORHORIUNIT*2;
number += range;
Write_Number(xpos,ypos,(number+5)/10,5,2,0);
}
}
else
{
Write_Number(xpos,ypos,number,5,1,0);
for(i=0; i<4 ; i++)
{
xpos += C_COORHORIUNIT*2;
number += range;
Write_Number(xpos,ypos,(number+5)/10,5,0,0);
}
}
}
void WriteLongness(u_short xpos, u_short ypos,int number,u_char total_len/*总长*/,u_char mode/*是否写单位*/)
{
if( MGetUnitType() > 0)
{
//单位inch
Write_Number(xpos,ypos ,number,total_len,3,0);
if( mode > 0)EMenuOut(xpos + total_len * C_ECHAR_VDOT,ypos,"in",2,1,8);
}
else
{
Write_Number(xpos,ypos,number,total_len,1,0);
if( mode > 0)EMenuOut(xpos + total_len * C_ECHAR_VDOT,ypos,"mm",2,1,8);
}
}
void ScreenRenovate(void) /*屏幕刷新*/
{
MFclearScreen();
MSetColor(C_CR_WAVE);
MChannelRenovate();
DisplayPrompt(16);
}
void MChannelRenovate(void) //本通道屏幕参数刷表
{
MSetColor(C_CR_PARA);
MCoorDraw(C_COORHPOSI ,C_COORVPOSI , C_COORHEIGHT , C_COORWIDTH ); /*画指定位置和大小的波形坐标*/
MSetColor(C_CR_PARA);
WriteScale(); //标度
MSetColor(C_CR_PARA);
SysParaDisp(); //显示通道号、探头类型、频带等
MSetColor(C_CR_MENU);
if( MGetUnitType() > 0)
{
//单位inch
EMenuOut(C_RANGE_HPOSI + 5 * C_ECHAR_HDOT,C_RANGE_VPOSI,"in( )",5,1,12);
}
else
{
EMenuOut(C_RANGE_HPOSI + 5 * C_ECHAR_HDOT,C_RANGE_VPOSI,"mm( )",5,1,12);
}
MSetColor(C_CR_PARA);
switch (MGetScaleMode() )
{
case 0:
Write_Ascii(C_RANGE_HPOSI + 8 * C_ECHAR_HDOT,C_RANGE_VPOSI+ 0,'Y');
break;
case 1:
Write_Ascii(C_RANGE_HPOSI + 8 * C_ECHAR_HDOT,C_RANGE_VPOSI+ 0,'X');
break;
default:
Write_Ascii(C_RANGE_HPOSI + 8 * C_ECHAR_HDOT,C_RANGE_VPOSI+ 0,'S');
break;
}
WriteBaseGain(C_BASEGAIN_HPOSI,C_BASEGAIN_VPOSI);
WriteCompGain(C_BASEGAIN_HPOSI + 4 * C_ECHAR_HDOT,C_BASEGAIN_VPOSI);
WriteSurfGain(C_BASEGAIN_HPOSI + 9 * C_ECHAR_HDOT,C_BASEGAIN_VPOSI);
EMenuOut(C_BASEGAIN_HPOSI + 14 * C_ECHAR_HDOT,C_BASEGAIN_VPOSI ,"dB",2,1,12);
WriteRange(C_RANGE_HPOSI,C_RANGE_VPOSI);
MSetColor(C_CR_MENU);
EMenuOut(C_RANGE_HPOSI + 11 * C_ECHAR_HDOT, C_RANGE_VPOSI,"k", 1,1,12);
MSetColor(C_CR_PARA);
Write_Number(C_RANGE_HPOSI + 12 * C_ECHAR_HDOT, C_ECHAR_HDOT + 1, (MGetAngle(1) + 50)/100, 4,2,0);
MSetColor(C_CR_MENU);
WritePeakPrompt( MGetBGateMode(),MGetEquivalentMode()); //mode1=0B门失波1进波,mode2<0波高.>0dB数
MParaRenovate(0);
CalcuDac();
if( MGetFunctionMode(C_DAC_GATE) )
{
DacGateInit();
}///MGateDraw();
MDrawGate(0,0,-1,0);
MDrawGate(1,0,-1,0);
MSetColor(C_CR_PARA);
DrawPower(GetBatteryStatus()%256,0);
}
extern int iItem;///机务曲面修正
extern int iBlock;
///一次反射
double* curve(double Angle1,double R,double dist)
{
double a , b , c , angB ;
double Ydist,Xdist;
double Angle=(double)(Angle1*PI*10000.0/1800.0/10000.0);
a = R;
b = dist ;
c = sqrt( pow( abs( dist - R * cos(Angle) ) , 2 ) + pow( R * sin(Angle) , 2 ) ) ;
angB = acos((a*a+c*c-b*b)/(2*a*c));
Ydist = a - c ;//¾à̤Ãæ
Xdist = a * angB ;//»¡³¤
double Dist[2]= {0};
Dist[0]=Xdist;
Dist[1]=Ydist;
return Dist;
}
///多次反射
int curveN(double Angle2,double R,double dist)
{
double a , b , c , angB ;
double Ydist,Xdist;
double Angle=(double)(Angle2*PI*10000.0/1800.0/10000.0);
int num=(int)dist/(int)(2* cos(Angle)*R);
double distTemp=dist-(2* cos(Angle)*R)*num;
a = R;
b = distTemp ;
c = sqrt( pow( abs( distTemp - R * cos(Angle) ) , 2 ) + pow( R * sin(Angle) , 2 ) ) ;
angB = acos((a*a+c*c-b*b)*(double)10000.0/(2*a*c)/(double)10000.0);
Ydist = a - c ;//¾à̤Ãæ
Xdist = a * angB ;//»¡³¤
double Dist[2]= {0.0};
///Dist[0]=Xdist+num*R*Angle;
///Dist[1]=Ydist;
int Dist1,Dist2;
Dist1=Xdist+num*R*Angle;
Dist2=Ydist;
///Write_Number(100,40,Dist[0],6,1,0);///
///Write_Number(100,60,Dist[1],6,1,0);///
///return Dist[0];
///return distTemp;
return ((Dist1<<16)&0xffff0000)+(Dist2&0x0000ffff);
}
extern int gJWFlag;
int giPara;
int GetDispEchoPara(void)/*得到指定门(0=A or 1=B)内回波的位置大小并写在屏幕上*/
{
//int dist_dire,dist_hori,dist_vert;
//int gateamp = MGetAmpMax(0);
int ElapsedTime = GetElapsedTime();
int time = ElapsedTime - AdjustTime.PreElapsedTime;
int para1,para2,para3,para4;
short pos1,pos2;
// int alarm_enable = 0; //
para1 = MGetAmpMax(2);
short amp1 = para1/256;
{///2019.3.6
u_char *sampbuff;
int iGatePos=MGetGatePara(0,0);
int iGateWidth=MGetGatePara(0,1);
int index=0;
int iMaxPos=0;
int iMaxAmp=0;
sampbuff=GetSampleBuffer();
//memcpy(sampbuffer,sampbuff,280);
for(index=iGatePos;index<(iGatePos+iGateWidth);index++)
{
if(iMaxAmp<sampbuff[index])
{
iMaxAmp=sampbuff[index];
iMaxPos=index;
}
}
amp1=sampbuff[iMaxPos];
}
short amp2 = para1%256;
u_int time1 = MGetAmpTime(0);
u_int time2 = MGetAmpTime(1);
pos1 = MGetAmpPos(0);
pos2 = MGetAmpPos(1);
//if(gateamp > MGetGatePara(0,2) || MGetAmpMax(1) < MGetGatePara(1,2)) alarm_enable = 1;
//else alarm_enable = 0;
int mode1,mode2;
mode1 = MGetBGateMode();
mode2 = MGetEquivalentMode(); //mode1=0B门失波1进波,mode2<0波高.>0dB数
if( MGetStdMode() == C_STD_AWS_NUM - 1)//AWS
{
mode1 = 0;
mode2 = -1;
}
//if( MGetAcquisitionMode() == 1 && AdjustTime.ParaDisplayTime > 200 )
if( AdjustTime.ParaDisplayTime > C_RENOVATE_TIME )
{
if(mode1 == 0)
{
//单进波门
para1 = (int)( (double)(time1 * MGetSpeed() )/(double)(200*100) +0.5) ; //距离
//;Write_Number(10,30,para1,10,0,0);
para1 += MGetDelay(3);
//if( (para1+2)%5 < 3)para1 = (para1+2)/5 * 5;
if( (para1)%5 < 1);
else if( (para1+2)%5 < 2)para1++;
else if( para1 > 1)para1--;
//;Write_Number(100,30,MGetAngle(2),10,0,0);
//;Write_Number(200,30,MGetAngle(3),10,0,0);
if( !MGetFunctionMode(C_CURVER_AMEND) )
{
para2 = para1 * MGetAngle(2) / 10000; //水平
para3 = para1 * MGetAngle(3) / 10000; //垂直
///--------------------------机务曲面修正
///double *Dist=NULL;
double Dist1=0,Dist2=0;
/*if(iItem==1&&iBlock==1&&((MGetProbeMode()==1||MGetProbeMode()==4)&&MGetAngle(0)<=450) )///520
{
Dist=curve(MGetAngle(0),5200.0,MGetAmpDist(0));
para2=Dist[0];
para3=Dist[1];
}
else if(iItem==1&&iBlock==2&&((MGetProbeMode()==1||MGetProbeMode()==4)&&MGetAngle(0)<=450) )///600
{
Dist=curve(MGetAngle(0),6000.0,MGetAmpDist(0));
para2=Dist[0];
para3=Dist[1];
}
else if(iItem==1&&iBlock==1&&((MGetProbeMode()==1||MGetProbeMode()==4)&&MGetAngle(0)>450) )///520
{
Dist=curveN(MGetAngle(0),5200.0,MGetAmpDist(0));
para2=Dist[0];
para3=Dist[1];
}
else if(iItem==1&&iBlock==2&&((MGetProbeMode()==1||MGetProbeMode()==4)&&MGetAngle(0)>450) )///600
{
Dist=curveN(MGetAngle(0),6000.0,MGetAmpDist(0));
para2=Dist[0];
para3=Dist[1];
}*/
int Dist;
if(gJWFlag&&iItem==1&&iBlock==1&&((MGetProbeMode()==1||MGetProbeMode()==4)) )///520
{
Dist=curveN((double)MGetAngle(0),(double)5200.0,(double)MGetAmpDist(0));
para2=(int)((Dist>>16)&0xffff);
para3=(int)(Dist&0xffff);
}
else if(gJWFlag&&iItem==1&&iBlock==2&&((MGetProbeMode()==1||MGetProbeMode()==4)) )///600
{
Dist=curveN((double)MGetAngle(0),(double)6000.0,(double)MGetAmpDist(0));
para2=(int)((Dist>>16)&0xffff);
para3=(int)(Dist&0xffff);
}
///Write_Number(100,40,(int)((Dist>>16)&0xffff),6,1,0);///
/// Write_Number(100,60,(int)(Dist&0xffff),6,1,0);///
if(iItem==7)
{
int iPara=0,i=0,imax=0;
int iPos=MGetGatePara(0,0);
int iWidth=MGetGatePara(0,1);
u_char *Sample=GetSampleBuffer;
for(i=iPos; i<iPos+iWidth; i++)
{
if(Sample[i]>iPara)
{
iPara=Sample[i];
imax=i;
}
}
para1=(int)((double)imax*100.0/(double)C_COORWIDTH/100.0*MGetRange(1));
giPara=para1;
para2 = para1 * MGetAngle(2) / 10000; //水平
para3 = para1 * MGetAngle(3) / 10000; //垂直
}
}
else
{
MGetCurveAmend(¶1,¶2,¶3,&stCurveAmend);
}
if (para2 >= MGetForward())
{
para2 -= MGetForward();
}
///else para2 = 0;
if( mode2 > 0)
{
//将波高转换dB值
para4 = Amp2db( pos1,amp1 );
///para4 += MGetSurfGain();
switch (mode2)
{
case 1:
break;
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
para4 -= MGetLineGain( MGetEquivalentMode()-2 );
break;
case 10:
break;
case 11://显示孔径
if( MGetUnitType() > 0 )
{
Write_Number(23*8,C_COORVPOSI - 10,(int)( 10*powf( 10,( para4 + 120 ) / 400.0)*100/25.4 + 0.5), 3,1,0);
}
else
{
Write_Number(23*8,C_COORVPOSI - 10,(int)( 10*powf( 10,( para4 + 120 ) / 400.0) + 0.5), 3,1,0);
}
/// Write_Number(23*8,C_COORVPOSI - 10,(int)( 10*powf( 10,( para4 + 120 ) / 400.0) + 0.5), 3,1,0);
para4 -= MGetLineGain(2);
break;
}
}
else para4 = amp1*5;
if( MGetThick() > 0 && MGetDiameter() == 0 && MGetSystemMode() == 0)
{
if( (para3 / MGetThick() ) % 2 == 0) para3 = para3 % MGetThick();
else para3 = MGetThick() - (para3 % MGetThick() );
}
}
else//双进波门
{
// para1 = MGetAmpTime(0) * MGetSpeed() /(C_SAMPLE_FREQ) ; //距离
para1 = (int)( (double)(time1 * MGetSpeed() )/(double)(C_SAMPLE_FREQ) +0.5) ; //距离
para1 += MGetDelay(3);
//if( (para1+2)%5 < 3)para1 = (para1+2)/5 * 5;
if( (para1)%5 < 1);
else if( (para1+2)%5 < 2)para1++;
else if( para1 > 1)para1--;
//if( (para1+1)%5 < 3)para1 = (para1+1)/5 * 5;
///Write_Number(0,0,MGetAmpTime(0),10,0,0);
if( !MGetFunctionMode(C_CURVER_AMEND) )
{
switch (MGetScaleMode() )
{
case 0://0垂直1水平2距离
para1 = para1 * MGetAngle(3) / 10000; //余弦
if( MGetThick() > 0 && MGetDiameter() == 0 && MGetSystemMode() == 0)
{
if( (para1 / MGetThick() ) % 2 == 0) para1 = para1 % MGetThick();
else para1 = MGetThick() - (para1 % MGetThick() );
}
break;
case 1:
para1 = para1 * MGetAngle(2) / 10000; //正弦
break;
default:
break;
}
}
else
{
MGetCurveAmend(¶1,¶2,¶3,&stCurveAmend);
switch (MGetScaleMode() )
{
case 0://0垂直1水平2距离
para1 = para3;
break;
case 1://
para1 = para2;
break;
default:
break;
}
}
// para3 = MGetAmpTime(1) * MGetSpeed() /(C_SAMPLE_FREQ) ; //距离
para3 = (int)( (double)(time2 * MGetSpeed() )/(double)(C_SAMPLE_FREQ) +0.5) ; //距离
para3 += MGetDelay(3);
//if( (para1+2)%5 < 3)para1 = (para1+2)/5 * 5;
if( (para3)%5 < 1);
else if( (para3+2)%5 < 2)para3++;
else if( para3 > 1)para3--;
//if( (para3+1)%5 < 3)para3 = (para3+1)/5 * 5;
if( !MGetFunctionMode(C_CURVER_AMEND) )
{
switch (MGetScaleMode() )
{
case 0://0垂直1水平2距离
para3 = para3 * MGetAngle(3) / 10000; //余弦
if( MGetThick() > 0 && MGetDiameter() == 0 && MGetSystemMode() == 0)
{
if( (para3 / MGetThick() ) % 2 == 0) para3 = para3 % MGetThick();
else para3 = MGetThick() - (para3 % MGetThick() );
}
break;
case 1:
para3 = para3 * MGetAngle(2) / 10000; //正弦
break;
default:
break;
}
}
else
{
MGetCurveAmend(¶3,¶2,¶4,&stCurveAmend);
switch (MGetScaleMode() )
{
case 0://0垂直1水平2距离
para3 = para4;
break;
case 1://
para3 = para2;
break;
default:
break;
}
}
//gateamp = MGetAmpMax(2) ;//同时得到两个门内的波高
if( mode2 > 0 )
{
//将波高转换dB值
para2 = Amp2db( pos1,amp1 );
para4 = Amp2db( pos2,amp2 );
switch (mode2)
{
case 1:
break;
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
para2 -= MGetLineGain( MGetEquivalentMode()-2 );
para4 -= MGetLineGain( MGetEquivalentMode()-2 );
break;
case 10:
break;
case 11://显示孔径
para2 -= MGetLineGain(2);
para4 -= MGetLineGain(2);
break;
}
}
else
{
para2 = (amp1)*5;
para4 = (amp2)*5;
}
}
stGateAmpMax.mode[0] = mode1;
stGateAmpMax.mode[1] = mode2;
stGateAmpMax.para[0] = para1;
stGateAmpMax.para[1] = para2;
stGateAmpMax.para[2] = para3;
stGateAmpMax.para[3] = para4;
if( MGetAcquisitionEnable() > 0)
{
ChannelPara.wavepara[0] = para1;
ChannelPara.wavepara[1] = para2;
ChannelPara.wavepara[2] = para3;
ChannelPara.wavepara[3] = para4;
}
WritePeakInfo(mode1,mode2,para1,para2,para3,para4);
if( MGetStdMode() == C_STD_AWS_NUM - 1)//AWS
{
int x = 28+2;
int ypos;
ypos = C_COORVPOSI+2;
EMenuOut(x,ypos,"d=",2,1,8);
if( MGetUnitType() > 0)para3 = (int)((para1 - 1000)*2+500)/1000;
else para3 = (int)((para1 - 254)*2+127)/254;
para1 = para4;
//Write_Number(10,50,para1,8,0,1);
if( para1 < 1)para1 = 1;
para1 = (int)( 200 * ( log10(para1) - log10(600) ) );
//Write_Number(100,50,para1,8,0,1);
para1 = (MGetBaseGain() + MGetCompGain() - para1+5)/10;
//Write_Number(200,50,para1,8,0,1);
para2 = (MGetBaseGain()+5)/10;
x += 8*2;
Write_Number(x,ypos,para1,2,0,0);
x+= 8*2;
EMenuOut(x,ypos,"-",1,1,8);
x += 8*1;
Write_Number(x,ypos,para2,2,0,0);
x+= 8*2;
EMenuOut(x,ypos,"-",1,1,8);
x += 8*1;
Write_Number(x,ypos,para3,2,0,0);
x+= 8*2;
EMenuOut(x,ypos,"=",1,1,8);
x += 8*1;
Write_Number(x,ypos,para1-para2-para3,3,0,1);
}
/*
Write_Number(10,30,AdjustTime.ParaDisplayTime,10,0,0);
Write_Number(10,40,AdjustTime.amp_total,10,0,0);
Write_Number(10,50,AdjustTime.amp_total2,10,0,0);
Write_Number(10,60,AdjustTime.time,10,0,0);
Write_Number(10,70,AdjustTime.time2,10,0,0);
//*/
AdjustTime.ParaDisplayTime = 0;
AdjustTime.amp_total = 0;
AdjustTime.amp_total2 = 0;
AdjustTime.time = AdjustTime.time2 = 0;
}
if( MGetFunctionMode(C_GATE_ALARM) == 1)
{
//gateamp = MGetAmpMax(0);
para1 = pos1;
//para2 = MGetAmpMax(1);
para3 = MGetGatePara(0, 2);
para4 = MGetGatePara(1, 2);
mode1 = MGetBGateMode();
//Write_Number(10,30,amp1,4,0,0);
//Write_Number(50,30,para3,4,0,0);
//Write_Number(10,40,amp2,4,0,0);
//Write_Number(50,40,para4,4,0,0);
//Write_Number(60,50,mode1,4,0,0);
//首先看A门
if( mode1 == 0 && amp2 < para4)BuzzerOn(1);//B门失波
else if (mode1 == 1 && amp2 > para4 )BuzzerOn(1);//两进波门
else if ((MGetTestStatus(C_TEST_DAC) == 1 || MGetTestStatus(C_TEST_AVG) == 1) && MGetFunctionMode(C_DAC_GATE) == 1 )
{
//有DAC门
// if (Amp2db( para1,gateamp ) > MGetGatedB() )BuzzerOn(1);
u_char * sampbuff = GetSampleBuffer();
u_short amp;
mode2 = MGetAcquisitionEnable();
para1 = para2 = MGetGatePara(0, 0);
para3 = para1 + MGetGatePara(0, 1);
///MSetAcquisitionEnable(0,C_SETMODE_SETSAVE);
for( para2 = 2*para2 + C_OFF_DACGATE; para1 < para3; para1++)
{
MCopyProtectedMemory( &, (void*)para2, C_SIZE_SHORT, PM_COPY_READ);
if( sampbuff[para1] > amp)
{
BuzzerOn(1);
break;
}
para2 += C_SIZE_SHORT;
}
///MSetAcquisitionEnable(mode2,C_SETMODE_SETSAVE);
}
else if (amp1 > para3 )
{
//A门永远进波
BuzzerOn(1);
}
}
AdjustTime.PreElapsedTime = ElapsedTime ;
//MSetOntime( ElapsedTime/1000,0);
AdjustTime.GainPlusTime += time;
AdjustTime.GainMinusTime += time;
AdjustTime.ParaDisplayTime += time;
///if( gateamp > 100 )AdjustTime.GainPlusTime = 0;//波高大于100,小于160不自动调节波高
///if( gateamp <140 )AdjustTime.GainMinusTime = 0;
return 0;
}
void WritePeakPrompt(int mode1,int mode2)//mode1=0B门失波1进波,mode2=0波高1dB数
{
u_int testrange[3]; //待测声程值
int offset;
int number;
u_char pzText[] = " x ";
pzText[0] = 'z' + 14;
u_char ch;
offset = C_OFF_TEMP + 30;
MCopyProtectedMemory( testrange, (void*)offset, 12, PM_COPY_READ);
MSetColor(C_CR_MENU);
MEraseWindow(0, C_COORVPOSI - 10, 40*8, C_COORVPOSI - 1) ;
if( mode2 != 1)
{
pzText[0] = ' ';
pzText[1] = ' ';
pzText[2] = ' ';
pzText[4] = 'L';
pzText[5] = ' ';
}
switch (mode2)
{
case 2:
pzText[3] = 'R';
break;
case 3:
pzText[3] = 'S';
break;
case 4:
pzText[3] = 'E';
break;
case 5:
pzText[3] = '4';
break;
case 6:
pzText[3] = '5';
break;
case 7:
pzText[3] = '6';
break;
case 10:
pzText[0] = ' ';
pzText[1] = ' ';
pzText[2] = ' ';
pzText[3] = ' ';
pzText[4] = 'z'+14;
pzText[5] = '2';
break;
case 11:
pzText[0] = 'z'+14;
pzText[1] = ' ';
pzText[2] = ' ';
pzText[3] = ' ';
pzText[4] = ' ';//'z'+14;
pzText[6] = 'z'+14;
if( MGetUnitType() == 0)
{
pzText[7] = (int)( powf( 10,( MGetLineGain(2) + 120 ) / 400.0) + 0.05)+0x30;
}
break;
}
if( mode1 == 0 )
{
//b门失波
Write_Ascii(0,C_COORVPOSI - 10,'z'+9);
Write_Ascii(7*8,C_COORVPOSI - 10,'z'+10);
Write_Ascii(14*8,C_COORVPOSI - 10,'z'+11);
if(mode2 > 0)
{
//显示dB数
EMenuOut(22*8,C_COORVPOSI - 10,pzText,8,1,8);
/// EMenuOut(33*8+2,C_COORVPOSI - 10,"dB",2,1,8);
if (mode2 == 1)
{
if( MGetUnitType() > 0)
{
WriteLongness(23*8+1,C_COORVPOSI - 10,(UINT)(Dac.diameter*100/25.4+0.5),5,0);
}
else
{
Write_Number(23*8,C_COORVPOSI - 10,Dac.diameter/10,2,0,0);
Write_Number(26*8+2,C_COORVPOSI - 10,Dac.length/10,2,0,0);
}
}
if (mode2 == 11)
{
//avg孔径
if( MGetUnitType() > 0)
{
number = (UINT)( 10*powf( 10,( MGetLineGain(2) + 120 ) / 400.0) + 0.5);
number = (UINT)( number * 1000.0/254+0.5);
WriteLongness(29*8+1,C_COORVPOSI - 10,number,4,0);
}
else Write_Number(29*8+1,C_COORVPOSI - 10,(int)( 10*powf( 10,( MGetLineGain(2) + 120 ) / 400.0) + 0.5)/10, 1,0,0);//显示dB
/// Write_Number(27*8,C_COORVPOSI - 10,(int)( 10*powf( 10,( MGetLineGain(2) + 120 ) / 400.0) + 0.5)/10, 1,0,0);//显示dB
}
}
else
{
//显示波高
Write_Ascii(22*8,C_COORVPOSI - 10,'z'+12);
Write_Ascii(27*8,C_COORVPOSI - 10,'%');
}
}
else
{
//b门进波
EMenuOut(0,C_COORVPOSI - 10,"A:",2,1,8);
EMenuOut(20*8,C_COORVPOSI - 10,"B:",2,1,8);
switch (MGetScaleMode() )
{
case 0:
ch = 'z' + 11;
break;
case 1:
ch = 'z' + 10;
break;
default:
ch = 'z' + 9;
break;
}
Write_Ascii(2*8,C_COORVPOSI - 10,ch);
Write_Ascii(22*8,C_COORVPOSI - 10,ch);
if( mode2 >= 10)
{
pzText[4] = 'z'+14;
if(mode2 == 10 )pzText[5] = '2';
else pzText[5] = (int)( powf( 10,( MGetLineGain(2) + 120 ) / 400.0) + 0.05)+0x30;
pzText[6] = ' ';
pzText[7] = ' ';
}
if(mode2 > 0 )
{
if(mode2 == 1)
{
pzText[3] = 'D';
pzText[4] = 'A';
pzText[5] = 'C';
}
EMenuOut(10*8,C_COORVPOSI - 10,pzText+3,8,1,8);
EMenuOut(31*8,C_COORVPOSI - 10,pzText+3,8,1,8);
}
else
{
//AVG
Write_Ascii(10*8,C_COORVPOSI - 10,'z'+12);
Write_Ascii(15*8,C_COORVPOSI - 10,'%');
Write_Ascii(31*8,C_COORVPOSI - 10,'z'+12);
Write_Ascii(36*8,C_COORVPOSI - 10,'%');
}
}
}
extern GATE_PEAK GatePeak;
void WritePeakInfo(int mode1,int mode2,int para1,int para2,int para3,int para4)
{
//mode1=0B门失波1进波,mode2<0波高>0dB数
int ypos = 19;
MSetColor(C_CR_PARA);
if(mode1 == 0)
{
WriteLongness(1*8,ypos,para1,6,0);
WriteLongness(8*8,ypos,para2,6,0);
WriteLongness(15*8,ypos,para3,6,0);
/*
if( MGetUnitType() > 0)
{//单位inch
Write_Number(1*8,ypos,para1,6,3,0);
Write_Number(8*8,ypos,para2,6,3,0);
Write_Number(15*8,ypos,para3,6,3,0);
}
else
{
Write_Number(1*8,ypos,para1,6,1,0);
Write_Number(8*8,ypos,para2,6,1,0);
Write_Number(15*8,ypos,para3,6,1,0);
}
//*/
if( MGetEchoMode() == C_RF_WAVE)Write_Number(23*8,ypos,para4,4,1,1);
else if(mode2 < 0)Write_Number(23*8,ypos,para4,4,1,0); ///
else
{
Write_Number(34*8,ypos,para4,5,1,1);
if(MGetFunctionMode(C_DEPTH_COMPENSATE))///机务增加
{
EraseWindow(34*8,19,6*8,8);
Write_Number(34*8,19,200*log10((double)GatePeak.Gate1PeakAmp*5) - 200*log10((double)dac_line[MGetAmpPos(0)]*5),6,1,1);
}
}
}
else
{
WriteLongness(3*8,ypos,para1,6,0);
WriteLongness(23*8,ypos,para3,6,0);
/* if( MGetUnitType() > 0)
{//单位inch
Write_Number(3*8,ypos,para1,6,3,0);
Write_Number(23*8,ypos,para3,6,3,0);
}
else
{
Write_Number(3*8,ypos,para1,6,1,0);
Write_Number(23*8,ypos,para3,6,1,0);
}
//*/
if( MGetEchoMode() == C_RF_WAVE)Write_Number(11*8,ypos,para2,5,1,1);
else if(mode2 < 0) Write_Number(11*8,ypos,para2,4,1,0); ///
else Write_Number(13*8,ypos,para2,5,1,1);
if( MGetEchoMode() == C_RF_WAVE)Write_Number(32*8,ypos,para4,5,1,1);
else if(mode2 < 0)Write_Number(32*8,ypos,para4,4,1,0); ///
else Write_Number(34*8,ypos,para4,5,1,1);
int xpos;
xpos = C_COORWIDTH-8*11;
ypos = C_COORVPOSI;
EraseDrawRectangle(xpos,ypos,xpos + 8*11,ypos + 12);
xpos += 4;
ypos += 3;
EMenuOut( xpos,ypos,"B-A:",4,1,12);
xpos += 8*4;
if( para3 >= para1)
{
//b门内回波深度处理后比A门深
WriteLongness(xpos+8,ypos,para3-para1,4,0);
/* if( MGetUnitType() > 0)
{//单位inch
Write_Number( xpos,ypos,para3-para1,5,3,0);
}
else
{
Write_Number( xpos,ypos,para3-para1,5,1,0);
}
//*/
}
else
{
Write_Ascii( xpos,ypos,'-');
WriteLongness(xpos+8,ypos,para1-para3,4,0);
/* if( MGetUnitType() > 0)
{//单位inch
Write_Number( xpos+8,ypos,para1-para3,4,3,0);
}
else
{
Write_Number( xpos+8,ypos,para1-para3,4,1,0);
}
//*/
}
}
}
void MParaRenovate(u_int mode) /*参数区刷新,0立即*/
{
if(mode == 0) AdjustTime.ParaDisplayTime = (C_RENOVATE_TIME + C_RENOVATE_TIME );
GetDispEchoPara();/*得到指定门(0=A or 1=B)内回波的位置大小并写在屏幕上*/
MSetGateAmpColor();
}
/* 画坐标 参数为左上和高度、宽度*/
int MCoorDraw(u_int CoorHPosi , u_int CoorVPosi , u_int CoorHeight , u_int CoorWidth )
{
int i = 0;
int j = 0;
int k = 0;
ClearCursor(2);
if(CoorHeight < 100 || CoorWidth < 120)
return C_FALSE ;/* 如果高度小于100或宽度小于120,则不可画坐标,返回C_FALSE*/
else
{
MEraseWindow(0, CoorVPosi,CoorHPosi + CoorWidth + 40, CoorVPosi + CoorHeight+1) ; /* 清除窗体 */
if(CoorWidth == 280)
{
MDrawLine(CoorHPosi, CoorVPosi, C_SCREEN_WIDTH, CoorVPosi) ; /* 上边的线 */
MDrawLine(CoorHPosi, CoorVPosi + CoorHeight+1,C_SCREEN_WIDTH, CoorVPosi + CoorHeight+1) ;
}
else
{
MDrawLine(CoorHPosi, CoorVPosi, CoorHPosi + CoorWidth, CoorVPosi) ; /* 上边的线 */
MDrawLine(CoorHPosi, CoorVPosi + CoorHeight+1,CoorHPosi + CoorWidth, CoorVPosi + CoorHeight+1) ;
/* 下边的线 */
}
for (i = 1; i < 4; i++ ) /* 画水平的虚线,两线垂直相差40个点 */
{
for (j = 0; j <= CoorWidth/4; j++ )/* 一条水平虚线共需画CoorWidth/4个点,每4个点画一个点 */
{
/* draw a point at (x,y) in one of three modes: DP_NOT(inverse), DP_NOT(set) or DP_RESET(clear) */
//MDrawPixel(CoorHPosi + 4 * j, CoorVPosi + 40 * i, DP_NOT) ;
MDrawLine( CoorHPosi + 4 * j, CoorVPosi + 40 * i,CoorHPosi + 4 * j, CoorVPosi + 40 * i );
}
}
for (j = 0; j <= CoorWidth/4; j++ )/* 一条水平虚线共需画CoorWidth/4个点,每4个点画一个点 */
{
/* draw a point at (x,y) in one of three modes: DP_NOT(inverse), DP_NOT(set) or DP_RESET(clear) */
//MDrawPixel(CoorHPosi + 4 * j, CoorVPosi + 40 * i+1, DP_NOT) ;
MDrawLine(CoorHPosi + 4 * j, CoorVPosi + 40 * i+1,CoorHPosi + 4 * j, CoorVPosi + 40 * i+1);
}
for (i = 0; i < CoorHeight/40; i++ ) /* 画垂直的虚线 */
{
for (j = 0; j < CoorWidth/28 + 1; j++ ) /* 两线相差28个点 */
{
for (k = 1; k < 40/4; k ++ ) /* 两水平的虚线相差40个点,两线之间的垂直虚线所画的*/
{
//MDrawPixel(CoorHPosi + 28 * j, CoorVPosi + 40 * i + 4 * k, DP_NOT) ;
MDrawLine(CoorHPosi + 28 * j, CoorVPosi + 40 * i + 4 * k,CoorHPosi + 28 * j, CoorVPosi + 40 * i + 4 * k);
}
}
}
return C_TRUE; /* 画完坐标,返回C_TRUE */
}
}
void DrawDacGate(void)
{
int offset;
u_short dac_line[280];
offset = C_OFF_DACGATE;
MCopyProtectedMemory( dac_line, (void*)offset, 280 * C_SIZE_SHORT, PM_COPY_READ);
DrawGateCurver( dac_line, MGetGatePara(0,0), MGetGatePara(0,1),0);
}
void MGateDraw(void) /*画门*/
{
MDrawGate(0,0,-1,0);
MDrawGate(1,0,-1,0);
}
void MDrawGate( int/*-1两门都画0A门1B门*/ gatetype, int/*-1向下1向上*/ mode,
int paratype/*-1全门0门位1门宽2门高*/ ,int clear/*0新画1清除*/)
{
u_short v = C_COORVPOSI + C_COORHEIGHT; /* 垂直位置 */
u_short p ;
u_short h ;
u_short w ;
int gatenum;
int s = 4;
int m;
if( gatetype == 0 || gatetype == 1)gatenum = gatetype + 1;
else
{
gatenum = 2;
gatetype = 0;
}
if( mode == 1 || mode == -1)m = mode ;
else m = 1;
if( clear > 0 )clear = 1;
else clear = 0;
if( paratype == 0 || paratype == 1 || paratype == 2 );
else paratype = -1;
#if C_DEVTYPE == 4 || C_DEVTYPE == 20 || C_DEVTYPE == 5
gatenum = 1;
#endif
for( ; gatetype < gatenum; gatetype++)
{
if( gatetype == 0)MSetColor(C_CR_GATEA);
else MSetColor(C_CR_GATEB);
if( gatetype == 0 && paratype == -1 && MGetEchoMode() != C_RF_WAVE && MGetFunctionMode(C_DAC_GATE) == 1 )
{
//
DrawDacGate();
continue;
}
p = MGetGatePara(gatetype, 0); // 水平位置
w = MGetGatePara(gatetype, 1);
h = MGetGatePara(gatetype, 2);
if( mode == 0 )
{
if(gatetype == 0)m = 1;
else if( MGetBGateMode() == 1)m = 1;
else m = -1;
}
if( h < 5 )return;
if( MGetEchoMode() == C_RF_WAVE )
{
MSetEchoMode(0, C_SETMODE_SAVE);
MSetGatePara(p, w, C_COORHEIGHT/2+h/2, gatetype, C_SETMODE_SAVE);
MDrawGate(gatetype, m, paratype,clear);
MSetGatePara(p, w, C_COORHEIGHT/2-h/2, gatetype, C_SETMODE_SAVE);
MDrawGate(gatetype, (-1)*m, paratype, clear);
MSetEchoMode(C_RF_WAVE, C_SETMODE_SAVE);
MSetGatePara(p, w, h,gatetype, C_SETMODE_SETSAVE);
return;
}
if( paratype == 0 || paratype == -1)
{
//posi
MDrawLine( p - s , v-h-s*m, p-clear,v-h-clear*m );
}
if( paratype == 1 || paratype == -1)
{
//wide
MDrawLine( p+w + clear, v-h-clear*m, p+w+s,v-h-s*m );
}
if( paratype == 2 || paratype == -1)
{
//high
MDrawLine( p + 1, v-h, p+w-1,v-h );
}
MSetColor(C_CR_UNDO);
}
}
void Scrsave_Picture(void)
{
}
void MSetColor(int item)
{
#if C_COLOR == 1 || C_DEVLIB == 23
if( item == C_CR_UNDO || item == C_CR_DEFAULT)
{
u_int cr = MLoadColor( C_CR_CURRENT );
/*set color for screen operation, (b0-b2): red ; (b3-b5): green ; (b6-b7): blue */
if( item == C_CR_DEFAULT )
{
MSetDisplayColor( c_crPara[C_CR_YELLOW] );
//MSaveColor( C_CR_MENU, c_crPara[C_CR_YELLOW]);
}
else if(item == C_CR_UNDO )MSetDisplayColor( c_crPara[ crPara[item%(C_CR_MAX+10)] ] );
MSaveColor( C_CR_CURRENT, crPara[item%(C_CR_MAX+10)] );
MSaveColor( C_CR_UNDO, cr );
return;
}
if( item < 0 || item >= C_CR_MAX+10)item = 0;
MSaveColor( C_CR_UNDO, MLoadColor( C_CR_CURRENT ) );
MSaveColor( C_CR_CURRENT, crPara[item%(C_CR_MAX+10)] );
if( item == C_CR_WAVE)
{
int start,end, thick;
thick = MGetThick()*C_COORWIDTH/MGetRange(4);//板厚除以垂直声程
//*
#if C_DEVLIB == 3
if( extend > 0)MSetEchoColor( 0, C_SCREEN_WIDTH, c_crPara[ crPara[C_CR_BACK] ] );
#endif
MSetEchoColor( C_COORWIDTH + 10, C_SCREEN_WIDTH-1, c_crPara[ crPara[C_CR_BACK] ] );
// int amp0 = MGetAmpMax(0);
// int amp1 = MGetAmpMax(1);
if( thick < 1 )//|| amp0 >= MGetGatePara(0,2) || ( amp1 >= MGetGatePara(1,2) && MGetGatePara(1,2) > 0) )
{
MSetEchoColor( 0,C_COORWIDTH + 10, c_crPara[ crPara[C_CR_WAVE]%C_CR_NUMBER ] );
}
else
{
//有板厚
start = end = HoriOffsetScreen;
while( start < C_SCREEN_WIDTH && end < C_SCREEN_WIDTH)
{
end = start + thick;
if( end > C_SCREEN_WIDTH)end = C_SCREEN_WIDTH;
MSetEchoColor( start, end, c_crPara[ crPara[C_CR_WAVE]%C_CR_NUMBER ] );
start = end+1;
if( start > C_SCREEN_WIDTH)start = C_SCREEN_WIDTH;
end = start + thick;
if( end > C_SCREEN_WIDTH)end = C_SCREEN_WIDTH;
MSetEchoColor( start,end,c_crPara[ crPara[C_CR_SEWAVE]%C_CR_NUMBER ] );
start = end+1;
}
}
MSetAmp2Gate(0,0);
MSetAmp2Gate(1,0);
MSetGateAmpColor();
UpdateEchoColor() ;
}
//else
{
MSetDisplayColor( c_crPara[ crPara[item]%C_CR_NUMBER ] );
}
#endif
}
void MSaveColor(int item,u_int cr)
{
#if( C_COLOR == 1 || C_DEVLIB == 23)
// unsigned int offset = 0;
if( item < 0 || item >= C_CR_MAX+10)
{
item = 0;
MSaveDefualtColor(0);
}
else
{
crPara[item] = cr;
/// offset = C_OFF_TEMP+60; //颜色存储位置
/// MCopyProtectedMemory( (void*)offset, crPara, C_CR_MAX+10, PM_COPY_WRITE);
}
#endif
}
u_int MLoadColor(int item)
{
#if( C_COLOR == 1 || C_DEVLIB == 23)
if( item < 0 || item >= C_CR_MAX+10)item = 0;
if( crPara[item] > C_CR_NUMBER)
{
MSaveDefualtColor(0);
}
return crPara[item];
#endif
return 0;
}
void MSaveDefualtColor(int item)//设置默认颜色
{
#if( C_COLOR == 1)
unsigned int offset;
item = item%2;
if( item == 0)
{
for( offset = 0 ; offset < C_CR_MAX + 10; offset++)crPara[offset] = 0;
crPara[C_CR_WAVE] = 2;//回波黄色
crPara[C_CR_SEWAVE] = 3;//回波绿色
crPara[ C_CR_ENVELOPE] = 4;//青
crPara[ C_CR_MENU] = 3;//绿
crPara[ C_CR_PARA] = 2;//青
crPara[ C_CR_GATEA] = 1;//粉红
crPara[ C_CR_GATEB] = 3;//绿
crPara[ C_CR_CURVE] = 4;//青
crPara[ C_CR_BACK] = 8;//青
}
else if( item == 1)
{
for( offset = 0 ; offset < C_CR_MAX + 10; offset++)crPara[offset] = 0;
crPara[C_CR_WAVE] = 8;//回波黄色
crPara[C_CR_SEWAVE] = 8;//回波绿色
crPara[ C_CR_ENVELOPE] = 8;//青
crPara[ C_CR_MENU] = 8;//绿
crPara[ C_CR_PARA] = 8;//青
crPara[ C_CR_GATEA] = 8;//粉红
crPara[ C_CR_GATEB] = 8;//绿
crPara[ C_CR_CURVE] = 8;//青
crPara[ C_CR_BACK] = 7;//青
}
else if( item == 2)
{
for( offset = 0 ; offset < C_CR_MAX + 10; offset++)crPara[offset] = 0;
crPara[C_CR_WAVE] = 3;//回波黄色
crPara[C_CR_SEWAVE] = 3;//回波绿色
crPara[ C_CR_ENVELOPE] = 8;//青
crPara[ C_CR_MENU] = 8;//绿
crPara[ C_CR_PARA] = 8;//青
crPara[ C_CR_GATEA] = 8;//粉红
crPara[ C_CR_GATEB] = 8;//绿
crPara[ C_CR_CURVE] = 8;//青
crPara[ C_CR_BACK] = 7;//青
}
else if( item == 3)
{
for( offset = 0 ; offset < C_CR_MAX + 10; offset++)crPara[offset] = 0;
crPara[C_CR_WAVE] = 4;//回波黄色
crPara[C_CR_SEWAVE] = 4;//回波绿色
crPara[ C_CR_ENVELOPE] = 8;//青
crPara[ C_CR_MENU] = 8;//绿
crPara[ C_CR_PARA] = 8;//青
crPara[ C_CR_GATEA] = 8;//粉红
crPara[ C_CR_GATEB] = 8;//绿
crPara[ C_CR_CURVE] = 8;//青
crPara[ C_CR_BACK] = 7;//青
}
offset = C_OFF_TEMP+60; //颜色存储位置
MCopyProtectedMemory( (void*)offset, crPara, C_CR_MAX+10, PM_COPY_WRITE);
MSetColorMode(item,C_SETMODE_SAVE);
SetBackgroundColor(c_crPara[crPara[ C_CR_BACK] ]);
#else
#if C_DEVLIB == 23
unsigned int offset;
item = item%2;
if( item == 0)
{
for( offset = 0 ; offset < C_CR_MAX + 10; offset++)crPara[offset] = 0;
crPara[C_CR_WAVE] = 2;//回波黄色
crPara[C_CR_SEWAVE] = 2;//回波
crPara[ C_CR_ENVELOPE] = 2;//
crPara[ C_CR_MENU] = 2;//
crPara[ C_CR_PARA] = 2;//
crPara[ C_CR_GATEA] = 2;//
crPara[ C_CR_GATEB] = 2;//
crPara[ C_CR_CURVE] = 2;//
crPara[ C_CR_BACK] = 8;//
}
else if( item == 1)
{
for( offset = 0 ; offset < C_CR_MAX + 10; offset++)crPara[offset] = 0;
crPara[C_CR_WAVE] = 8;//回波
crPara[C_CR_SEWAVE] = 8;//回波
crPara[ C_CR_ENVELOPE] = 8;//
crPara[ C_CR_MENU] = 8;//
crPara[ C_CR_PARA] = 8;//
crPara[ C_CR_GATEA] = 8;//
crPara[ C_CR_GATEB] = 8;//
crPara[ C_CR_CURVE] = 8;//
crPara[ C_CR_BACK] = 7;//
}
offset = C_OFF_TEMP+60; //颜色存储位置
MCopyProtectedMemory( (void*)offset, crPara, C_CR_MAX+10, PM_COPY_WRITE);
MSetColorMode(item,C_SETMODE_SAVE);
SetBackgroundColor(c_crPara[crPara[ C_CR_BACK] ]);
#endif
#endif
}
void MSetGateAmpColor()
{
#if C_COLOR == 1 || C_DEVLIB == 23
MSetEchoColor( MGetGatePara(0,0), MGetGatePara(0,0)+MGetGatePara(0,1), c_crPara[1]/*c_crPara[ crPara[C_CR_WAVE]%C_CR_NUMBER ]*/ );
/*short start,end;
int thick;
for( start = 0; start < 2; start++)
{
//用start来代门类型0门A,1门B
if ((MGetTestStatus(C_TEST_DAC) == 1 || MGetTestStatus(C_TEST_AVG) == 1) && MGetFunctionMode(C_DAC_GATE) == 1 && start == 0)
{
thick = 2*MGetAmpPos1(0,1) + C_OFF_DACGATE;
MCopyProtectedMemory( &end, (void*)thick, C_SIZE_SHORT, PM_COPY_READ);
thick = MGetAmpPos1(0,11);
//Write_Number(150,30,end,4,0,0);
if( thick < end && MGetAmp2Gate(start) > 0 )
{
//现在门内回波低于门高,原来高于门高
MSetGateEchoColor( start,1);
MSetAmp2Gate(start,0);
}
else if( thick >= end && MGetAmp2Gate(start) == 0 )
{
//现在门内回波高于门高,原来低于门高
MSetGateEchoColor( start,1);
MSetAmp2Gate(start,1);
}
else MSetGateEchoColor( start,0);
}
else
{
if( MGetAmpMax(start) < MGetGatePara(start,2) && MGetAmp2Gate(start) > 0)
{
//现在门内回波低于门高,原来高于门高
MSetGateEchoColor( start,1);
///MSetAmp2Gate(start,0);
MSetAmp2Gate(start,1);
}
else if( MGetAmpMax(start) >= MGetGatePara(start,2) && MGetAmp2Gate(start) == 0 )
{
//现在门内回波高于门高,原来低于门高
MSetGateEchoColor( start,1);
MSetAmp2Gate(start,1);
}
///else MSetGateEchoColor( start,0);
}
}
if( MGetGateEchoColor(0) > 0 || MGetGateEchoColor(1) > 0 )//表示门内的回波有跨越门高,需要改变回波颜色
{
//2表示门A,4表示门B,6表示两门都变
MSetEchoColor( 0, C_SCREEN_WIDTH, c_crPara[ C_CR_BLACK ] );
thick = MGetThick()*C_COORWIDTH/MGetRange(4);//板厚除以垂直声程
// Write_Number(10,30,thick,10,0,0);
if( thick < 1)
{
MSetEchoColor( 0, C_SCREEN_WIDTH, c_crPara[ crPara[C_CR_WAVE]%C_CR_NUMBER ] );
}
else
{
start = end = HoriOffsetScreen;
while( start < C_SCREEN_WIDTH && end < C_SCREEN_WIDTH)
{
end = start + thick;
if( end > C_SCREEN_WIDTH)end = C_SCREEN_WIDTH;
MSetEchoColor( start, end, c_crPara[ crPara[C_CR_WAVE]%C_CR_NUMBER ] );
start = end+1;
if( start > C_SCREEN_WIDTH)start = C_SCREEN_WIDTH;
end = start + thick;
if( end > C_SCREEN_WIDTH)end = C_SCREEN_WIDTH;
MSetEchoColor( start,end,c_crPara[ crPara[C_CR_SEWAVE]%C_CR_NUMBER ] );
start = end+1;
}
}
if( C_DEVLIB == 3)thick = 0;
else thick = HoriOffsetScreen;
if( MGetGateEchoColor(0) > 0 && MGetAmp2Gate(0) > 0 )
{
start = MGetAmpPos1(0,5) + thick+1;
end = MGetAmpPos1(0,2) + thick+1;
MSetEchoColor( start,end,c_crPara[ crPara[C_CR_GATEA]%C_CR_NUMBER ] );
}
///Write_Number(10,50,start,4,0,0);
///Write_Number(50,50,end,4,0,0);
if( MGetGatePara(1,2) > 0 && MGetGateEchoColor(1) > 0 && MGetAmp2Gate(1) > 0)
{
start = MGetAmpPos1(1,5) + thick+1;
end = MGetAmpPos1(1,2) + thick+1;
MSetEchoColor( start,end,c_crPara[ crPara[C_CR_GATEB]%C_CR_NUMBER ] );
}
///Write_Number(100,50,start,4,0,0);
///Write_Number(150,50,end,4,0,0);
MSetEchoColor( C_COORWIDTH + 10, C_SCREEN_WIDTH-1, c_crPara[ crPara[C_CR_BACK] ]);
UpdateEchoColor() ;
MSetGateEchoColor(0,0);
MSetGateEchoColor(1,0);
}*/
#endif
}
/*extern void MaxRange(int iRange);
extern int iItem;
int TanRangeChange(void)
{
int retvalue = C_TRUE;
int keycode,rotary;
int step = MGetParaStep(C_RANGE);
int time = 15;
ClearEnvelope(); //清包络或峰值
do
{
WriteParaName(C_RANGE + MGetScaleMode() );
Write_Ascii(4*C_CCHAR_HDOT,C_ECHAR_VDOT,'-');
Write_Number(4*C_CCHAR_HDOT+C_ECHAR_HDOT,C_ECHAR_VDOT,step,1,0,0);
InvertBytes(C_RANGE_HPOSI, C_RANGE_VPOSI, 5) ;
while(1)
{
time = C_KEYDELAY;
ExpendTime(time);
keycode = MGetKeyCode(0);
MParaRenovate(1);
if(keycode == C_KEYCODMAX)
{
continue;
}
else rotary = 1;
if(GetNoKeyTime() > 60 && MGetSystemMode() == 1)return -1;
//在自动测试状态下未按超过60s则超出参量调节状态
if(keycode == C_KEYCOD_PLUS || keycode == C_KEYCOD_MINUS )
{
if(MGetFunctionMode(C_DAC_GATE))MDrawGate(0,0,-1,0);
DrawDac(1);
do
{
if( rotary < 3 || step == 2)rotary = 1;
if(keycode == C_KEYCOD_PLUS)
TanRangePlus(rotary*step);
else
TanRangeMinus(rotary*step);
WriteRange(C_RANGE_HPOSI,C_RANGE_VPOSI);
// InvertBytes(C_RANGE_HPOSI, C_RANGE_VPOSI, 5) ;
WriteScale(); //标度
if(time > 20)time -= 5;
else time -= 3;
if(time < 3)time = 2;
ExpendTime(time);
if( keycode != MGetKeyCode(0) )break;
}
while( true );
DrawDac(0);
if( MGetFunctionMode(C_DAC_GATE) == 1)
{
DacGateInit();
MDrawGate(0,0,-1,0);
}
}
else if(keycode == C_KEYCOD_RANGE)
{
step = ParaStepChange(C_RANGE); //设置待调节参量步长
InvertBytes(C_RANGE_HPOSI, C_RANGE_VPOSI, 5) ;
}
else if(keycode == C_KEYCOD_CONFIRM)
{
MSetScaleMode(MGetScaleMode()+1,0);
u_char ch;
switch (MGetScaleMode() )
{
case 0:
Write_Ascii(C_RANGE_HPOSI + 8 * C_ECHAR_HDOT,C_RANGE_VPOSI+ 0,'Y');
ch = 'z' + 11;
break;
case 1:
Write_Ascii(C_RANGE_HPOSI + 8 * C_ECHAR_HDOT,C_RANGE_VPOSI+ 0,'X');
ch = 'z' + 10;
break;
default:
Write_Ascii(C_RANGE_HPOSI + 8 * C_ECHAR_HDOT,C_RANGE_VPOSI+ 0,'S');
ch = 'z' + 9;
break;
}
if( MGetBGateMode() ==1 )
{
Write_Ascii(2*8,C_COORVPOSI - 10,ch);
Write_Ascii(22*8,C_COORVPOSI - 10,ch);
}
MParaRenovate(1);
WriteParaName(C_RANGE + MGetScaleMode() - 0);
WriteRange(C_RANGE_HPOSI,C_RANGE_VPOSI);
ExpendTime(20);
}
else
{
WriteRange(C_RANGE_HPOSI,C_RANGE_VPOSI);
MSelectPrompt(keycode);
return keycode;
}
break;
}
if( !retvalue ) break;
WriteScale(); //标度
}
while (1);
if(keycode == C_KEYCOD_RETURN || keycode == C_KEYCOD_CONFIRM)
{
keycode = -1;
DisplayPrompt(16);
}
else DisplayPrompt(15);
WriteRange(C_RANGE_HPOSI,C_RANGE_VPOSI);
ClearEnvelope(); //清包络或峰值
return retvalue;
}
int TanRangePlus(int step)
{
u_int range = MGetRange(1);
if (step == 2)
{
if (range >= 3000)
{
if( (range + 20)%1000 < 20 )range = (range + 20);
range = ( range/1000 + 1) * 1000;
}
else
{
step = 1;
while ( range + 5 > (u_int)_RANGEVALUE[step])
{
step++;
}
range = (u_int)_RANGEVALUE[step];
}
}
else if( range <= 30000)
{
range = range + step*10;
}
else if( range <= 60000)
{
range = range + step*20;
}
else
{
range = range + step*50;
}
MSetRange(range,C_SETMODE_SETSAVE) ;
if ( ( MGetEchoMode() != C_RF_WAVE && MGetRange(3) + MGetDelay(3) >= C_MAX_RANGE ) || ( MGetEchoMode() == C_RF_WAVE && MGetRange(3) + MGetDelay(3) > C_MAX_RF_RANGE) )
{
int scale = MGetScaleMode();
MSetScaleMode(2,0);
if( MGetEchoMode() != C_RF_WAVE)MSetRange(C_MAX_RANGE - MGetDelay(3), C_SETMODE_SETSAVE) ;
else MSetRange(C_MAX_RF_RANGE - MGetDelay(3), C_SETMODE_SETSAVE) ;
MSetScaleMode(scale,0);
DisplayPrompt(3);
return C_FALSE;
}
else if( MGetSpeed() < CD_SPEED_2 * 110/100 && MGetProbeMode() == C_APROBE && MGetRange(3) + MGetDelay(3) >= C_MAX_RANGE/2)
{
int scale = MGetScaleMode();
MSetScaleMode(2,0);
MSetRange(C_MAX_RANGE/2 - MGetDelay(3), C_SETMODE_SETSAVE) ;
MSetScaleMode(scale,0);
DisplayPrompt(3);
return C_FALSE;
}
return C_TRUE;
}
int TanRangeMinus(int step)
{
u_int range = MGetRange(0);
if (range <= C_MIN_TIMERANGE)
{
DisplayPrompt(3);
return C_FALSE;
}
range = MGetRange(1);
if (range <= C_MIN_RANGE)
{
DisplayPrompt(3);
return C_FALSE;
}
if (step == 2 )
{
if (range > 3000)
{
if( range%1000 < 20 )range = ( range/1000 ) * 1000;;
if( range%1000 == 0 )range = range - 1000;
else range = ( range/1000 ) * 1000;
}
else
{
step = 1; //暂用step作指针
while ( range > (u_int)_RANGEVALUE[step])
{
step++;
}
range = (u_int)_RANGEVALUE[step -1];
}
}
else if( range <= 30000)
{
range = range - step*10;
}
else if( range <= 60000)
{
range = range - step*20;
}
else
{
range = range - step*50;
}
MSetRange(range,C_SETMODE_SETSAVE) ;
return C_TRUE;
}*/
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。