123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601 |
- #include "global.h"
- #if XI_DONG_MACHINE
- void YYa_AlarmProtect(void);
- void YYa_ManualAction(void);
- void YYa_AutoAction(void);
- void YYa_StepCheckStart(void);
- void YYa_ExtiActionX31(void);
- void YYa_SongLiao(void);
- void YY_JieTouControl(void);
- void YY_ZhuYou(void);
- void YY_Stop_Action(void);
- void YY_StartZYFirst(void);
- float YY_CalToothLength(unsigned short roll_diameter,unsigned short tooth_num);
- //输入齿数计算长度返回的是单位厘米
- unsigned long YY_ToothNumCalLengthCM(float single_length,unsigned short tooth_num,unsigned long zipper_num);
- //输入齿数计算长度返回的是单位英寸
- unsigned long YY_ToothNumCalLengthInch(float single_length,unsigned short tooth_num,unsigned long zipper_num);
- //输入长度厘米算齿数
- unsigned long YY_ToothLengthCMCalNum(float single_length,unsigned short tooth_length,unsigned long zipper_num);
- //输入长度厘米算英寸
- unsigned long YY_ToothLengthCMCalInch(float single_length,unsigned short tooth_length,unsigned long zipper_num);
- //输入厘米长度计算总长度单位米
- unsigned long YY_LengthCalLengthM(unsigned short set_length,unsigned short kongwei_length,unsigned long zipper_num);
- //输入英寸长度计算总长度
- unsigned long YY_InchLengthCalLength(unsigned short set_length,unsigned short kongwei_length,unsigned long zipper_num);
- //输入齿数计算长度返回的是单位米
- unsigned long YY_ToothNumCalLength(float single_length,unsigned short tooth_num,unsigned long zipper_num);
- //输入齿数计算长度返回的是单位米带浮点型
- float YY_ToothNumCalLengthFloat(float single_length,unsigned short tooth_num,unsigned long zipper_num);
- //输入长度英寸算齿数
- unsigned long YY_ToothLengthInchCalNum(float single_length,unsigned short tooth_length,unsigned long zipper_num);
- //输入长度英寸算厘米
- unsigned long YY_ToothLengthInchCalCM(float single_length,unsigned short tooth_length,unsigned long zipper_num);
- void YY_SetLeftPyData(unsigned short cLeftData,unsigned short cLeftKongWei);
- void YY_SetRightPyData(unsigned short cRightData,unsigned short cRightKongWei);
- void SetLeftSpaceDisplay(unsigned char mode,unsigned short source_data);
- void SetRightSpaceDisplay(unsigned char mode,unsigned short source_data);
- void YY_SetLeftDCTSpace(void);
- void YY_SetRightDCTSpace(void);
- void YY_SetLeftDCTTooth(void);
- void YY_SetRightDCTTooth(void);
- unsigned long YY_GetLeftToothNum(void);
- unsigned long YY_GetRightToothNum(void);
- unsigned long YY_GetLeftToothNumDisplay(void);
- unsigned long YY_GetRightToothNumDisplay(void);
- unsigned long YY_GetLeftSpace(void);
- unsigned long YY_GetRightSpace(void);
- unsigned long YY_GetLeftSpaceDisplay(void);
- unsigned long YY_GetRightSpaceDisplay(void);
- void YY_SetLeftDisplay(unsigned short source_data);
- void YY_SetRightDisplay(unsigned short source_data);
- void YY_SetLeftSpaceDisplay(unsigned short source_data);
- void YY_SetRightSpaceDisplay(unsigned short source_data);
- void YY_AddTotal(void);
- unsigned long YY_GetTotal(void);
- unsigned long YY_GetSetTotal(void);
- void YY_LeftToothDisplayAdd(void);
- void YY_RightToothDisplayAdd(void);
- void YY_LeftSpaceDisplayAdd(void);
- void YY_RightSpaceDisplayAdd(void);
- void YY_LeftOverSet(void);
- void YY_RightOverSet(void);
- float YY_SingleToothLength;
- unsigned long YY_cTotal,YY_ProOnceTime,YY_cJieDaiClrTotal,YY_cJieDaiState,YY_cJieDaiTotal;
- unsigned char YY_RightCountEnable,YY_cOverTotalLeftFlg = 0,YY_cOverTotalRightFlg = 0,YY_LeftOk,YY_RightOk,YY_ChangeNextGroupFlg,YY_cTatal_OK,YY_CalUseLifeFlg,
- YY_SaveParamFlg,YY_UseLifeNowGroup,YY_LastGroup,YY_cHeLian,YY_bOldMode,YY_OldGroup;
- unsigned short YY_NowLeftPyNum,YY_NowRightPyNum,YY_NowLeftPyKongWei,YY_NowRightPyKongWei,YY_ZYBuff,YY_cStartWorkTime;
- unsigned short YY_cStartPYFlag_Left,YY_cStartPYFlag_Right;
- YY_SingleParam_str *YY_SingleParam;
- YY_GroupParam_str *YY_GroupParam;
- YY_SystemParam_str *YY_SystemParam;
- YY_ComponentParam_str *YY_ComponentParam;
- void YYa_SetAlarmCode(unsigned short alarm_code)
- {
- YY_SystemParam->AlarmCode |= alarm_code;
- YY_bAlarmStop = 1;
- }
- void YYa_SetLifeAlarmCode(unsigned short alarm_code)
- {
- YY_ComponentParam->LifeAlarm |= 0x0001 << alarm_code;
- }
- void YYa_InitAction(void)
- {
- static unsigned long start_delay;
-
- YY_SingleParam = (YY_SingleParam_str *)&user_datas[YY_SINGLE_ADDR];
- YY_GroupParam = (YY_GroupParam_str *)&user_datas[YY_GROUP_ADDR];
- YY_SystemParam = (YY_SystemParam_str *)&user_datas[YY_SYSTEM_ADDR];
- YY_ComponentParam = (YY_ComponentParam_str *)&user_datas[YY_LIFE_ADDR];
-
- if(YY_SystemParam->NowGroup > 4)YY_SystemParam->NowGroup = 0;
-
- YY_SingleToothLength = YY_CalToothLength(YY_SystemParam->ToothLength,YY_SystemParam->ToothNum);
- YY_bMode = YY_SINGLE_MODE;
- YY_bDCTEnable = 1;
- YY_cTotal = YY_GetTotal();
-
- YY_StartZYFirst();
- YY_bCalculateTotal = 1; //bCalculate
- YY_SystemParam->AlarmCode = 0;
- start_delay = dwTickCount + 1000;
- while(dwTickCount <= start_delay)
- {
- io_app_read_input();
- }
- }
- void YYa_Action(void)
- {
- YYa_ManualAction();
- YYa_AutoAction();
- YY_ZhuYou();
- YYa_SongLiao();
- YYa_StepCheckStart(); // 调用脚踏开关检测程序
- YYa_AlarmProtect();
- }
- void YY_ClearJTData(void)
- {
- YY_cJieDaiState = 0;
- YY_cJieDaiTotal = 0;
- YY_cJieDaiClrTotal = 0;
- }
- //重设数据
- void YY_ReSetData(void)
- {
- unsigned char i;
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- if((YY_SingleParam->DisplyLeftToothNum != YY_SingleParam->DisplyRightToothNum) || (YY_SingleParam->DisplyLeftToothNumSpace != YY_SingleParam->DisplyRightToothNumSpace))
- YY_RightCountEnable = 1;
- else
- YY_RightCountEnable = 0;
- YY_SingleParam->DisplyLeftToothNum = 0;
- YY_SingleParam->DisplyLeftToothLengthCM = 0;
- YY_SingleParam->DisplyLeftToothLengthINCH = 0;
- YY_SingleParam->DisplyLeftToothNumSpace = 0;
- YY_SingleParam->DisplyLeftToothLengthCMSpace = 0;
- YY_SingleParam->DisplyLeftToothLengthINCHSpace = 0;
- YY_SingleParam->DisplyRightToothNum = 0;
- YY_SingleParam->DisplyRightToothLengthCM = 0;
- YY_SingleParam->DisplyRightToothLengthINCH = 0;
- YY_SingleParam->DisplyRightToothNumSpace = 0;
- YY_SingleParam->DisplyRightToothLengthCMSpace = 0;
- YY_SingleParam->DisplyRightToothLengthINCHSpace = 0;
- YY_ClearJTData();
-
- }break;
- case YY_GROUP_MODE:
- {
- if((YY_GroupParam->DisplyLeftToothNum[YY_SystemParam->NowGroup] != YY_GroupParam->DisplyRightToothNum[YY_SystemParam->NowGroup]) || (YY_GroupParam->DisplyLeftToothNumSpace[YY_SystemParam->NowGroup] != YY_GroupParam->DisplyRightToothNumSpace[YY_SystemParam->NowGroup]))
- {
- YY_RightCountEnable = 1;
- }
- else
- {
- YY_RightCountEnable = 0;
- }
-
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->DisplyLeftToothNum[i] = 0;
- YY_GroupParam->DisplyLeftToothLengthCM[i] = 0;
- YY_GroupParam->DisplyLeftToothLengthINCH[i] = 0;
- YY_GroupParam->DisplyLeftToothNumSpace[i]= 0;
- YY_GroupParam->DisplyLeftToothLengthCMSpace[i]= 0;
- YY_GroupParam->DisplyLeftToothLengthINCHSpace[i]= 0;
- YY_GroupParam->DisplyRightToothNum[i]= 0;
- YY_GroupParam->DisplyRightToothLengthCM[i]= 0;
- YY_GroupParam->DisplyRightToothLengthINCH[i]= 0;
- YY_GroupParam->DisplyRightToothLengthCM[i]= 0;
- YY_GroupParam->DisplyRightToothLengthCMSpace[i]= 0;
- YY_GroupParam->DisplyRightToothLengthINCHSpace[i]= 0;
- YY_ClearJTData();
- }
- }break;
- }
- }
- unsigned long YY_CalOverLength(void)
- {
- unsigned char i;
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- YY_SingleParam->OverLength = (YY_SingleParam->LeftToothLengthCM + YY_SingleParam->LeftToothLengthCMSpace) * YY_SingleParam->OverTotal / 1000;
- }break;
- case YY_GROUP_MODE:
- {
- YY_GroupParam->AllOverLength = 0;
- for(i=0;i<5;i++)
- {
- YY_GroupParam->AllOverLength += (YY_GroupParam->LeftToothLengthCM[i] + YY_GroupParam->LeftToothLengthCMSpace[i]) * YY_GroupParam->OverSetTotal[i] / 1000;
- }
- }break;
- default:return 0;
- }
- return 0;
- }
- void YY_CalProcessTime(unsigned long add_time)
- {
- unsigned long time_buff,hour_buff,minute_buff;
- unsigned char i;
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- if(YY_MAIN_MOTOR)
- {
- time_buff = YY_SingleParam->OverTotal * (YY_SingleParam->LeftToothNum + YY_SingleParam->LeftToothNumSpace) * add_time;
- time_buff = time_buff / 1000;
-
- hour_buff = time_buff / 3600;
-
- YY_SingleParam->SetTimeHour = hour_buff;
- time_buff -= hour_buff * 3600;
-
- minute_buff = time_buff / 60;
-
- YY_SingleParam->SetTimeMinute = minute_buff;
- }
- }break;
- case YY_GROUP_MODE:
- {
- if(YY_MAIN_MOTOR)
- {
- time_buff = 0;
- for(i=0;i<5;i++)
- {
- time_buff += YY_GroupParam->OverSetTotal[i] * (YY_GroupParam->LeftToothNum[i] + YY_GroupParam->LeftToothNumSpace[i]) * add_time;
- }
- time_buff = time_buff / 1000;
-
- hour_buff = time_buff / 3600;
-
- YY_GroupParam->SetTimeHour = hour_buff;
- time_buff -= hour_buff * 3600;
-
- minute_buff = time_buff / 60;
-
- YY_GroupParam->SetTimeMinute = minute_buff;
-
- }
- }break;
- }
- }
- void YY_CalRemainTime(unsigned long one_time)
- {
- unsigned long time_buff,hour_buff,minute_buff;
- unsigned char i;
-
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- time_buff = one_time * (YY_SingleParam->SetTotal - YY_SingleParam->OverTotal) * (YY_SingleParam->LeftToothNum + YY_SingleParam->LeftToothNumSpace);
-
- time_buff = time_buff / 1000;
-
- hour_buff = time_buff / 3600;
-
- YY_SingleParam->RemainTimeHour = hour_buff;
- time_buff -= hour_buff * 3600;
-
- minute_buff = time_buff / 60;
-
- YY_SingleParam->RemainTimeMinute = minute_buff;
-
- }break;
- case YY_GROUP_MODE:
- {
- time_buff = 0;
- for(i=0;i<5;i++)
- {
- time_buff += (YY_GroupParam->SetTotal[i] - YY_GroupParam->OverSetTotal[i]) * (YY_GroupParam->LeftToothNum[i] + YY_GroupParam->LeftToothNumSpace[i]) * one_time;
- }
- time_buff = time_buff / 1000;
-
- hour_buff = time_buff / 3600;
-
- YY_GroupParam->RemainTimeHour = hour_buff;
- time_buff -= hour_buff * 3600;
-
- minute_buff = time_buff / 60;
-
- YY_GroupParam->RemainTimeMinute = minute_buff;
- }break;
- }
- }
- void YY_cTotal_Time(void)
- {
- YY_CalOverLength();
- YY_CalProcessTime(YY_ProOnceTime);
- YY_CalRemainTime(YY_ProOnceTime);
- }
- //参数运算控制
- void YY_CalculataParam(void)
- {
- unsigned char i;
- unsigned long total_buff;
-
- if(YY_bMode != YY_bOldMode)
- {
- YY_cTotal = YY_GetTotal();
- }
- YY_bOldMode = YY_bMode;
-
- if(YY_SystemParam->NowGroup != YY_OldGroup)
- {
- YY_SystemParam->NextGroupBuff = YY_SystemParam->NowGroup + 1;
- }
- YY_OldGroup = YY_SystemParam->NowGroup;
-
- //输入右边的齿数
- if(YY_bCalInputRightToothNum)
- {
- YY_bCalInputRightToothNum = 0;
-
- YY_SingleParam->RightToothNumSpace = (YY_SingleParam->LeftToothNumSpace + YY_SingleParam->LeftToothNum) - YY_SingleParam->RightToothNum;
- YY_bCalInputToothNum = 1;
- }
-
- if(YY_bCalInputRightKongWei)
- {
- YY_bCalInputRightKongWei = 0;
-
- YY_SingleParam->RightToothNum = (YY_SingleParam->LeftToothNumSpace + YY_SingleParam->LeftToothNum) - YY_SingleParam->RightToothNumSpace;
- YY_bCalInputToothNum = 1;
- }
- //输入右边的长度
- if(YY_bCalInputRightToothNumLength)
- {
- YY_bCalInputRightToothNumLength = 0;
-
- YY_SingleParam->RightToothLengthCMSpace = (YY_SingleParam->LeftToothLengthCMSpace + YY_SingleParam->LeftToothLengthCM) - YY_SingleParam->RightToothLengthCM;
- YY_bCalInputLength = 1;
- }
-
- if(YY_bCalInputRightKongWeiLength)
- {
- YY_bCalInputRightKongWeiLength = 0;
-
- YY_SingleParam->RightToothLengthCM = (YY_SingleParam->LeftToothLengthCMSpace + YY_SingleParam->LeftToothLengthCM) - YY_SingleParam->RightToothLengthCMSpace;
- YY_bCalInputLength = 1;
- }
- //输入右边的英寸长度
- if(YY_bCalInputRightToothNumLengthInch)
- {
- YY_bCalInputRightToothNumLengthInch = 0;
-
- YY_SingleParam->RightToothLengthINCHSpace = (YY_SingleParam->LeftToothLengthINCHSpace + YY_SingleParam->LeftToothLengthINCH) - YY_SingleParam->RightToothLengthINCH;
- YY_bCalInputLengthInch = 1;
- }
-
- if(YY_bCalInputRightKongWeiLengthInch)
- {
- YY_bCalInputRightKongWeiLengthInch = 0;
-
- YY_SingleParam->RightToothLengthINCH = (YY_SingleParam->LeftToothLengthINCHSpace + YY_SingleParam->LeftToothLengthINCH) - YY_SingleParam->RightToothLengthINCHSpace;
- YY_bCalInputLengthInch = 1;
- }
-
-
- if(YY_bCalInputToothNum)
- {
- YY_bCalInputToothNum = 0;
-
- YY_SingleParam->LeftToothLengthCM = YY_ToothNumCalLengthCM(YY_SingleToothLength,YY_SingleParam->LeftToothNum,1);
- YY_SingleParam->LeftToothLengthINCH = YY_ToothNumCalLengthInch(YY_SingleToothLength,YY_SingleParam->LeftToothNum,1);
-
- YY_SingleParam->RightToothLengthCM = YY_ToothNumCalLengthCM(YY_SingleToothLength,YY_SingleParam->RightToothNum,1);
- YY_SingleParam->RightToothLengthINCH = YY_ToothNumCalLengthInch(YY_SingleToothLength,YY_SingleParam->RightToothNum,1);
-
- YY_SingleParam->LeftToothLengthCMSpace = YY_ToothNumCalLengthCM(YY_SingleToothLength,YY_SingleParam->LeftToothNumSpace,1);
- YY_SingleParam->LeftToothLengthINCHSpace = YY_ToothNumCalLengthInch(YY_SingleToothLength,YY_SingleParam->LeftToothNumSpace,1);
-
- YY_SingleParam->RightToothLengthCMSpace = YY_ToothNumCalLengthCM(YY_SingleToothLength,YY_SingleParam->RightToothNumSpace,1);
- YY_SingleParam->RightToothLengthINCHSpace = YY_ToothNumCalLengthInch(YY_SingleToothLength,YY_SingleParam->RightToothNumSpace,1);
-
- YY_GroupParam->AllSetLength = 0;
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->AllSetLength += YY_ToothNumCalLength(YY_SingleToothLength,(YY_GroupParam->LeftToothNum[i] + YY_GroupParam->LeftToothNumSpace[i]),YY_GroupParam->SetTotal[i]);
- }
-
- YY_SingleParam->SetLength = YY_ToothNumCalLength(YY_SingleToothLength,(YY_SingleParam->LeftToothNum + YY_SingleParam->LeftToothNumSpace),YY_SingleParam->SetTotal);
-
- YY_GroupParam->AllSetTotal = 0;
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->AllSetTotal += YY_GroupParam->SetTotal[i];
- }
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->LeftToothLengthCM[i] = YY_ToothNumCalLengthCM(YY_SingleToothLength,YY_GroupParam->LeftToothNum[i],1);
- }
-
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->LeftToothLengthCMSpace[i] = YY_ToothNumCalLengthCM(YY_SingleToothLength,YY_GroupParam->LeftToothNumSpace[i],1);
- }
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->LeftToothLengthINCH[i] = YY_ToothNumCalLengthInch(YY_SingleToothLength,YY_GroupParam->LeftToothNum[i],1);
- }
-
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->LeftToothLengthINCHSpace[i] = YY_ToothNumCalLengthInch(YY_SingleToothLength,YY_GroupParam->LeftToothNumSpace[i],1);
- }
-
- }
-
- if(YY_bCalInputLength)
- {
- YY_bCalInputLength = 0;
-
- YY_SingleParam->LeftToothLengthINCH = YY_ToothLengthCMCalInch(YY_SingleToothLength,YY_SingleParam->LeftToothLengthCM,1);
- YY_SingleParam->LeftToothNum = YY_ToothLengthCMCalNum(YY_SingleToothLength,YY_SingleParam->LeftToothLengthCM,1);
-
- YY_SingleParam->RightToothLengthINCH = YY_ToothLengthCMCalInch(YY_SingleToothLength,YY_SingleParam->RightToothLengthCM,1);
- YY_SingleParam->RightToothNum = YY_ToothLengthCMCalNum(YY_SingleToothLength,YY_SingleParam->RightToothLengthCM,1);
- YY_SingleParam->LeftToothLengthINCHSpace = YY_ToothLengthCMCalInch(YY_SingleToothLength,YY_SingleParam->LeftToothLengthCMSpace,1);
- YY_SingleParam->LeftToothNumSpace = YY_ToothLengthCMCalNum(YY_SingleToothLength,YY_SingleParam->LeftToothLengthCMSpace,1);
-
- YY_SingleParam->RightToothLengthINCHSpace = YY_ToothLengthCMCalInch(YY_SingleToothLength,YY_SingleParam->RightToothLengthCMSpace,1);
- YY_SingleParam->RightToothNumSpace = YY_ToothLengthCMCalNum(YY_SingleToothLength,YY_SingleParam->RightToothLengthCMSpace,1);
-
-
- YY_GroupParam->AllSetLength = 0;
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->AllSetLength += YY_LengthCalLengthM(YY_GroupParam->LeftToothLengthCM[i],YY_GroupParam->LeftToothLengthCMSpace[i],YY_GroupParam->SetTotal[i]);
- }
-
- YY_SingleParam->SetLength = YY_ToothNumCalLength(YY_SingleToothLength,(YY_SingleParam->LeftToothNum + YY_SingleParam->LeftToothNumSpace),YY_SingleParam->SetTotal);
-
- YY_GroupParam->AllSetTotal = 0;
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->AllSetTotal += YY_GroupParam->SetTotal[i];
- }
-
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->LeftToothNum[i] = YY_ToothLengthCMCalNum(YY_SingleToothLength,YY_GroupParam->LeftToothLengthCM[i],1);
- }
-
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->LeftToothNumSpace[i] = YY_ToothLengthCMCalNum(YY_SingleToothLength,YY_GroupParam->LeftToothLengthCMSpace[i],1);
- }
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->LeftToothLengthINCH[i] = YY_ToothLengthCMCalInch(YY_SingleToothLength,YY_GroupParam->LeftToothLengthCMSpace[i],1);
- }
-
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->LeftToothLengthINCHSpace[i] = YY_ToothLengthCMCalInch(YY_SingleToothLength,YY_GroupParam->LeftToothLengthCMSpace[i],1);
- }
-
- YY_bCalInputToothNum = 1;
- }
-
- if(YY_bCalInputLengthInch)
- {
- YY_bCalInputLengthInch = 0;
-
- YY_SingleParam->LeftToothLengthCM = YY_ToothLengthInchCalCM(YY_SingleToothLength,YY_SingleParam->LeftToothLengthINCH,1);
- YY_SingleParam->LeftToothNum = YY_ToothLengthInchCalNum(YY_SingleToothLength,YY_SingleParam->LeftToothLengthINCH,1);
-
- YY_SingleParam->RightToothLengthCM = YY_ToothLengthInchCalCM(YY_SingleToothLength,YY_SingleParam->RightToothLengthINCH,1);
- YY_SingleParam->RightToothNum = YY_ToothLengthInchCalNum(YY_SingleToothLength,YY_SingleParam->RightToothLengthINCH,1);
-
- YY_SingleParam->LeftToothLengthCMSpace = YY_ToothLengthInchCalCM(YY_SingleToothLength,YY_SingleParam->LeftToothLengthINCHSpace,1);
- YY_SingleParam->LeftToothNumSpace = YY_ToothLengthInchCalNum(YY_SingleToothLength,YY_SingleParam->LeftToothLengthINCHSpace,1);
-
- YY_SingleParam->RightToothLengthCMSpace = YY_ToothLengthInchCalCM(YY_SingleToothLength,YY_SingleParam->RightToothLengthINCHSpace,1);
- YY_SingleParam->RightToothNumSpace = YY_ToothLengthInchCalNum(YY_SingleToothLength,YY_SingleParam->RightToothLengthINCHSpace,1);
-
- YY_GroupParam->AllSetLength = 0;
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->AllSetLength += YY_InchLengthCalLength(YY_GroupParam->LeftToothLengthINCH[i],YY_GroupParam->LeftToothLengthINCHSpace[i],YY_GroupParam->SetTotal[i]);
- }
-
- YY_SingleParam->SetLength = YY_ToothNumCalLength(YY_SingleToothLength,(YY_SingleParam->LeftToothNum + YY_SingleParam->LeftToothNumSpace),YY_SingleParam->SetTotal);
-
- YY_GroupParam->AllSetTotal = 0;
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->AllSetTotal += YY_GroupParam->SetTotal[i];
- }
-
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->LeftToothNum[i] = YY_ToothLengthInchCalNum(YY_SingleToothLength,YY_GroupParam->LeftToothLengthINCH[i],1);
- }
-
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->LeftToothNumSpace[i] = YY_ToothLengthInchCalNum(YY_SingleToothLength,YY_GroupParam->LeftToothLengthINCHSpace[i],1);
- }
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->LeftToothLengthCM[i] = YY_ToothLengthInchCalCM(YY_SingleToothLength,YY_GroupParam->LeftToothLengthINCH[i],1);
- }
-
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->LeftToothLengthCMSpace[i] = YY_ToothLengthInchCalCM(YY_SingleToothLength,YY_GroupParam->LeftToothLengthINCHSpace[i],1);
- }
-
- YY_bCalInputToothNum = 1;
- }
-
- if(YY_bCalculateTotal) //下一程序周期计算长度的时间
- {
- YY_bCalculateTotal = 0; // 清通知位
-
- total_buff = 0;
-
- for(i = 0;i < 5;i++)
- {
- total_buff += YY_GroupParam->SetTotal[i];
- }
-
- if(YY_GroupParam->AllSetTotal > total_buff)YY_GroupParam->AllSetTotal = total_buff;
-
- YY_cTotal_Time();
- }
-
- if(YY_bCalAllLength)
- {
- YY_bCalAllLength = 0;
-
- YY_GroupParam->AllSetLength = 0;
- for(i = 0;i < 5;i++)
- {
- YY_GroupParam->AllSetLength += YY_ToothNumCalLength(YY_SingleToothLength,(YY_GroupParam->LeftToothNum[i] + YY_GroupParam->LeftToothNumSpace[i]),YY_GroupParam->SetTotal[i]);
- }
-
- YY_SingleParam->SetLength = YY_ToothNumCalLength(YY_SingleToothLength,(YY_SingleParam->LeftToothNum + YY_SingleParam->LeftToothNumSpace),YY_SingleParam->SetTotal);
- }
-
- if(YY_bClear1)
- {
- YY_bClear1 = 0;
- YY_GroupParam->OverSetTotal[0] = 0;
- YY_GroupParam->DisplyLeftToothLengthCM[0] = 0;
- YY_GroupParam->DisplyLeftToothLengthCMSpace[0] = 0;
- YY_GroupParam->DisplyLeftToothLengthINCHSpace[0] = 0;
- YY_GroupParam->DisplyLeftToothLengthINCH[0] = 0;
-
- YY_GroupParam->DisplyRightToothNum[0] = 0;
- YY_GroupParam->DisplyRightToothNumSpace[0] = 0;
- }
- if(YY_bClear2)
- {
- YY_bClear2 = 0;
- YY_GroupParam->OverSetTotal[1] = 0;
- YY_GroupParam->DisplyLeftToothLengthCM[1] = 0;
- YY_GroupParam->DisplyLeftToothLengthCMSpace[1] = 0;
- YY_GroupParam->DisplyLeftToothLengthINCHSpace[1] = 0;
- YY_GroupParam->DisplyLeftToothLengthINCH[1] = 0;
-
- YY_GroupParam->DisplyRightToothNum[1] = 0;
- YY_GroupParam->DisplyRightToothNumSpace[1] = 0;
- }
-
- if(YY_bClear3)
- {
- YY_bClear3 = 0;
- YY_GroupParam->OverSetTotal[2] = 0;
- YY_GroupParam->DisplyLeftToothLengthCM[2] = 0;
- YY_GroupParam->DisplyLeftToothLengthCMSpace[2] = 0;
- YY_GroupParam->DisplyLeftToothLengthINCHSpace[2] = 0;
- YY_GroupParam->DisplyLeftToothLengthINCH[2] = 0;
-
- YY_GroupParam->DisplyRightToothNum[2] = 0;
- YY_GroupParam->DisplyRightToothNumSpace[2] = 0;
- }
- if(YY_bClear4)
- {
- YY_bClear4 = 0;
- YY_GroupParam->OverSetTotal[3] = 0;
- YY_GroupParam->DisplyLeftToothLengthCM[3] = 0;
- YY_GroupParam->DisplyLeftToothLengthCMSpace[3] = 0;
- YY_GroupParam->DisplyLeftToothLengthINCHSpace[3] = 0;
- YY_GroupParam->DisplyLeftToothLengthINCH[3] = 0;
-
- YY_GroupParam->DisplyRightToothNum[3] = 0;
- YY_GroupParam->DisplyRightToothNumSpace[3] = 0;
- }
-
- if(YY_bClear5)
- {
- YY_bClear5 = 0;
- YY_GroupParam->OverSetTotal[4] = 0;
- YY_GroupParam->DisplyLeftToothLengthCM[4] = 0;
- YY_GroupParam->DisplyLeftToothLengthCMSpace[4] = 0;
- YY_GroupParam->DisplyLeftToothLengthINCHSpace[4] = 0;
- YY_GroupParam->DisplyLeftToothLengthINCH[4] = 0;
-
- YY_GroupParam->DisplyRightToothNum[4] = 0;
- YY_GroupParam->DisplyRightToothNumSpace[4] = 0;
- }
- }
- void YY_StartZYFirst(void)
- {
- YY_ZYBuff = YY_SystemParam->StartOilTime;
- YY_bFirstZY = 1; //M100 倒时显示
- YY_bZhuYou = 1;
- YY_ZYDelay = dwTickCount + 1000;
- YY_OIL_MOTOR = 1;
- YY_DISPLAY_STATE = 1;
- YY_OilCheckDelay = dwTickCount + 2500;
- }
- void YY_ZhuYou(void)
- {
- if(YY_OIL_MOTOR)
- {
- if((dwTickCount >= YY_ZYDelay) || (YY_bZhuYou == 0))
- {
- if(YY_bFirstZY)
- {
- YY_ZYDelay = dwTickCount + 1000;
- if(YY_SystemParam->StartOilTime)
- {
- YY_SystemParam->StartOilTime--;
- }
- if((YY_SystemParam->StartOilTime == 0) || (YY_bZhuYou == 0)) //初次注油完成
- {
- YY_bFirstZY = 0; //M100
- YY_OIL_MOTOR = 0; //注油机关
- YY_SystemParam->StartOilTime = YY_ZYBuff;
- YY_ZYDelay = dwTickCount + YY_SystemParam->IntOilTime * 60 * 1000;
- YY_DISPLAY_STATE = 2; //注油完成
- }
- }
- else
- {
- YY_OIL_MOTOR = 0; //注油机关
- if(YY_bZhuYou)
- YY_ZYDelay = dwTickCount + YY_SystemParam->IntOilTime * 60 * 1000; //间隔注油时间 分钟
- else
- YY_ZYDelay = dwTickCount;
- }
- YY_bZYNow = 0; //M8 清通知位
- }
- }
- else if(YY_bZhuYou && ((dwTickCount >= YY_ZYDelay) || YY_bZYNow) && YY_EGMSTOP_IN)
- {
- //大于1小时,重新先注油
- if(((dwTickCount - YY_ZYDelay) > (3600 * 1000)) && (dwTickCount >= YY_ZYDelay))
- {
- YY_StartZYFirst();
- }
- else
- {
- YY_OIL_MOTOR = 1;
- YY_ZYDelay = dwTickCount + YY_SystemParam->OilTime * 1000; //注油时间 秒
- YY_OilCheckDelay = dwTickCount + (unsigned long)2500; //延时检测油压
- }
- YY_bZYNow = 0; //M8 清通知位
- }
- }
- //手动动作
- void YYa_ManualAction(void)
- {
- //合链机启动
- if(YY_bHL)
- {
- if(YY_HL_DW_IN)
- {
- YY_HL_MOTOR = 1;
- }
- else if(YY_HL_UP_IN)
- {
- YY_HL_MOTOR = 0;
- }
- }
- else
- {
- YY_HL_MOTOR = 0;
- }
-
- if(YY_bPYMotor)
- {
- YY_bPYMotor = 0;
-
- if(YY_MAIN_MOTOR)
- {
- if(!YY_bRunning)YY_bPYControl = 0;
- }
- else if(YY_bZhuYou && !YY_bOnceStartPower) YY_bPYControl = 1;
- }
-
- if(YY_bPYControl)
- {
- if(YY_MAIN_MOTOR == 0)
- {
- YY_CheckDelay = dwTickCount + 1000;
- YY_OIL_MOTOR = 1;
- YY_ZhuYouDelay = dwTickCount + 1000*YY_SystemParam->OilTime;
- YY_CheckDelay = dwTickCount + 2500;
- }
- YY_MAIN_MOTOR = 1;
- }
- else
- {
- if(YY_MAIN_MOTOR)
- {
- YY_CheckDelay = dwTickCount + 1000;
- }
- YY_MAIN_MOTOR = 0;
- }
-
- if(YY_bClearTotal)
- {
- YY_bClearTotal = 0;
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- YY_SystemParam->AllProductTime += YY_SingleParam->SetTimeHour;
- YY_SystemParam->AllProductTime += YY_SingleParam->SetTimeMinute/60;
- YY_SingleParam->OverTotal = 0;
- YY_SingleParam->OverLength = 0;
- YY_SingleParam->SetTimeHour = 0;
- YY_SingleParam->SetTimeMinute = 0;
- }break;
- case YY_GROUP_MODE:
- {
- YY_SystemParam->AllProductTime += YY_GroupParam->SetTimeHour;
- YY_SystemParam->AllProductTime += YY_GroupParam->SetTimeMinute/60;
- YY_GroupParam->AllOverTotal = 0;
- YY_GroupParam->AllOverLength = 0;
- YY_GroupParam->SetTimeHour = 0;
- YY_GroupParam->SetTimeMinute = 0;
- }break;
-
- }
- YY_cTotal = 0;
- }
-
- if(YY_bClearPro)
- {
- YY_bClearPro = 0;
- YY_SystemParam->AllProductTime = 0;
- YY_SystemParam->AllProductLength = 0;
- }
-
- if(!YY_bRunning)
- {
- if((YY_bChangeNextGroup) && (YY_GroupParam->DisplyLeftToothNum[YY_SystemParam->NowGroup] == 0) && (YY_GroupParam->DisplyLeftToothNumSpace[YY_SystemParam->NowGroup] == 0))
- {
- YY_bChangeNextGroup = 0;
- YY_SystemParam->NowGroup = YY_SystemParam->NextGroupBuff - 1;
- }
-
-
- if(YY_bReset)
- {
- YY_bReset = 0;
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- YY_ReSetData();
- }break;
- case YY_GROUP_MODE:
- {
- YY_ReSetData();
- }break;
- }
- }
- }
-
- //故障清除
- if(YY_bClearAlarm)
- {
- if(YY_SystemParam->AlarmCode& YY_TOOTH_NUM_ALARM) //叠牙时直接打空位
- {
- YY_ReSetData(); //6空位,6牙
- }
- YY_ALARM_LED = 0;
- YY_SystemParam->AlarmCode = 0;
- YY_bClearAlarm = 0;
- }
-
- if(YY_bSetDCTEnable)
- {
- YY_bSetDCTEnable = 0;
- if(YY_bDCTEnable)
- {
- YY_SingleParam->DisplyLeftToothNum = 0;
- YY_SingleParam->DisplyLeftToothLengthCM = 0;
- YY_SingleParam->DisplyLeftToothLengthINCH = 0;
- YY_SingleParam->DisplyLeftToothNumSpace = 0;
- YY_SingleParam->DisplyLeftToothLengthCMSpace = 0;
- YY_SingleParam->DisplyLeftToothLengthINCHSpace = 0;
- YY_SingleParam->DisplyRightToothNum = 0;
- YY_SingleParam->DisplyRightToothLengthCM = 0;
- YY_SingleParam->DisplyRightToothLengthINCH = 0;
- YY_SingleParam->DisplyRightToothNumSpace = 0;
- YY_SingleParam->DisplyRightToothLengthCMSpace = 0;
- YY_SingleParam->DisplyRightToothLengthINCHSpace = 0;
- YY_cStartPYFlag_Left = 1;
- YY_cStartPYFlag_Right = 1;
- }
- else
- {
- YY_cStartPYFlag_Left = 0;
- YY_cStartPYFlag_Right = 0;
- YY_SingleParam->DisplyLeftToothNum = 0;
- YY_SingleParam->DisplyLeftToothLengthCM = 0;
- YY_SingleParam->DisplyLeftToothLengthINCH = 0;
- YY_SingleParam->DisplyLeftToothNumSpace = 0;
- YY_SingleParam->DisplyLeftToothLengthCMSpace = 0;
- YY_SingleParam->DisplyLeftToothLengthINCHSpace = 0;
- YY_SingleParam->DisplyRightToothNum = 0;
- YY_SingleParam->DisplyRightToothLengthCM = 0;
- YY_SingleParam->DisplyRightToothLengthINCH = 0;
- YY_SingleParam->DisplyRightToothNumSpace = 0;
- YY_SingleParam->DisplyRightToothLengthCMSpace = 0;
- YY_SingleParam->DisplyRightToothLengthINCHSpace = 0;
- YY_SetLeftDCTSpace();
- YY_SetRightDCTSpace();
- }
- }
-
- YY_CalculataParam();
- }
- //拉链接头控制处理
- void YY_JieTouControl(void)
- {
- //接头检测
- if(YY_JT_IN_UP) //空位
- {
- YY_cJieDaiTotal = YY_SystemParam->JieTouMJToothNum;
- YY_cJieDaiClrTotal = 0;
- YY_cJieDaiState = 1;
- }
- else if(YY_JT_IN_DW)
- {
- YY_cJieDaiState = 2;
- if(YY_cJieDaiTotal == 0)
- {
- YY_cJieDaiTotal = YY_SystemParam->JieTouMJToothNum;
- }
- else
- {
- }
- }
- }
- void YY_CountYaError(void)
- {
- unsigned short i;
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- //数牙出错
- /* if(UserParam->LeftOverToothNum || UserParam->RightOverToothNum)
- {
- if(UserParam->LeftOverToothNum >= UserParam->RightOverToothNum)
- {
- i = UserParam->LeftOverToothNum - UserParam->RightOverToothNum;
- }
- else
- i = UserParam->RightOverToothNum - UserParam->LeftOverToothNum;
- // 正常打牙状态
- if((i > 2) && (((i < (UserParam->LeftSetNum-1)) && (cStartPYFlag_Right == 0))
- // 复位打牙状态
- ||(cStartPYFlag_Right && (i < 5))))
-
- {
- M88 = 1; //M88 数牙出错
- ALARM_CODE = 88;
-
- if(Y017 == 0)Y16 = 1;
-
- }
- }
- else if((UserParam->LeftOverKongWei || UserParam->RightOverKongWei) && UserParam->LeftSetKongWei)
- {
- if(UserParam->LeftOverKongWei >= UserParam->RightOverKongWei)
- {
- i = UserParam->LeftOverKongWei - UserParam->RightOverKongWei;
- }
- else
- i = UserParam->RightOverKongWei - UserParam->LeftOverKongWei;
- if((i > 2) && (i != UserParam->LeftSetKongWei))
- {
- M88 = 1; //M88 数牙出错
- ALARM_CODE = 88;
- if(Y16 == 0)Y017 = 1;
-
- }
- } */
- }break;
- case YY_GROUP_MODE:
- {
- //数牙出错
- if(YY_GroupParam->DisplyLeftToothNum[YY_SystemParam->NowGroup] || YY_GroupParam->DisplyRightToothNum[YY_SystemParam->NowGroup])
- {
- if(YY_GroupParam->DisplyLeftToothNum[YY_SystemParam->NowGroup] >= YY_GroupParam->DisplyRightToothNum[YY_SystemParam->NowGroup])
- {
- i = YY_GroupParam->DisplyLeftToothNum[YY_SystemParam->NowGroup] - YY_GroupParam->DisplyRightToothNum[YY_SystemParam->NowGroup];
- }
- else
- i = YY_GroupParam->DisplyRightToothNum[YY_SystemParam->NowGroup] - YY_GroupParam->DisplyLeftToothNum[YY_SystemParam->NowGroup];
- // 正常打牙状态
- if((i > 2) && (((i < (YY_GroupParam->LeftToothNum[YY_SystemParam->NowGroup]-1)) && (YY_cStartPYFlag_Right == 0))
- // 复位打牙状态
- ||(YY_cStartPYFlag_Right && (i < 5))))
- {
-
- YYa_SetAlarmCode(YY_TOOTH_NUM_ALARM);
- if(Y017 == 0)Y16 = 1;
-
- }
- }
- else if((YY_GroupParam->DisplyLeftToothNumSpace[YY_SystemParam->NowGroup] || YY_GroupParam->DisplyRightToothNumSpace[YY_SystemParam->NowGroup]) && YY_GroupParam->LeftToothNumSpace[YY_SystemParam->NowGroup])
- {
- if(YY_GroupParam->DisplyLeftToothNumSpace[YY_SystemParam->NowGroup] >= YY_GroupParam->DisplyRightToothNumSpace[YY_SystemParam->NowGroup])
- {
- i = YY_GroupParam->DisplyLeftToothNumSpace[YY_SystemParam->NowGroup] - YY_GroupParam->DisplyRightToothNumSpace[YY_SystemParam->NowGroup];
- }
- else
- i = YY_GroupParam->DisplyRightToothNumSpace[YY_SystemParam->NowGroup] - YY_GroupParam->DisplyLeftToothNumSpace[YY_SystemParam->NowGroup];
- if((i > 2) && (i != YY_GroupParam->LeftToothNumSpace[YY_SystemParam->NowGroup]))
- {
- YYa_SetAlarmCode(YY_TOOTH_NUM_ALARM);
- if(Y16 == 0)Y017 = 1;
-
- }
- }
- }break;
- }
- }
- void YY_RefreshLengthInch(void)
- {
- unsigned char i;
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- YY_SingleParam->DisplyLeftToothLengthCM = YY_ToothNumCalLengthCM(YY_SingleToothLength,YY_SingleParam->DisplyLeftToothNum,1);
- YY_SingleParam->DisplyLeftToothLengthCMSpace = YY_ToothNumCalLengthCM(YY_SingleToothLength,YY_SingleParam->DisplyLeftToothNumSpace,1);
- YY_SingleParam->DisplyRightToothLengthCM = YY_ToothNumCalLengthCM(YY_SingleToothLength,YY_SingleParam->DisplyRightToothNum,1);
- YY_SingleParam->DisplyRightToothLengthCMSpace = YY_ToothNumCalLengthCM(YY_SingleToothLength,YY_SingleParam->DisplyRightToothNumSpace,1);
- YY_SingleParam->DisplyLeftToothLengthINCH = YY_ToothNumCalLengthInch(YY_SingleToothLength,YY_SingleParam->DisplyLeftToothNum,1);
- YY_SingleParam->DisplyLeftToothLengthINCHSpace = YY_ToothNumCalLengthInch(YY_SingleToothLength,YY_SingleParam->DisplyLeftToothNumSpace,1);
- YY_SingleParam->DisplyRightToothLengthINCH = YY_ToothNumCalLengthInch(YY_SingleToothLength,YY_SingleParam->DisplyRightToothNum,1);
- YY_SingleParam->DisplyRightToothLengthINCHSpace = YY_ToothNumCalLengthInch(YY_SingleToothLength,YY_SingleParam->DisplyRightToothNumSpace,1);
- }break;
- case YY_GROUP_MODE:
- {
- for(i=0;i < 5;i++)
- {
- YY_GroupParam->DisplyLeftToothLengthCM[i] = YY_ToothNumCalLengthCM(YY_SingleToothLength,YY_GroupParam->DisplyLeftToothNum[i],1);
- YY_GroupParam->DisplyLeftToothLengthCMSpace[i] = YY_ToothNumCalLengthCM(YY_SingleToothLength,YY_GroupParam->DisplyLeftToothNumSpace[i],1);
- YY_GroupParam->DisplyLeftToothLengthINCH[i]= YY_ToothNumCalLengthInch(YY_SingleToothLength,YY_GroupParam->DisplyLeftToothNum[i],1);
- YY_GroupParam->DisplyLeftToothLengthINCHSpace[i] = YY_ToothNumCalLengthInch(YY_SingleToothLength,YY_GroupParam->DisplyLeftToothNumSpace[i],1);
- }
- }break;
- }
- }
- void YY_ReFreshRemainLife(void)
- {
- unsigned char i;
-
- for(i=0;i<16;i++)
- {
- YY_ComponentParam->RemainLife[i] = YY_ComponentParam->LeftRightLife[i] - YY_ComponentParam->LeftRightUsedLife[i];
- }
- }
- void YY_DisplayStateRefresh(void)
- {
- unsigned char i;
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
-
- }break;
- case YY_GROUP_MODE:
- {
- if(YY_bRunning)
- {
- for(i=0;i<5;i++)
- {
- if(i==YY_SystemParam->NowGroup)YY_SystemParam->TotalDisplayState[i] = 1;
- else
- {
- if(YY_GroupParam->OverSetTotal[i] < YY_GroupParam->SetTotal[i])
- {
- YY_SystemParam->TotalDisplayState[i] = 0;//待加工组
- }
- else
- {
- YY_SystemParam->TotalDisplayState[i] = 2;//已完成组
- }
- }
- }
- }
- else
- {
- for(i=0;i<5;i++)
- {
- if(i==(YY_SystemParam->NextGroupBuff - 1))YY_SystemParam->TotalDisplayState[i] = 1;
- else
- {
- if(YY_GroupParam->OverSetTotal[i] < YY_GroupParam->SetTotal[i])
- {
- YY_SystemParam->TotalDisplayState[i] = 0;//待加工组
- }
- else
- {
- YY_SystemParam->TotalDisplayState[i] = 2;//已完成组
- }
- }
- }
- }
- }break;
- }
- }
- //错误停机
- void YY_Error_Action(void)
- {
- static unsigned long tx_cnt = 0;
- if(YY_EGMSTOP_IN == 0) //紧急停止
- {
- YYa_SetAlarmCode(YY_EGM_ALARM);
- }
-
- if(dwTickCount >= YY_ErrorDelay)
- {
- if(YY_YW_IN) //液位警告
- {
- YYa_SetAlarmCode(YY_OIL_VOLUME_ALARM);
- }
- if(YY_TX_IN) //铜线故障
- {
- tx_cnt++;
- if(tx_cnt > 1000)
- {
- YYa_SetAlarmCode(YY_TONG_XIAN_ALARM);
- }
- }
- else
- tx_cnt = 0;
- if(YY_CX_IN && YY_MAIN_MOTOR) //叠牙
- {
- YYa_SetAlarmCode(YY_CHENG_XING_ALARM);
- }
- if(YY_KD_IN) //卡带故障(布带1)
- {
- YYa_SetAlarmCode(YY_KA_DAI_ALARM);
- }
- if(YY_ZIPPER_IN) //没带故障(布带2)
- {
- YYa_SetAlarmCode(YY_QUE_DAI_ALARM);
- }
- if(YY_HL_LIMIT_IN) //合链上限、下限位开关(合链1)
- {
- YYa_SetAlarmCode(YY_JIN_LIAN_ALARM);
- }
-
- if(dwTickCount >= YY_OilCheckDelay)
- {
- YY_OilCheckDelay= dwTickCount+ 100;
- //油压不到警告
- if(YY_OIL_MOTOR)
- {
- if(YY_YY_IN)
- {
- YYa_SetAlarmCode(YY_OIL_PRESSURE_ALARM);
- }
- }
- }
-
- YY_CountYaError();
- YY_RefreshLengthInch();
- YY_ReFreshRemainLife();
- YY_DisplayStateRefresh();
-
- }
- }
- void YYa_AlarmProtect(void)
- {
- YY_Error_Action();
- //旋转电磁铁动作
- if((YY_LEFT_IN || YY_LEFT_OUT) && (dwTickCount >= YY_LCntDelay)) //左边
- {
- YY_LEFT_IN = 0;
- YY_LEFT_OUT = 0;
- }
- if((YY_RIGHT_IN || YY_RIGHT_OUT) && (dwTickCount >= YY_RCntDelay)) //右边
- {
- YY_RIGHT_IN = 0;
- YY_RIGHT_OUT = 0;
- }
- }
- //检测现在加工是否会换组
- unsigned short YY_CheckHaveChangeGroup(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- return 0;
- }break;
- case YY_GROUP_MODE:
- {
- if(YY_GroupParam->OverSetTotal[YY_SystemParam->NowGroup] == (YY_GroupParam->SetTotal[YY_SystemParam->NowGroup] - 1))
- return 1;
- else
- return 0;
- }break;
- default:return 0;
- }
- }
- //检测剩余齿数够不够完成拉链
- unsigned short YY_CheckRemainToothOk(void)
- {
- unsigned short toothbuff1,toothbuff2;
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- if(((YY_SingleParam->LeftToothNum+YY_SingleParam->LeftToothNumSpace) - (YY_SingleParam->DisplyLeftToothNum+YY_SingleParam->DisplyLeftToothNumSpace)) <= YY_cJieDaiTotal)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }break;
- case YY_GROUP_MODE:
- {
- toothbuff1 = YY_GroupParam->LeftToothNum[YY_SystemParam->NowGroup] + YY_GroupParam->LeftToothNumSpace[YY_SystemParam->NowGroup];
- toothbuff2 = YY_GroupParam->DisplyLeftToothNum[YY_SystemParam->NowGroup] + YY_GroupParam->DisplyLeftToothNumSpace[YY_SystemParam->NowGroup];
- if(YY_CheckHaveChangeGroup())
- {
- if((toothbuff1 - toothbuff2 + YY_SystemParam->DifferentLengthToothNum) <= YY_cJieDaiTotal)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else
- {
- if((toothbuff1 - toothbuff2) <= YY_cJieDaiTotal)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- }break;
- default:return 0;
- }
- }
- unsigned short YY_FindNextUserFulGroup(unsigned short now_group)
- {
- unsigned char i;
-
- for(i=(now_group + 1);i<5;i++)
- {
- if((YY_GroupParam->OverSetTotal[i] < YY_GroupParam->SetTotal[i]) && (YY_GroupParam->SetTotal[i] != 0)) return i;
- }
-
- for(i=0;i<now_group;i++)
- {
- if((YY_GroupParam->OverSetTotal[i] < YY_GroupParam->SetTotal[i]) && (YY_GroupParam->SetTotal[i] != 0)) return i;
- }
-
- return 99;
- }
- void YY_ChangeGroupControlLeft(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- }break;
- case YY_GROUP_MODE:
- {
- if(YY_GroupParam->SetTotal[YY_SystemParam->NowGroup] != 0)
- {
- if(YY_GroupParam->OverSetTotal[YY_SystemParam->NowGroup] < YY_GroupParam->SetTotal[YY_SystemParam->NowGroup])
- {
-
- }
- else
- {
- if(YY_FindNextUserFulGroup(YY_SystemParam->NowGroup) != 99)
- {
- YY_SetLeftPyData(0,YY_SystemParam->DifferentLengthToothNum);
- YY_SetRightPyData(0,YY_SystemParam->DifferentLengthToothNum);
- YY_cStartPYFlag_Left = 1;
- YY_cStartPYFlag_Right = 1;
- YY_SystemParam->NowGroup = YY_FindNextUserFulGroup(YY_SystemParam->NowGroup);
- }
- }
- }
- }
- }
- }
- //搜索全部做完没有
- unsigned long YY_FindCanWorkNum(void)
- {
- unsigned char i;
-
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- return 1;
- }break;
- case YY_GROUP_MODE:
- {
- for(i=0;i < 5;i++)
- {
- if(YY_GroupParam->OverSetTotal[i] < YY_GroupParam->SetTotal[i])return 1;
- }
-
- return 0;
- }break;
- default:return 0;
- }
- }
- //左边排牙动作
- /*
- 当在按下复位时就先打6空位,再打6牙
- */
- void YY_Left_Action(void)
- {
- YY_DIAPLAY0 = YY_cTotal;
- YY_DIAPLAY1 = YY_GetSetTotal();
- YY_DIAPLAY2 = YY_FindCanWorkNum();
- if(YY_LEFT_COUNT_IN_UP && YY_bDCTEnable)
- {
- YY_RightCountEnable = 0;
-
- if(YY_cJieDaiState == 1)
- {
- if(YY_cJieDaiTotal)
- {
- YY_cJieDaiClrTotal++;
- }
- else
- YY_cJieDaiClrTotal = 0;
- }
- if(YY_cJieDaiTotal && YY_cJieDaiState)
- {
- YY_cJieDaiTotal--;
- if(YY_cJieDaiTotal == 0)
- {
- YY_cStartPYFlag_Left = 3;
- YY_cStartPYFlag_Right = 3;
-
- if(YY_GetLeftSpace() == 0) // 空位设定
- {
- YY_SetLeftPyData(0,YY_cJieDaiClrTotal + 10 + YY_SystemParam->JieTouToothNum);
- YY_SetRightPyData(0,YY_cJieDaiClrTotal + 10 +YY_SystemParam->JieTouToothNum);
- YY_SetLeftSpaceDisplay(0);
- YY_SetLeftDisplay(0);
- YY_SetRightSpaceDisplay(0);
- YY_SetRightDisplay(0);
- YY_cJieDaiState = 0;
- }
- else
- {
- YY_SetLeftPyData(0,YY_cJieDaiClrTotal + 6 + YY_SystemParam->JieTouToothNum);
- YY_SetRightPyData(0,YY_cJieDaiClrTotal + 6 + YY_SystemParam->JieTouToothNum);
- YY_SetLeftSpaceDisplay(0);
- YY_SetLeftDisplay(0);
- YY_SetRightSpaceDisplay(0);
- YY_SetRightDisplay(0);
- YY_cJieDaiState = 0;
- }
-
- if(YY_cJieDaiState == 2)YY_cJieDaiState = 0;
-
- if(YY_bDCTEnable)
- {
- YY_SetLeftDCTSpace();
- YY_SetRightDCTSpace();
- }
- }
- }
- if(YY_NowLeftPyKongWei)
- {
- if(YY_cStartPYFlag_Left)
- {
- YY_cStartPYFlag_Left = 0;
- //变为空位,不用铜丝
- if(YY_bDCTEnable)
- {
- YY_SetLeftDCTSpace();
- }
- }
- YY_NowLeftPyKongWei--;
-
- if(YY_NowLeftPyKongWei == 0)YY_cStartPYFlag_Left = 1;
- }
- else if(YY_NowLeftPyNum)
- {
- if(YY_cStartPYFlag_Left && (YY_cOverTotalLeftFlg == 0))
- {
- YY_cStartPYFlag_Left = 0;
-
- if(YY_bDCTEnable)
- {
- //变为打牙,
- YY_SetLeftDCTTooth();
- }
- }
- YY_NowLeftPyNum--;
-
- if(YY_NowLeftPyNum == 0)
- {
- YY_cStartPYFlag_Left = 1;
- YY_cOverTotalLeftFlg = 0;
- }
- }
- else if(YY_GetLeftToothNum() > YY_GetLeftToothNumDisplay()) //打齿状态
- {
- if(YY_cStartPYFlag_Left)
- {
- YY_cStartPYFlag_Left = 0;
-
- if(YY_bDCTEnable)
- {
- //变为打牙,
- YY_SetLeftDCTTooth();
- }
- }
-
- YY_LeftToothDisplayAdd();
-
- if(YY_cJieDaiState)
- {
- if(YY_GetLeftSpace() != 0)
- {
- if(YY_CheckRemainToothOk())
- {
- }
- else
- {
- YY_SetLeftPyData(0,YY_cJieDaiTotal);
- YY_SetLeftSpaceDisplay(0);
- YY_SetLeftDisplay(0);
-
- YY_SetRightPyData(0,YY_cJieDaiTotal);
- YY_SetRightSpaceDisplay(0);
- YY_SetRightDisplay(0);
-
- YY_cStartPYFlag_Left = 1;
- YY_cStartPYFlag_Right = 1;
- }
- }
- }
-
- if(YY_GetLeftToothNum() == YY_GetLeftToothNumDisplay()) //打完齿
- {
- YY_cStartPYFlag_Left = 1;
- YY_LeftOverSet();
- if(YY_GetLeftSpace() == 0)
- {
- if(YY_bChangeNextGroup)
- {
- YY_bChangeNextGroup = 0;
- YY_SystemParam->NowGroup = YY_SystemParam->NextGroupBuff - 1;
- YY_SetLeftPyData(0,YY_SystemParam->DifferentLengthToothNum);
- YY_SetRightPyData(0,YY_SystemParam->DifferentLengthToothNum);
- YY_cStartPYFlag_Left = 1;
- YY_cStartPYFlag_Right = 1;
- }
-
- YY_ChangeGroupControlLeft();
-
- YY_SetLeftSpaceDisplay(0);
- YY_SetLeftDisplay(0);
- }
- //按停止 或产量到
- if(YY_bSingStop || (YY_cTotal >= YY_GetSetTotal()) || (YY_FindCanWorkNum() == 0))
- {
- if(YY_GetLeftSpace() == 0)
- {
- if((YY_cTotal >= YY_GetSetTotal()) || (YY_FindCanWorkNum() == 0))
- {
- YY_SetLeftPyData(10,YY_SystemParam->DifferentLengthToothNum);
- YY_SetRightPyData(10,YY_SystemParam->DifferentLengthToothNum);
- YY_cStartPYFlag_Left = 1;
- YY_cStartPYFlag_Right = 1;
-
- YY_cOverTotalRightFlg = 1;
- YY_cOverTotalLeftFlg = 1;
- }
- }
-
- YY_Stop_Action();
- if(YY_bSingStop == 0)YY_DISPLAY_STATE = 4;
- }
- YY_LeftOk = 0;
- }
- }
- else if(YY_GetLeftSpace() > YY_GetLeftSpaceDisplay()) //空位状态
- {
- if(YY_cStartPYFlag_Left)
- {
- YY_cStartPYFlag_Left = 0;
- if(YY_bDCTEnable)
- {
- //变为空位,不用铜丝
- YY_SetLeftDCTSpace();
- }
- }
-
- YY_LeftSpaceDisplayAdd();
-
- if(YY_GetLeftSpace() == YY_GetLeftSpaceDisplay())
- {
- //只有大于一条拉链时才打牙状态
- if(YY_cJieDaiState)
- {
- if(YY_CheckRemainToothOk())
- {
- }
- else
- {
- if(YY_cJieDaiState != 0)
- {
- YY_SetLeftPyData(0,YY_cJieDaiTotal);
- YY_SetLeftSpaceDisplay(0);
- YY_SetLeftDisplay(0);
-
- YY_SetRightPyData(0,YY_cJieDaiTotal);
- YY_SetRightSpaceDisplay(0);
- YY_SetRightDisplay(0);
- }
- }
- }
-
- YY_SetLeftSpaceDisplay(0);
- YY_SetLeftDisplay(0);
- YY_cStartPYFlag_Left = 1;
- YY_LeftOk = 1;
- if(YY_ChangeNextGroupFlg && YY_RightOk)
- {
- YY_RightOk = 0;
- YY_LeftOk = 0;
- YY_ChangeNextGroupFlg = 0;
- YY_SetLeftSpaceDisplay(0);
- YY_SetLeftDisplay(0);
- if(YY_bChangeNextGroup)
- {
- YY_bChangeNextGroup = 0;
- YY_SystemParam->NowGroup = YY_SystemParam->NextGroupBuff - 1;
- YY_SetLeftPyData(0,YY_SystemParam->DifferentLengthToothNum);
- YY_SetRightPyData(0,YY_SystemParam->DifferentLengthToothNum);
- YY_cStartPYFlag_Left = 1;
- YY_cStartPYFlag_Right = 1;
- }
-
- YY_ChangeGroupControlLeft();
- }
-
-
- }
- }
-
- //如叠牙或数牙导常的情况下,不能送牙
- if((YY_SystemParam->AlarmCode == YY_CHENG_XING_ALARM) || (YY_SystemParam->AlarmCode == YY_TOOTH_NUM_ALARM) || !YY_bDCTEnable)// || M81 || M80)
- {
- YY_SetLeftDCTSpace();
- }
-
- YY_ProOnceTime = dwTickCount - YY_CalProcessDelay; //计算时间
- YY_CalProcessDelay = dwTickCount;
- }
- }
- void YY_LeftOverSet(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- //产量计数
- //当两边的齿都打完时,产量加1
- if(YY_cTatal_OK)
- {
- YY_cTatal_OK = 0;
- YY_cTotal++;
- YY_AddTotal();
- YY_CalUseLifeFlg = 1;
- YY_bCalculateTotal = 1;
- }
- else
- YY_cTatal_OK = 1;
- }break;
- case YY_GROUP_MODE:
- {
- //产量计数
- //当两边的齿都打完时,产量加1
- if(YY_cTatal_OK)
- {
- YY_cTatal_OK = 0;
- YY_cTotal++;
- YY_AddTotal();
- YY_CalUseLifeFlg = 1;
- YY_bCalculateTotal = 1;
- YY_SaveParamFlg = 1;
- YY_UseLifeNowGroup = YY_SystemParam->NowGroup;
- YY_LastGroup = YY_SystemParam->NowGroup;
- YY_ChangeNextGroupFlg = 1;
- }
- else
- {
- YY_cTatal_OK = 1;
- }
-
- }break;
- }
- }
- void YY_RightOverSet(void)
- {
- //产量计数
- //当两边的齿都打完时,产量加1
- if(YY_cTatal_OK)
- {
- YY_cTatal_OK = 0;
- YY_cTotal++;
- YY_AddTotal();
- YY_CalUseLifeFlg = 1;
- YY_bCalculateTotal = 1;
- YY_UseLifeNowGroup = YY_SystemParam->NowGroup;
- YY_LastGroup = YY_SystemParam->NowGroup;
- YY_ChangeNextGroupFlg = 1;
- }
- else
- {
- YY_cTatal_OK = 1;
- }
- }
- void YY_Right_Action(void)
- {
-
- if(YY_RIGHT_COUNT_IN_UP && (YY_RightCountEnable == 0) && YY_bDCTEnable)
- {
- if(YY_NowRightPyKongWei)
- {
- if(YY_cStartPYFlag_Right)
- {
- YY_cStartPYFlag_Right = 0;
-
- if(YY_bDCTEnable)
- {
- //变为空位,不用铜丝
- YY_SetRightDCTSpace();
- }
- }
- YY_NowRightPyKongWei--;
-
- if((YY_NowRightPyKongWei == 0))YY_cStartPYFlag_Right = 1;
- }
- else if(YY_NowRightPyNum)
- {
- if(YY_cStartPYFlag_Right && (YY_cOverTotalRightFlg == 0))
- {
- YY_cStartPYFlag_Right = 0;
- //变为打牙,
- if(YY_bDCTEnable)
- {
- YY_SetRightDCTTooth();
- }
- }
- YY_NowRightPyNum--;
- if(YY_NowRightPyNum == 0)
- {
- YY_cStartPYFlag_Right = 1;
- YY_cOverTotalRightFlg = 0;
- }
- }
- else if(YY_GetRightToothNum() > YY_GetRightToothNumDisplay()) //打齿状态
- {
- if(YY_cStartPYFlag_Right)
- {
- YY_cStartPYFlag_Right = 0;
- if(YY_bDCTEnable)
- {
- //变为打牙,
- YY_SetRightDCTTooth();
- }
- }
-
- YY_RightToothDisplayAdd();
-
- if(YY_GetRightToothNum() == YY_GetRightToothNumDisplay()) //打齿状态
- {
- YY_cStartPYFlag_Right = 1;
-
- YY_RightOverSet();
-
- if(YY_GetRightSpace() == 0)
- {
- YY_SetRightSpaceDisplay(0);
- YY_SetRightDisplay(0);
- if(YY_bChangeNextGroup)
- {
- YY_bChangeNextGroup = 0;
- YY_SystemParam->NowGroup = YY_SystemParam->NextGroupBuff - 1;
- YY_SetLeftPyData(0,YY_SystemParam->DifferentLengthToothNum);
- YY_SetRightPyData(0,YY_SystemParam->DifferentLengthToothNum);
- YY_cStartPYFlag_Left = 1;
- YY_cStartPYFlag_Right = 1;
- }
-
- YY_ChangeGroupControlLeft();
- }
- //按停止 或产量到
- if(YY_bSingStop || (YY_cTotal >= YY_GetSetTotal()) || (YY_FindCanWorkNum() == 0))
- {
- if(YY_GetLeftSpace() == 0)
- {
- if((YY_cTotal >= YY_GetSetTotal()) || (YY_FindCanWorkNum() == 0))
- {
- YY_SetLeftPyData(10,YY_SystemParam->DifferentLengthToothNum);
- YY_SetRightPyData(10,YY_SystemParam->DifferentLengthToothNum);
- YY_cStartPYFlag_Left = 1;
- YY_cStartPYFlag_Right = 1;
- YY_cOverTotalRightFlg = 1;
- YY_cOverTotalLeftFlg = 1;
- }
- }
- YY_Stop_Action();
- if(YY_bSingStop == 0)YY_DISPLAY_STATE = 4;
- }
- YY_RightOk = 0;
-
- }
- }
- else if(YY_GetRightSpace() > YY_GetRightSpaceDisplay()) //空位状态
- {
- if(YY_cStartPYFlag_Right)
- {
- YY_cStartPYFlag_Right = 0;
- if(YY_bDCTEnable)
- {
- //变为空位,不用铜丝
- YY_SetRightDCTSpace();
- }
- }
-
- YY_RightSpaceDisplayAdd();
-
- if(YY_GetRightSpace() == YY_GetRightSpaceDisplay())
- {
- YY_SetRightSpaceDisplay(0);
- YY_SetRightDisplay(0);
- YY_cStartPYFlag_Right = 1;
- YY_RightOk = 1;
- if(YY_ChangeNextGroupFlg && YY_LeftOk)
- {
- YY_ChangeNextGroupFlg = 0;
- YY_LeftOk = 0;
- YY_RightOk = 0;
- if(YY_bChangeNextGroup)
- {
- YY_bChangeNextGroup = 0;
- YY_SystemParam->NowGroup = YY_SystemParam->NextGroupBuff - 1;
- YY_SetLeftPyData(10,YY_SystemParam->DifferentLengthToothNum);
- YY_SetRightPyData(10,YY_SystemParam->DifferentLengthToothNum);
- YY_cStartPYFlag_Left = 1;
- YY_cStartPYFlag_Right = 1;
- }
-
- YY_ChangeGroupControlLeft();
- }
-
- }
-
- }
-
-
- //如叠牙的情况下,不能送牙
- if((YY_SystemParam->AlarmCode == YY_CHENG_XING_ALARM) || (YY_SystemParam->AlarmCode == YY_TOOTH_NUM_ALARM) || !YY_bDCTEnable)// || M81 || M80)
- {
- YY_SetRightDCTSpace();
- }
- }
- }
- void YYa_AutoAction(void)
- {
- YY_Left_Action();
- YY_Right_Action();
- }
- void YYa_SongLiao(void)
- {
- //送丝启动
- if(YY_bSongSi)
- {
- //左送料(送丝)
- if(YY_LEFT_SL_DW_IN)
- {
- YY_LEFT_SL_MOTOR = 1;
- }
- else if(YY_LEFT_SL_UP_IN)
- {
- YY_LEFT_SL_MOTOR = 0;
- }
- //右送料(送丝)
- if(YY_RIGHT_SL_DW_IN)
- {
- YY_RIGHT_SL_MOTOR = 1;
- }
- else if(YY_RIGHT_SL_UP_IN)
- {
- YY_RIGHT_SL_MOTOR = 0;
- }
- }
- else
- {
- YY_LEFT_SL_MOTOR = 0;
- YY_RIGHT_SL_MOTOR = 0;
- }
- }
- // 停止工作
- void YY_Stop_Action(void)
- {
- YY_bWorkState = 0; //M7 工作显示
- if((YY_EGMSTOP_IN == 0) && ((YY_SystemParam->AlarmCode & YY_TOOTH_NUM_ALARM) == 0))YY_bZhuYou = 0; // 注油控制
- YY_bHL = 0;
- YY_bSongSi = 0;
- YY_bPYControl = 0;
- YY_DISPLAY_STATE = 2;
- YY_bRunning = 0;
- YY_bSingStop = 0;
- }
- //启动时检测当前要加工的组别可不可以加工,不可以就切换到可以加工的组别
- unsigned char YY_StartCheckChoose(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- return 1;
- }break;
- case YY_GROUP_MODE:
- {
- if(YY_GroupParam->OverSetTotal[YY_SystemParam->NowGroup] < YY_GroupParam->SetTotal[YY_SystemParam->NowGroup])
- {
- return 1;
- }
- else
- {
- if(YY_FindNextUserFulGroup(YY_SystemParam->NowGroup) != 99)
- {
- if((YY_GroupParam->DisplyLeftToothNumSpace[YY_SystemParam->NowGroup] == 0) && (YY_GroupParam->DisplyRightToothNum[YY_SystemParam->NowGroup] == 0))YY_SystemParam->NowGroup = YY_FindNextUserFulGroup(YY_SystemParam->NowGroup);
-
- return 1;
- }
- else
- {
- return 0;
- }
- }
- }break;
- default:return 0;
- }
- }
- void YYa_StepCheckStart(void)
- {
- if(YY_bFirstZY == 0)//首次加油已经完成
- {
- if((YY_bStart || YY_START_IN_UP) && !YY_bRunning && YY_bZhuYou && (YY_STOP_IN == 0) && (YY_SystemParam->AlarmCode== 0) && (YY_StartCheckChoose() == 1)&& (YY_cTotal < YY_GetSetTotal()))
- {
- YY_bWorkState = 1; //M7 工作显示
- YY_bHL = 1; //M4 合链控制
- YY_bSongSi = 1; //M5 送丝控制
- YY_bPYControl = 1; //M6 排牙控制
- YY_bZYNow = 1; //M8 马上注油D2时间
- YY_DISPLAY_STATE = 3;
- YY_bRunning = 1;
- // YY_DIAPLAY1++;
- if(!YY_bDCTEnable)
- {
- YY_cStartWorkTime = 3;
- }
- }
- YY_bStart = 0; //M0
- }
- else
- {
- YY_bStart = 0; //M0
- }
-
- if((YY_cStartWorkTime != 0) && (dwTickCount >= YY_TryDelay))
- {
- YY_cStartWorkTime--;
- YY_SetLeftDCTSpace();
- YY_SetRightDCTSpace();
- YY_TryDelay = dwTickCount + 500;
- }
- //停止
- if(YY_STOP_IN || (YY_bAlarmStop == 1) || YY_bStop)
- {
- // 普通停止是打完当条再停止
- if((YY_bStop || (YY_STOP_IN)) && YY_bDCTEnable)
- {
- if(YY_bPYControl)YY_bSingStop = 1;
- }
- else //其它故障都要立即停止
- {
- if(YY_bRunning)YY_ALARM_LED = 1;
- YY_Stop_Action();
- }
- YY_bStop = 0; //M0 系统复位
- YY_bAlarmStop = 0;
- }
-
-
- }
- //零件寿命相关控制和运算
- void YYa_CalParts(void)
- {
- // AddUsedLifeControl();
- if(YY_bClearLife1)
- {
- YY_bClearLife1 = 0;
- YY_ComponentParam->LeftRightLife[0] = 0;
- YY_ComponentParam->LeftRightUsedLife[0] = 0;
-
- YY_ComponentParam->RefreshTimes[0]++;
- }
-
- if(YY_bClearTimes1)
- {
- YY_bClearTimes1 = 0;
- YY_ComponentParam->RefreshTimes[0] = 0;
- }
-
- if(YY_bClearLife2)
- {
- YY_bClearLife2 = 0;
- YY_ComponentParam->LeftRightLife[1] = 0;
- YY_ComponentParam->LeftRightUsedLife[1] = 0;
-
- YY_ComponentParam->RefreshTimes[1]++;
- }
-
- if(YY_bClearTimes2)
- {
- YY_bClearTimes2 = 0;
- YY_ComponentParam->RefreshTimes[1] = 0;
- }
-
- if(YY_bClearLife3)
- {
- YY_bClearLife3 = 0;
- YY_ComponentParam->LeftRightLife[2] = 0;
- YY_ComponentParam->LeftRightUsedLife[2] = 0;
-
- YY_ComponentParam->RefreshTimes[2]++;
- }
-
- if(YY_bClearTimes3)
- {
- YY_bClearTimes3 = 0;
- YY_ComponentParam->RefreshTimes[2] = 0;
- }
-
- if(YY_bClearLife4)
- {
- YY_bClearLife4 = 0;
- YY_ComponentParam->LeftRightLife[3] = 0;
- YY_ComponentParam->LeftRightUsedLife[3] = 0;
-
- YY_ComponentParam->RefreshTimes[3]++;
- }
-
- if(YY_bClearTimes4)
- {
- YY_bClearTimes4 = 0;
- YY_ComponentParam->RefreshTimes[3] = 0;
- }
-
- if(YY_bClearLife5)
- {
- YY_bClearLife5 = 0;
- YY_ComponentParam->LeftRightLife[4] = 0;
- YY_ComponentParam->LeftRightUsedLife[4] = 0;
-
- YY_ComponentParam->RefreshTimes[4]++;
- }
-
- if(YY_bClearTimes5)
- {
- YY_bClearTimes5 = 0;
- YY_ComponentParam->RefreshTimes[4] = 0;
- }
-
- if(YY_bClearLife6)
- {
- YY_bClearLife6 = 0;
- YY_ComponentParam->LeftRightLife[5] = 0;
- YY_ComponentParam->LeftRightUsedLife[5] = 0;
-
- YY_ComponentParam->RefreshTimes[5]++;
- }
-
- if(YY_bClearTimes6)
- {
- YY_bClearTimes6 = 0;
- YY_ComponentParam->RefreshTimes[5] = 0;
- }
-
- if(YY_bClearLife7)
- {
- YY_bClearLife7 = 0;
- YY_ComponentParam->LeftRightLife[6] = 0;
- YY_ComponentParam->LeftRightUsedLife[6] = 0;
-
- YY_ComponentParam->RefreshTimes[6]++;
- }
-
- if(YY_bClearTimes7)
- {
- YY_bClearTimes7 = 0;
- YY_ComponentParam->RefreshTimes[6] = 0;
- }
-
- if(YY_bClearLife8)
- {
- YY_bClearLife8 = 0;
- YY_ComponentParam->LeftRightLife[7] = 0;
- YY_ComponentParam->LeftRightUsedLife[7] = 0;
-
- YY_ComponentParam->RefreshTimes[7]++;
- }
-
- if(YY_bClearTimes8)
- {
- YY_bClearTimes8 = 0;
- YY_ComponentParam->RefreshTimes[7] = 0;
- }
-
- if(YY_bClearLife9)
- {
- YY_bClearLife9 = 0;
- YY_ComponentParam->LeftRightLife[8] = 0;
- YY_ComponentParam->LeftRightUsedLife[8] = 0;
-
- YY_ComponentParam->RefreshTimes[8]++;
- }
-
- if(YY_bClearTimes9)
- {
- YY_bClearTimes9 = 0;
- YY_ComponentParam->RefreshTimes[8] = 0;
- }
-
- if(YY_bClearLife10)
- {
- YY_bClearLife10 = 0;
- YY_ComponentParam->LeftRightLife[9] = 0;
- YY_ComponentParam->LeftRightUsedLife[9] = 0;
-
- YY_ComponentParam->RefreshTimes[9]++;
- }
-
- if(YY_bClearTimes10)
- {
- YY_bClearTimes10 = 0;
- YY_ComponentParam->RefreshTimes[9] = 0;
- }
-
- if(YY_bClearLife11)
- {
- YY_bClearLife11 = 0;
- YY_ComponentParam->LeftRightLife[10] = 0;
- YY_ComponentParam->LeftRightUsedLife[10] = 0;
-
- YY_ComponentParam->RefreshTimes[10]++;
- }
-
- if(YY_bClearTimes11)
- {
- YY_bClearTimes1 = 0;
- YY_ComponentParam->RefreshTimes[10] = 0;
- }
-
- if(YY_bClearLife12)
- {
- YY_bClearLife12 = 0;
- YY_ComponentParam->LeftRightLife[11] = 0;
- YY_ComponentParam->LeftRightUsedLife[11] = 0;
-
- YY_ComponentParam->RefreshTimes[11]++;
- }
-
- if(YY_bClearTimes12)
- {
- YY_bClearTimes12 = 0;
- YY_ComponentParam->RefreshTimes[11] = 0;
- }
-
- if(YY_bClearLife13)
- {
- YY_bClearLife13 = 0;
- YY_ComponentParam->LeftRightLife[12] = 0;
- YY_ComponentParam->LeftRightUsedLife[12] = 0;
-
- YY_ComponentParam->RefreshTimes[12]++;
- }
-
- if(YY_bClearTimes13)
- {
- YY_bClearTimes13 = 0;
- YY_ComponentParam->RefreshTimes[12] = 0;
- }
-
- if(YY_bClearLife14)
- {
- YY_bClearLife14 = 0;
- YY_ComponentParam->LeftRightLife[13] = 0;
- YY_ComponentParam->LeftRightUsedLife[13] = 0;
-
- YY_ComponentParam->RefreshTimes[13]++;
- }
-
- if(YY_bClearTimes14)
- {
- YY_bClearTimes14 = 0;
- YY_ComponentParam->RefreshTimes[13] = 0;
- }
-
- if(YY_bClearLife15)
- {
- YY_bClearLife15 = 0;
- YY_ComponentParam->LeftRightLife[14] = 0;
- YY_ComponentParam->LeftRightUsedLife[14] = 0;
-
- YY_ComponentParam->RefreshTimes[14]++;
- }
-
- if(YY_bClearTimes15)
- {
- YY_bClearTimes15 = 0;
- YY_ComponentParam->RefreshTimes[14] = 0;
- }
-
- if(YY_bClearLife16)
- {
- YY_bClearLife16 = 0;
- YY_ComponentParam->LeftRightLife[15] = 0;
- YY_ComponentParam->LeftRightUsedLife[15] = 0;
-
- YY_ComponentParam->RefreshTimes[15]++;
- }
-
- if(YY_bClearTimes16)
- {
- YY_bClearTimes16 = 0;
- YY_ComponentParam->RefreshTimes[15] = 0;
- }
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////
- void YY_LeftToothDisplayAdd(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:YY_SingleParam->DisplyLeftToothNum++;break;
- case YY_GROUP_MODE:YY_GroupParam->DisplyLeftToothNum[YY_SystemParam->NowGroup]++;break;
- }
- }
- void YY_RightToothDisplayAdd(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:YY_SingleParam->DisplyRightToothNum++;break;
- case YY_GROUP_MODE:YY_GroupParam->DisplyRightToothNum[YY_SystemParam->NowGroup]++;break;
- }
- }
- void YY_LeftSpaceDisplayAdd(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:YY_SingleParam->DisplyLeftToothNumSpace++;break;
- case YY_GROUP_MODE:YY_GroupParam->DisplyLeftToothNumSpace[YY_SystemParam->NowGroup]++;break;
- }
- }
- void YY_RightSpaceDisplayAdd(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:YY_SingleParam->DisplyRightToothNumSpace++;break;
- case YY_GROUP_MODE:YY_GroupParam->DisplyRightToothNumSpace[YY_SystemParam->NowGroup]++;break;
- }
- }
- unsigned long YY_GetLeftToothNum(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- return YY_SingleParam->LeftToothNum;
- }break;
- case YY_GROUP_MODE:
- {
- return YY_GroupParam->LeftToothNum[YY_SystemParam->NowGroup];
- }break;
- default:return 0;
- }
- }
- unsigned long YY_GetRightToothNum(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- return YY_SingleParam->RightToothNum;
- }break;
- case YY_GROUP_MODE:
- {
- return YY_GroupParam->LeftToothNum[YY_SystemParam->NowGroup];
- }break;
- default:return 0;
- }
- }
- unsigned long YY_GetLeftToothNumDisplay(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- return YY_SingleParam->DisplyLeftToothNum;
- }break;
- case YY_GROUP_MODE:
- {
- return YY_GroupParam->DisplyLeftToothNum[YY_SystemParam->NowGroup];
- }break;
- default:return 0;
- }
- }
- unsigned long YY_GetRightToothNumDisplay(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- return YY_SingleParam->DisplyRightToothNum;
- }break;
- case YY_GROUP_MODE:
- {
- return YY_GroupParam->DisplyRightToothNum[YY_SystemParam->NowGroup];
- }break;
- default:return 0;
- }
- }
- unsigned long YY_GetLeftSpace(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- return YY_SingleParam->LeftToothNumSpace;
- }break;
- case YY_GROUP_MODE:
- {
- return YY_GroupParam->LeftToothNumSpace[YY_SystemParam->NowGroup];
- }break;
- default:return 0;
- }
- }
- unsigned long YY_GetRightSpace(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- return YY_SingleParam->RightToothNumSpace;
- }break;
- case YY_GROUP_MODE:
- {
- return YY_GroupParam->LeftToothNumSpace[YY_SystemParam->NowGroup];
- }break;
- default:return 0;
- }
- }
- unsigned long YY_GetLeftSpaceDisplay(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- return YY_SingleParam->DisplyLeftToothNumSpace;
- }break;
- case YY_GROUP_MODE:
- {
- return YY_GroupParam->DisplyLeftToothNumSpace[YY_SystemParam->NowGroup];
- }break;
- default:return 0;
- }
- }
- unsigned long YY_GetRightSpaceDisplay(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- return YY_SingleParam->DisplyRightToothNumSpace;
- }break;
- case YY_GROUP_MODE:
- {
- return YY_GroupParam->DisplyRightToothNumSpace[YY_SystemParam->NowGroup];
- }break;
- default:return 0;
- }
- }
- void YY_SetLeftDCTSpace(void)
- {
- //变为空位,不用铜丝
- YY_LEFT_OUT = 0;
- YY_LEFT_IN = 1;
- YY_LCntDelay = dwTickCount + YY_DCT_OUT_TIME;
- }
- void YY_SetLeftDCTTooth(void)
- {
- //变为排牙
- YY_LEFT_OUT = 1;
- YY_LEFT_IN = 0;
- YY_LCntDelay = dwTickCount + YY_DCT_OUT_TIME;
- }
- void YY_SetRightDCTSpace(void)
- {
- //变为空位,不用铜丝
- YY_RIGHT_OUT = 0;
- YY_RIGHT_IN = 1;
- YY_RCntDelay = dwTickCount + YY_DCT_OUT_TIME;
- }
- void YY_SetRightDCTTooth(void)
- {
- //变为排牙
- YY_RIGHT_OUT = 1;
- YY_RIGHT_IN = 0;
- YY_RCntDelay = dwTickCount + YY_DCT_OUT_TIME;
- }
- void YY_SetLeftPyData(unsigned short cLeftData,unsigned short cLeftKongWei)
- {
- YY_NowLeftPyKongWei = cLeftKongWei;
- YY_NowLeftPyNum = cLeftData;
- }
- void YY_SetRightPyData(unsigned short cRightData,unsigned short cRightKongWei)
- {
- YY_NowRightPyKongWei = cRightKongWei;
- YY_NowRightPyNum = cRightData;
- }
- void YY_SetLeftDisplay(unsigned short source_data)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- YY_SingleParam->DisplyLeftToothNum = source_data;
- }break;
- case YY_GROUP_MODE:
- {
- YY_GroupParam->DisplyLeftToothNum[YY_SystemParam->NowGroup] = source_data;
- }break;
- }
- }
- void YY_SetRightDisplay(unsigned short source_data)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- YY_SingleParam->DisplyRightToothNum = source_data;
- }break;
- case YY_GROUP_MODE:
- {
- YY_GroupParam->DisplyRightToothNum[YY_SystemParam->NowGroup] = source_data;
- }break;
- }
- }
- void YY_SetLeftSpaceDisplay(unsigned short source_data)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- YY_SingleParam->DisplyLeftToothNumSpace = source_data;
- }break;
- case YY_GROUP_MODE:
- {
- YY_GroupParam->DisplyLeftToothNumSpace[YY_SystemParam->NowGroup] = source_data;
- }break;
- }
- }
- void YY_SetRightSpaceDisplay(unsigned short source_data)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- YY_SingleParam->DisplyRightToothNumSpace = source_data;
- }break;
- case YY_GROUP_MODE:
- {
- YY_GroupParam->DisplyRightToothNumSpace[YY_SystemParam->NowGroup] = source_data;
- }break;
- }
- }
- unsigned long YY_GetTotal(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- return YY_SingleParam->OverTotal;
- }break;
- case YY_GROUP_MODE:
- {
- return YY_GroupParam->AllOverTotal;
- }break;
- default:return 0;
- }
- }
- unsigned long YY_GetSetTotal(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:return YY_SingleParam->SetTotal;break;
- case YY_GROUP_MODE:return YY_GroupParam->AllSetTotal;break;
- default:return 0;
- }
- }
- void YY_AddTotal(void)
- {
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:YY_SingleParam->OverTotal++;break;
- case YY_GROUP_MODE:
- {
- YY_GroupParam->AllOverTotal++;
- YY_GroupParam->OverSetTotal[YY_SystemParam->NowGroup]++;
- }break;
- }
- }
- //算单个齿长度
- float YY_CalToothLength(unsigned short roll_diameter,unsigned short tooth_num)
- {
- float buff,buff_num;
-
- buff = roll_diameter;
- buff_num = tooth_num;
- return (buff * 3.1415926 / buff_num);
- }
- //输入齿数计算长度返回的是单位厘米
- unsigned long YY_ToothNumCalLengthCM(float single_length,unsigned short tooth_num,unsigned long zipper_num)
- {
- float buff1,buff2,buff3;
- buff1 = single_length;
- buff2 = tooth_num;
- buff3 = zipper_num;
- return (unsigned long)(buff1 * buff2 * buff3);
- }
- //输入齿数计算长度返回的是单位英寸
- unsigned long YY_ToothNumCalLengthInch(float single_length,unsigned short tooth_num,unsigned long zipper_num)
- {
- float buff1,buff2,buff3;
- buff1 = single_length;
- buff2 = tooth_num;
- buff3 = zipper_num;
- return (unsigned long)(buff1 * buff2 * buff3 / 2.5399);
- }
- //输入长度厘米算齿数
- unsigned long YY_ToothLengthCMCalNum(float single_length,unsigned short tooth_length,unsigned long zipper_num)
- {
- float buff1,buff2,buff3;
- buff1 = zipper_num;
- buff2 = tooth_length;
- buff3 = single_length;
- return (unsigned long)ceil(buff1 * buff2 / buff3);
- }
- //输入长度厘米算英寸
- unsigned long YY_ToothLengthCMCalInch(float single_length,unsigned short tooth_length,unsigned long zipper_num)
- {
- float buff1,buff2;
- buff1 = tooth_length;
- buff2 = zipper_num;
- return (unsigned long)(buff1 * buff2 / 2.5399);
- }
- //输入厘米长度计算总长度单位米
- unsigned long YY_LengthCalLengthM(unsigned short set_length,unsigned short kongwei_length,unsigned long zipper_num)
- {
- float buff1,buff2,buff3;
-
- buff1 = set_length;
- buff2 = kongwei_length;
- buff3 = zipper_num;
- return (unsigned long)((buff1 + buff2) * buff3 / 100);
- }
- //输入英寸长度计算总长度
- unsigned long YY_InchLengthCalLength(unsigned short set_length,unsigned short kongwei_length,unsigned long zipper_num)
- {
- float buff1,buff2,buff3;
-
- buff1 = set_length;
- buff2 = kongwei_length;
- buff3 = zipper_num;
- return (unsigned long)((buff1 + buff2) * buff3 / 2.5399);
- }
- //输入齿数计算长度返回的是单位米
- unsigned long YY_ToothNumCalLength(float single_length,unsigned short tooth_num,unsigned long zipper_num)
- {
- float buff1,buff2,buff3;
-
- buff1 = single_length;
- buff2 = tooth_num;
- buff3 = zipper_num;
- return (unsigned long)(buff1 * buff2 * buff3 / 1000);
- }
- //输入齿数计算长度返回的是单位米带浮点型
- float YY_ToothNumCalLengthFloat(float single_length,unsigned short tooth_num,unsigned long zipper_num)
- {
- float buff1,buff2,buff3;
-
- buff1 = single_length;
- buff2 = tooth_num;
- buff3 = zipper_num;
- return (buff1 * buff2 * buff3 / 1000);
- }
- //输入长度英寸算齿数
- unsigned long YY_ToothLengthInchCalNum(float single_length,unsigned short tooth_length,unsigned long zipper_num)
- {
- float buff1,buff2;
- buff1 = zipper_num * tooth_length;
- buff2 = single_length;
- return (unsigned long)ceil(buff1 * 2.5399 / buff2);
- }
- //输入长度英寸算厘米
- unsigned long YY_ToothLengthInchCalCM(float single_length,unsigned short tooth_length,unsigned long zipper_num)
- {
- float buff1,buff2;
- buff1 = tooth_length;
- buff2 = zipper_num;
- return (unsigned long)(buff1 * buff2 * 2.5399);
- }
- #endif
|