123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477 |
- #include "global.h"
- #if TONG_YONG_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);
- YY_SingleParam_str *YY_SingleParam;
- YY_GroupParam_str *YY_GroupParam;
- YY_SystemParam_str *YY_SystemParam;
- YY_ComponentParam_str *YY_ComponentParam;
- void YYa_ExtiActionX31(void)
- {
- }
- void YYa_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(YY_ALARM_ADDR,alarm_code);
- bAlarmStop = 1;
- }
- void YYa_SetLifeAlarmCode(unsigned alarm_code)
- {
- YY_ComponentParam->LifeAlarm |= 0x0001 << alarm_code;
- }
- void YYa_InitAction(void)
- {
- 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];
- }
- void YYa_Action(void)
- {
- YYa_AlarmProtect();
- YYa_ManualAction();
- YYa_AutoAction();
- YYa_SongLiao();
- YYa_StepCheckStart(); // 调用脚踏开关检测程序
- }
- //手动动作
- void YYa_ManualAction(void)
- {
- //合链机启动
- if(YY_bHL)
- {
- if(YY_HL_DW_IN)
- {
- YY_YL_MOTOR = 1;
- YY_HL_MOTOR = 1;
- }
- else if(YY_HL_UP_IN)
- {
- YY_YL_MOTOR = 0;
- YY_HL_MOTOR = 0;
- }
- }
- else
- {
- YY_YL_MOTOR = 0;
- YY_HL_MOTOR = 0;
- }
-
- if(YY_bPYMotor)
- {
- YY_bPYMotor = 0;
-
- if(YY_MAIN_MOTOR)
- {
- if(!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;
- YY_SD_MOTOR = 1;
- }
- else
- {
- if(YY_MAIN_MOTOR)
- {
- YY_CheckDelay = dwTickCount + 1000;
- }
- YY_MAIN_MOTOR = 0;
- YY_SD_MOTOR = 0;
- }
-
- if(bClearTotal)
- {
- bClearTotal = 0;
- switch(YY_bMode)
- {
- case YY_SINGLE_MODE:
- {
- YY_SingleParam->OverTotal = 0;
- YY_SingleParam->OverLength = 0;
- YY_SingleParam->SetTimeHour = 0;
- YY_SingleParam->SetTimeMinute = 0;
- }break;
- case YY_GROUP_MODE:
- {
- YY_GroupParam->AllOverTotal = 0;
- YY_GroupParam->AllOverLength = 0;
- YY_GroupParam->SetTimeHour = 0;
- YY_GroupParam->SetTimeMinute = 0;
- }break;
- }
- }
-
- if(YY_bClearAll)
- {
- YY_bClearAll = 0;
- YY_SystemParam->AllProductTime = 0;
- YY_SystemParam->AllProductLength = 0;
- }
- }
- void YYa_AlarmProtect(void)
- {
-
- }
- void YYa_AutoAction(void)
- {
- if(bRunning)
- {
- }
- }
- void YYa_SongLiao(void)
- {
- //送丝启动
- if(M0035)
- {
- //左送料(送丝)
- 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 YYa_StepCheckStart(void)
- {
- // 启动
- if((YY_START_IN_UP) || bStart || YY_bSingle)
- {
- bStart = 0;
-
- if(!bRunning && (YY_AutoStep == 0))
- {
- {
- bRunning = 1;
- if(YY_bSingle) SingOneFlg= 1;
- }
- }
- YY_bSingle = 0;
- }
- //停止
- if(YY_STOP_IN_UP || bStop)
- {
- bStop = 0;
-
- if(bRunning)
- {
- bRunning = 0;
- if(GetAlarmCode(YY_ALARM_ADDR) != 0)SetAlarmCode(YY_ALARM_ADDR,0);
- }
- else
- {
- if(GetAlarmCode(YY_ALARM_ADDR) != 0)SetAlarmCode(YY_ALARM_ADDR,0);
- }
- }
-
- if(bAlarmStop)
- {
- }
-
- }
- //零件寿命相关控制和运算
- 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;
- }
- }
- #endif
|