1 Star 0 Fork 0

jsshinechow/JW

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
display.c 130.09 KB
一键复制 编辑 原始数据 按行查看 历史
jsshinechow 提交于 2019-03-07 13:42 . 分屏显示,软件画波形
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445
// 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(&para1,&para2,&para3,&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(&para1,&para2,&para3,&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(&para3,&para2,&para4,&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( &amp, (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;
}*/
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jsshinechow/JW.git
[email protected]:jsshinechow/JW.git
jsshinechow
JW
JW
master

搜索帮助