diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2020-12-03 12:31:12 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2020-12-03 12:31:12 +0200 |
| commit | 389aef8ec68dd58a9b40c95c5b55d339a5f67528 (patch) | |
| tree | f436e91793673a478cc33a0c0b4f5b73afa957e2 /Software/Embedded_SW | |
| parent | 64acdf2b43affc3403d6d40c96a6d48cfc5c5e23 (diff) | |
| download | Tango-389aef8ec68dd58a9b40c95c5b55d339a5f67528.tar.gz Tango-389aef8ec68dd58a9b40c95c5b55d339a5f67528.zip | |
thread load merge
Diffstat (limited to 'Software/Embedded_SW')
| -rw-r--r-- | Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c | 34 | ||||
| -rw-r--r-- | Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c | 13 |
2 files changed, 27 insertions, 20 deletions
diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c index 81e62746a..75f68d00c 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c @@ -249,10 +249,10 @@ uint32_t MotorRunWithCallback (TimerMotors_t MotorId,bool direction, uint32_t Fr MotorControlCallback[MotorId] = MotorMoveCallBackFunction; return MotorControlId[MotorId]; } -uint32_t MotorRunCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO +uint32_t MotorRunCallBackFunction(uint32_t IfIndex, uint32_t ReadValue) //TODO { uint32_t MotorId,encoder,temp = 0; - uint32_t Busy = BUSY; + uint32_t RunningContinues = true; int angle; if (IfIndex>>8 != IfTypeMotors) @@ -314,17 +314,17 @@ uint32_t MotorRunCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO { Report("MotorRunCallBackFunction temp curr prev small",__FILE__,encoder,InitialArmLocation,RpWarning,temp,0); failCounter++; - if (failCounter>=20) + if (failCounter>=5) { Report("arm stopped",__FILE__,failCounter,encoder,RpWarning,temp,0); MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Hard_Hiz); - Busy = NOTBUSY; + RunningContinues = false; } } else { failCounter = 0; - Busy = BUSY; + RunningContinues = true; } if (CallbackCalls%50 == 0) { @@ -347,7 +347,7 @@ uint32_t MotorRunCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO } MotorTimeout[MotorId]+=MotorTimeLag[MotorId]; - if ((Busy == NOTBUSY)||((MotorTimeout[MotorId]>=MotorTimeLimit[MotorId])&&(MotorTimeLimit[MotorId]>0))) + if ((RunningContinues == false)||((MotorTimeout[MotorId]>=MotorTimeLimit[MotorId])&&(MotorTimeLimit[MotorId]>0))) { if (MotorId == HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM) { @@ -355,17 +355,17 @@ uint32_t MotorRunCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO if (abs(angle)<400) { - Busy = NOTBUSY; + RunningContinues = false; } else { - Busy = BUSY; + RunningContinues = true; } Report("arm stopped call",__FILE__,failCounter,encoder,RpWarning,abs(DrierZeroPosition-encoder),0); - Report("arm stopped call 2",__FILE__,MotorTimeout[MotorId],Busy,RpWarning,angle,0); + Report("arm stopped call 2",__FILE__,MotorTimeout[MotorId],RunningContinues,RpWarning,angle,0); } //stop this control loop - Report("MotorControlGetnBusyState stop",__FILE__,MotorId,Busy,RpMessage,MotorCallback[MotorId],0); + Report("MotorControlGetnBusyState stop",__FILE__,MotorId,RunningContinues,RpMessage,MotorCallback[MotorId],0); SafeRemoveControlCallback(MotorControlId[MotorId], MotorRunCallBackFunction ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; @@ -374,13 +374,13 @@ uint32_t MotorRunCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO if ((MotorTimeout[MotorId]>=MotorTimeLimit[MotorId])&&(MotorTimeLimit[MotorId]>0)) { Report("motor timeout",__FILE__,__LINE__,MotorId,RpMessage,MotorTimeout[MotorId],0); - Busy = BUSY; + RunningContinues = true; } Report("MotorRunCallBackFunction curr prev return",__FILE__,encoder,temp,RpWarning,AccumulatedArmMovement,0); //call the module callback if (MotorCallback[MotorId]) { - MotorCallback[MotorId](MotorId,Busy); + MotorCallback[MotorId](MotorId,RunningContinues); } } @@ -620,8 +620,8 @@ uint32_t MotorMovetoEncoderPosition (TimerMotors_t MotorId, callback_fptr callb currentposition = Control_Read_Dryer_Position(0,0); MCU_E2PromRead(EEPROM_STORAGE_DRYER_CENTER,&DrierZeroPosition); Report("MotorMovetoEncoderPosition",__FILE__,__LINE__,DrierZeroPosition,RpWarning,currentposition,0); - Report("MotorMovetoEncoderPosition callback",__FILE__,__LINE__,callback,RpWarning,speed,0); - if (abs(currentposition - DrierZeroPosition)<5) + Report("MotorMovetoEncoderPosition callback",__FILE__,__LINE__,direction,RpWarning,speed,0); + if (abs(currentposition - DrierZeroPosition)<2) { if (callback) callback(MotorId,0); @@ -669,7 +669,7 @@ uint32_t MotorMoveCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO { Read_Dryer_ENC_Position(); if (CallbackCalls<50) - return; + return OK; if (CallbackCalls%200 == 0) { Report("MotorMoveCallBackFunction",__FILE__,__LINE__,MotorId,RpWarning,Read_Dryer_ENC_Position(0,0),0); @@ -1170,11 +1170,11 @@ uint32_t LoadingArmReset_Callback(uint32_t MotorId, uint32_t ReadValue) //if (fabs(angle)<0.2) { ReportWithPackageFilter(DiagnosticsFilter,"drier center proximity",__FILE__,temp,Arm_Drier_Center,RpMessage,angle,0); - if (angle<400) + if (angle>0) direction = 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize; else direction = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize; - MotorMovetoEncoderPosition(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,LoadingArmReset_Callback_Stopper_Callback,/*3000*/16000,direction,10); + MotorMovetoEncoderPosition(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,LoadingArmReset_Callback_Stopper_Callback,/*3000*/16000,direction,5); } else diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index f327ef3b2..ffbb504db 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -247,7 +247,8 @@ } uint32_t Thread_Load_Set_Load_Arm_To_Stopper_Callback(uint32_t deviceID, uint32_t BusyFlag) { - uint32_t angle, temp = Read_Dryer_ENC_Position(); + uint32_t temp = Read_Dryer_ENC_Position(); + int angle; ReportWithPackageFilter(DiagnosticsFilter,"Thread_Load_Set_Load_Arm_To_Stopper_Callback",__FILE__,(int)numberOfCycles,(int)DrierPrevLocation,RpMessage,temp,0); @@ -258,7 +259,7 @@ { CallbackCounter--; } - if ((abs(angle)<200 )&&(BusyFlag == NOTBUSY)) // OK + if (abs(angle)<10 ) // OK { Report("Thread_Load_Set_Load_Arm_To_Stopper time",__FILE__,msec_millisecondCounter - UnloadingStart,msec_millisecondCounter,RpMessage,UnloadingStart,0); @@ -274,7 +275,7 @@ else { load.color = fastBILNK; - usnprintf(LoadErrorMsg, 100, "*Stage %s - %s timeout",LoadStagesStr[LoadStages], MotorStr[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM]); + usnprintf(LoadErrorMsg, 100, "^Stage %s - %s timeout",LoadStagesStr[LoadStages], MotorStr[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM]); Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0); LoadStatus = ERROR; @@ -1531,6 +1532,12 @@ uint32_t TryThreadLoadingFunc(MessageContainer* requestContainer) { responseContainer = createContainer(MESSAGE_TYPE__TryThreadLoadingResponse, requestContainer->token, true, &Cresponse, &try_thread_loading_response__pack, &try_thread_loading_response__get_packed_size); responseContainer.continuous = false; + if (JobIsActive()||(MachineReadyForHeating == false)||(FPGABurningActive==true)) + { + responseContainer.has_error = true; + responseContainer.error = ERROR_CODE__GENERAL_ERROR; + responseContainer.errormessage = "The machine is not ready for loading"; + } uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); |
