From 1249c69fd5c7e9d0df3d502e78425a9e3a5404d3 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 1 Dec 2020 20:51:27 +0200 Subject: new event - head open. warnings removal --- Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index 11a92ab63..4ce48a639 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -9,6 +9,10 @@ #define WINDER_DANCER HARDWARE_DANCER_TYPE__LeftDancer #define POOLER_DANCER HARDWARE_DANCER_TYPE__MiddleDancer #define FEEDER_DANCER HARDWARE_DANCER_TYPE__RightDancer +#define WINDER_2_DANCER HARDWARE_DANCER_TYPE__FourthDancer +#define WINDER_3_DANCER HARDWARE_DANCER_TYPE__ThirdDancer +#define WINDER_4_DANCER HARDWARE_DANCER_TYPE__RightDancer + #define NUM_OF_DANCERS NUM_OF_ROTENC //} DANCER_ENUM; typedef enum threadMotorsEnum -- cgit v1.3.1 From 61b72c2bcb2798f7b0d96f1b4ccb5e176b2051dc Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Wed, 2 Dec 2020 19:56:02 +0200 Subject: thread loading fixes --- .../Embedded/Drivers/Motors/MotorActions.c | 43 ++++++++++++---------- .../Modules/Diagnostics/DiagnosticsHoming.c | 6 ++- .../Embedded/Modules/Heaters/Heaters_Blowers.c | 2 +- .../Embedded/Modules/Thread/ThreadLoad.c | 21 ++++++++--- 4 files changed, 45 insertions(+), 27 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c index 4722bfe2f..81e62746a 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c @@ -44,9 +44,6 @@ uint32_t DrierZeroPosition = 0; //bool DrierBackLashDirection = false; uint32_t Arm_Drier_Center = 0; callback_fptr UnloadingReset = NULL; -/*int CallbackCalls=0; -int FirstCall = 0; -#define MAX_CONTROL_SAMPLES 10*/ int32_t ArmSamples[MAX_CONTROL_SAMPLES] = {0}; int ArmSamplePointer = {0}; int StoredavreageSampleValue = 0; @@ -214,6 +211,7 @@ uint32_t MotorGotoWithBusyCallback (TimerMotors_t MotorId,bool direction, uint32 //MotorStop(MotorId,Hard_Hiz ); int sign = direction?1:-1; MotorGoTo(MotorId,Steps*sign ); + CallbackCalls = 0; MotorControlId[MotorId] = AddControlCallback(NULL, MotorMoveCallBackFunction, /*eTenMillisecond*/20, MotorControlGetnBusyState,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); MotorControlCallback[MotorId] = MotorMoveCallBackFunction; return MotorControlId[MotorId]; @@ -232,6 +230,7 @@ uint32_t MotorRunWithCallback (TimerMotors_t MotorId,bool direction, uint32_t Fr MotorTimeout[MotorId] = 0; MotorTimeLag[MotorId] = 20; MotorTimeLimit[MotorId] = timeout; + CallbackCalls = 0; if (MotorId ==HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM) { InitialArmLocation = Read_Dryer_ENC_Position(0,0); @@ -289,7 +288,7 @@ uint32_t MotorRunCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO } } } - else //loading - going up + /*else //loading - going up { //previous number is smaller than current if (InitialArmLocation1000)||(temp<20))&&(CallbackCalls>10)) { - Report("MotorRunCallBackFunctionMotorRunCallBackFunction temp curr prev small",__FILE__,encoder,InitialArmLocation,RpWarning,temp,0); + Report("MotorRunCallBackFunction temp curr prev small",__FILE__,encoder,InitialArmLocation,RpWarning,temp,0); failCounter++; if (failCounter>=20) { Report("arm stopped",__FILE__,failCounter,encoder,RpWarning,temp,0); MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Hard_Hiz); - BusyFlag = NOTBUSY; + Busy = NOTBUSY; } } else { failCounter = 0; - BusyFlag = BUSY; + Busy = BUSY; } if (CallbackCalls%50 == 0) { //encoder = Read_Dryer_ENC_Position(0,0); - Report("MotorRunCallBackFunctionMotorRunCallBackFunction periodic curr prev total",__FILE__,encoder,temp,RpWarning,AccumulatedArmMovement,0); + Report("MotorRunCallBackFunction periodic curr prev total",__FILE__,encoder,temp,RpWarning,AccumulatedArmMovement,0); } if (CallbackCalls%200 == 0) { //encoder = Read_Dryer_ENC_Position(0,0); - Report("MotorRunCallBackFunctionMotorRunCallBackFunction",__FILE__,__LINE__,encoder,RpWarning,CallbackCalls,0); + Report("MotorRunCallBackFunction",__FILE__,__LINE__,encoder,RpWarning,CallbackCalls,0); } } else @@ -348,24 +347,25 @@ uint32_t MotorRunCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO } MotorTimeout[MotorId]+=MotorTimeLag[MotorId]; - if ((BusyFlag == NOTBUSY)||((MotorTimeout[MotorId]>=MotorTimeLimit[MotorId])&&(MotorTimeLimit[MotorId]>0))) + if ((Busy == NOTBUSY)||((MotorTimeout[MotorId]>=MotorTimeLimit[MotorId])&&(MotorTimeLimit[MotorId]>0))) { if (MotorId == HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM) { - angle = Calculate_Arm_Distance(Arm_Drier_Center,temp); + angle = Calculate_Arm_Distance(Arm_Drier_Center,encoder); if (abs(angle)<400) { - BusyFlag = NOTBUSY; + Busy = NOTBUSY; } else { - BusyFlag = BUSY; + Busy = BUSY; } Report("arm stopped call",__FILE__,failCounter,encoder,RpWarning,abs(DrierZeroPosition-encoder),0); + Report("arm stopped call 2",__FILE__,MotorTimeout[MotorId],Busy,RpWarning,angle,0); } //stop this control loop - Report("MotorControlGetnBusyState stop",__FILE__,MotorId,BusyFlag,RpMessage,MotorCallback[MotorId],0); + Report("MotorControlGetnBusyState stop",__FILE__,MotorId,Busy,RpMessage,MotorCallback[MotorId],0); SafeRemoveControlCallback(MotorControlId[MotorId], MotorRunCallBackFunction ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; @@ -398,7 +398,7 @@ uint32_t MotorMoveWithCallback (TimerMotors_t MotorId,bool direction, uint32_t S Report("MotorControlGetnBusyState print",__FILE__,__LINE__,MotorDriverResponse[MotorId].Busy,RpMessage,0,0); }*/ ReportWithPackageFilter(GeneralFilter,"MotorMoveWithCallback",__FILE__,direction,MotorId,RpMessage,Steps,0); - + CallbackCalls = 0; //call driver action to device id with the parameter //SetMotorSpeed (deviceId, parameter); MotorCallback[MotorId] = callback; @@ -542,6 +542,7 @@ uint32_t MotorMoveToStopper (TimerMotors_t MotorId,bool direction, uint32_t Spee Task_sleep(10); Initialcurrentposition = Read_Dryer_ENC_Position(); cycles = 0; + CallbackCalls = 0; StoredMotorPosition[MotorId] = Read_Dryer_ENC_Position(); Report("MotorMoveToStopper initial position",__FILE__,__LINE__,StoredMotorPosition[MotorId],RpWarning,Initialcurrentposition,0); MotorSetSpeed (MotorId, Speed); @@ -664,9 +665,11 @@ uint32_t MotorMoveCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO } MotorId = IfIndex&0xFF; CallbackCalls++; - if (MotorId ==HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM) { + Read_Dryer_ENC_Position(); + if (CallbackCalls<50) + return; if (CallbackCalls%200 == 0) { Report("MotorMoveCallBackFunction",__FILE__,__LINE__,MotorId,RpWarning,Read_Dryer_ENC_Position(0,0),0); @@ -1157,7 +1160,7 @@ uint32_t LoadingArmReset_Callback(uint32_t MotorId, uint32_t ReadValue) uint32_t temp = Read_Dryer_ENC_Position(); angle = Calculate_Arm_Distance(Arm_Drier_Center,temp); ReportWithPackageFilter(DiagnosticsFilter,"LoadingArmReset_Callback",__FILE__,angle,temp,RpMessage,Arm_Drier_Center,0); - //ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics_Dryer_UnLoading_Callback details",__FILE__,(int)(TotalLoadedLen),D_numberOfCycles,RpMessage,CallbackCounter,0); + //ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics_Dryer_UnLoading_Callback details",__FILE__,__LINE__,ReadValue,RpMessage,0,0); //if ((AccumulatedArmMovement>8000 )&&(ReadValue == NOTBUSY)) // OK - take another round if (ReadValue == NOTBUSY) // OK - take another round { @@ -1189,6 +1192,7 @@ uint32_t LoadingArmReset_Callback(uint32_t MotorId, uint32_t ReadValue) else //timeout or no movement { ReportWithPackageFilter(DiagnosticsFilter,"Unloading drier - halted",__FILE__,__LINE__,Arm_Drier_Center,RpMessage,0,0); + MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Hard_Stop); //MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmRounds-(D_numberOfCycles-2));//it takes two cycles to identify a stop of the arm ReportWithPackageFilter(DiagnosticsFilter,"Dryer unloading timeout(1) or no movement",__FILE__,temp,Arm_Drier_Center,RpWarning,ReadValue,0); @@ -1217,7 +1221,8 @@ uint32_t LoadingArmReset (callback_fptr callback,uint32_t timeout) //TODO ReportWithPackageFilter(DiagnosticsFilter,"LoadingArmReset",__FILE__,__LINE__,timeout,RpMessage, 0,0); MotorRunWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize, - MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius, LoadingArmReset_Callback, 300000); + MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius, + LoadingArmReset_Callback, 300000); return OK; diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c index 7e1424b8a..d20cd65d5 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c @@ -615,13 +615,14 @@ uint32_t Diagnostics_Dryer_MovetoEncoderPosition_Callback(uint32_t MotorId, uint uint32_t Diagnostics_Dryer_Loading_Callback(uint32_t MotorId, uint32_t ReadValue) { D_numberOfCycles++; - uint32_t angle, temp = Read_Dryer_ENC_Position(); + int angle; + uint32_t temp = Read_Dryer_ENC_Position(); angle = Calculate_Arm_Distance(D_DrierPrevLocation,temp); ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics_Dryer_Loading_Callback",__FILE__,(int)angle,(int)ReadValue,RpMessage,temp,0); MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,D_numberOfCycles); - if ((abs(angle)>14000 )&&(ReadValue == NOTBUSY)) // OK - take another round + if ((abs(angle)<400 )&&(ReadValue == NOTBUSY)) // OK - take another round { D_DrierPrevLocation = temp; ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics_Dryer_Loading_Callback",__FILE__,ReadValue,temp,RpMessage,angle,0); @@ -653,6 +654,7 @@ uint32_t Diagnostics_Dryer_Loading(void) if (dryerbufferlength) LoadArmRounds = (int)dryerbufferlength; MCU_E2PromRead(EEPROM_STORAGE_DRYER_CENTER,&D_DrierPrevLocation); + //MCU_E2PromProgram(EEPROM_DRIER_LOADING_ARM_ANGLE,Calc_angle); ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics_Dryer_Loading request: current ",__FILE__,D_DrierPrevLocation,D_numberOfCycles,RpMessage,LoadArmRounds,0); Drier_Center_read = D_DrierPrevLocation; diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_Blowers.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_Blowers.c index eefd42d75..2f8de1643 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_Blowers.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_Blowers.c @@ -260,7 +260,7 @@ void setArcHeadAlarms(uint32_t AlarmId, bool value) } void FlatHeadAlarms(void) { - if (FPGA_Read_limit_Switches(Motor_Id_to_LS_IdUp [HARDWARE_MOTOR_TYPE__MOTO_DH_LID]) != LIMIT) { + if (FPGA_Read_limit_Switches(Motor_Id_to_LS_IdUp [HARDWARE_MOTOR_TYPE__MOTO_DH_LID]) == LIMIT) { if (++count9 == ARC_ALARM_LIMIT) setArcHeadAlarms(EVENT_TYPE__DYEING_HEAD_COVER_IS_OPEN, true); count9 = (count9 > ARC_ALARM_LIMIT)?(ARC_ALARM_LIMIT):(count9); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index f2ca4e8d7..f327ef3b2 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -258,12 +258,14 @@ { CallbackCounter--; } - if ((abs(angle)>14000 )&&(BusyFlag == NOTBUSY)) // OK - take another round + if ((abs(angle)<200 )&&(BusyFlag == NOTBUSY)) // OK { Report("Thread_Load_Set_Load_Arm_To_Stopper time",__FILE__,msec_millisecondCounter - UnloadingStart,msec_millisecondCounter,RpMessage,UnloadingStart,0); Report("Thread_Load_Set_Load_Arm_To_Stopper_Callback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); NumberOfDrierLoaderCycles=0; + MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,0); + //storeLoadArmParameters(); LoadStages++; @@ -272,7 +274,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; @@ -317,7 +319,7 @@ { TimeoutsCounter = 0; load.color = fastBILNK; - usnprintf(LoadErrorMsg, 100, "Stage %s - %s timeout",LoadStagesStr[LoadStages], MotorStr[MotorId]); + usnprintf(LoadErrorMsg, 100, "/Stage %s - %s timeout",LoadStagesStr[LoadStages], MotorStr[MotorId]); Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0); LoadStatus = ERROR; @@ -687,7 +689,7 @@ TimeoutsCounter = 0; CallbackCounter = 0; load.color = fastBILNK; - usnprintf(LoadErrorMsg, 100, "Stage %s - Dryer load arm timeout",LoadStagesStr[LoadStages]); + usnprintf(LoadErrorMsg, 100, "$Stage %s - Dryer load arm timeout",LoadStagesStr[LoadStages]); Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0); LoadStatus = ERROR; MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, 200); @@ -729,6 +731,13 @@ { LoadArmRounds -= CurrentlyLoaded; } + if (LoadArmRounds == CurrentlyLoaded) + { + Report("Thread_Load_Dryer_Loading no need for cycles",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); + LoadStages++; + ThreadLoadStateMachine(LoadStages); + return OK; + } ThreadMotorIdToMotorId[FEEDER_MOTOR] = HARDWARE_MOTOR_TYPE__MOTO_RDRIVING ; ThreadMotorIdToMotorId[DRYER_MOTOR] = HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING; @@ -932,7 +941,7 @@ MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,Hard_Hiz); load.color = fastBILNK; - usnprintf(LoadErrorMsg, 100, "Stage %s - Dryer load arm timeout",LoadStagesStr[LoadStages]); + usnprintf(LoadErrorMsg, 100, "&Stage %s - Dryer load arm timeout",LoadStagesStr[LoadStages]); Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0); Report("Dryer unloading timeout(1) or no movement",__FILE__,temp,DrierPrevLocation,RpWarning,ReadValue,0); LoadStatus = ERROR; @@ -1489,6 +1498,8 @@ uint32_t ThreadLoadingRestartReport(void) //sending after a failure in the final if (ThreadLoadingToken[0] == 0) return OK; + if (LoadStages == THREAD_LOAD_INIT) + return OK; ThreadLoadingRestartFlag = true; response.has_state = true; -- cgit v1.3.1 From af782aca2364948527c1107a02428897fb8382a1 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Thu, 3 Dec 2020 12:28:18 +0200 Subject: thread loading, mostly --- .../Embedded/Drivers/Motors/MotorActions.c | 61 ++++++----- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 4 +- .../Modules/Diagnostics/DiagnosticsHoming.c | 26 ++--- .../Embedded/Modules/General/GeneralHardware.c | 7 ++ .../Embedded/Modules/Heaters/Heaters_Blowers.c | 2 +- .../Embedded/Modules/Stubs_Handler/Progress.c | 4 +- .../Embedded/Modules/Thread/ThreadLoad.c | 30 ++++-- .../Embedded/Modules/Thread/Thread_print.c | 2 +- .../Embedded/StateMachines/Printing/JobSTM.c | 116 ++++++++++++--------- .../Embedded/StateMachines/Printing/PrintingSTM.c | 2 + Software/Stubs Collection/stubs/read WHS V0.cs | 33 ++++++ 11 files changed, 188 insertions(+), 99 deletions(-) create mode 100644 Software/Stubs Collection/stubs/read WHS V0.cs (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c index 4722bfe2f..75f68d00c 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c @@ -44,9 +44,6 @@ uint32_t DrierZeroPosition = 0; //bool DrierBackLashDirection = false; uint32_t Arm_Drier_Center = 0; callback_fptr UnloadingReset = NULL; -/*int CallbackCalls=0; -int FirstCall = 0; -#define MAX_CONTROL_SAMPLES 10*/ int32_t ArmSamples[MAX_CONTROL_SAMPLES] = {0}; int ArmSamplePointer = {0}; int StoredavreageSampleValue = 0; @@ -214,6 +211,7 @@ uint32_t MotorGotoWithBusyCallback (TimerMotors_t MotorId,bool direction, uint32 //MotorStop(MotorId,Hard_Hiz ); int sign = direction?1:-1; MotorGoTo(MotorId,Steps*sign ); + CallbackCalls = 0; MotorControlId[MotorId] = AddControlCallback(NULL, MotorMoveCallBackFunction, /*eTenMillisecond*/20, MotorControlGetnBusyState,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); MotorControlCallback[MotorId] = MotorMoveCallBackFunction; return MotorControlId[MotorId]; @@ -232,6 +230,7 @@ uint32_t MotorRunWithCallback (TimerMotors_t MotorId,bool direction, uint32_t Fr MotorTimeout[MotorId] = 0; MotorTimeLag[MotorId] = 20; MotorTimeLimit[MotorId] = timeout; + CallbackCalls = 0; if (MotorId ==HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM) { InitialArmLocation = Read_Dryer_ENC_Position(0,0); @@ -250,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) @@ -289,7 +288,7 @@ uint32_t MotorRunCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO } } } - else //loading - going up + /*else //loading - going up { //previous number is smaller than current if (InitialArmLocation1000)||(temp<20))&&(CallbackCalls>10)) { - Report("MotorRunCallBackFunctionMotorRunCallBackFunction temp curr prev small",__FILE__,encoder,InitialArmLocation,RpWarning,temp,0); + 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); - BusyFlag = NOTBUSY; + RunningContinues = false; } } else { failCounter = 0; - BusyFlag = BUSY; + RunningContinues = true; } if (CallbackCalls%50 == 0) { //encoder = Read_Dryer_ENC_Position(0,0); - Report("MotorRunCallBackFunctionMotorRunCallBackFunction periodic curr prev total",__FILE__,encoder,temp,RpWarning,AccumulatedArmMovement,0); + Report("MotorRunCallBackFunction periodic curr prev total",__FILE__,encoder,temp,RpWarning,AccumulatedArmMovement,0); } if (CallbackCalls%200 == 0) { //encoder = Read_Dryer_ENC_Position(0,0); - Report("MotorRunCallBackFunctionMotorRunCallBackFunction",__FILE__,__LINE__,encoder,RpWarning,CallbackCalls,0); + Report("MotorRunCallBackFunction",__FILE__,__LINE__,encoder,RpWarning,CallbackCalls,0); } } else @@ -348,24 +347,25 @@ uint32_t MotorRunCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO } MotorTimeout[MotorId]+=MotorTimeLag[MotorId]; - if ((BusyFlag == 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) { - angle = Calculate_Arm_Distance(Arm_Drier_Center,temp); + angle = Calculate_Arm_Distance(Arm_Drier_Center,encoder); if (abs(angle)<400) { - BusyFlag = NOTBUSY; + RunningContinues = false; } else { - BusyFlag = BUSY; + RunningContinues = true; } Report("arm stopped call",__FILE__,failCounter,encoder,RpWarning,abs(DrierZeroPosition-encoder),0); + Report("arm stopped call 2",__FILE__,MotorTimeout[MotorId],RunningContinues,RpWarning,angle,0); } //stop this control loop - Report("MotorControlGetnBusyState stop",__FILE__,MotorId,BusyFlag,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); } } @@ -398,7 +398,7 @@ uint32_t MotorMoveWithCallback (TimerMotors_t MotorId,bool direction, uint32_t S Report("MotorControlGetnBusyState print",__FILE__,__LINE__,MotorDriverResponse[MotorId].Busy,RpMessage,0,0); }*/ ReportWithPackageFilter(GeneralFilter,"MotorMoveWithCallback",__FILE__,direction,MotorId,RpMessage,Steps,0); - + CallbackCalls = 0; //call driver action to device id with the parameter //SetMotorSpeed (deviceId, parameter); MotorCallback[MotorId] = callback; @@ -542,6 +542,7 @@ uint32_t MotorMoveToStopper (TimerMotors_t MotorId,bool direction, uint32_t Spee Task_sleep(10); Initialcurrentposition = Read_Dryer_ENC_Position(); cycles = 0; + CallbackCalls = 0; StoredMotorPosition[MotorId] = Read_Dryer_ENC_Position(); Report("MotorMoveToStopper initial position",__FILE__,__LINE__,StoredMotorPosition[MotorId],RpWarning,Initialcurrentposition,0); MotorSetSpeed (MotorId, Speed); @@ -619,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); @@ -664,9 +665,11 @@ uint32_t MotorMoveCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO } MotorId = IfIndex&0xFF; CallbackCalls++; - if (MotorId ==HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM) { + Read_Dryer_ENC_Position(); + if (CallbackCalls<50) + return OK; if (CallbackCalls%200 == 0) { Report("MotorMoveCallBackFunction",__FILE__,__LINE__,MotorId,RpWarning,Read_Dryer_ENC_Position(0,0),0); @@ -1157,7 +1160,7 @@ uint32_t LoadingArmReset_Callback(uint32_t MotorId, uint32_t ReadValue) uint32_t temp = Read_Dryer_ENC_Position(); angle = Calculate_Arm_Distance(Arm_Drier_Center,temp); ReportWithPackageFilter(DiagnosticsFilter,"LoadingArmReset_Callback",__FILE__,angle,temp,RpMessage,Arm_Drier_Center,0); - //ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics_Dryer_UnLoading_Callback details",__FILE__,(int)(TotalLoadedLen),D_numberOfCycles,RpMessage,CallbackCounter,0); + //ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics_Dryer_UnLoading_Callback details",__FILE__,__LINE__,ReadValue,RpMessage,0,0); //if ((AccumulatedArmMovement>8000 )&&(ReadValue == NOTBUSY)) // OK - take another round if (ReadValue == NOTBUSY) // OK - take another round { @@ -1167,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 @@ -1189,6 +1192,7 @@ uint32_t LoadingArmReset_Callback(uint32_t MotorId, uint32_t ReadValue) else //timeout or no movement { ReportWithPackageFilter(DiagnosticsFilter,"Unloading drier - halted",__FILE__,__LINE__,Arm_Drier_Center,RpMessage,0,0); + MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Hard_Stop); //MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmRounds-(D_numberOfCycles-2));//it takes two cycles to identify a stop of the arm ReportWithPackageFilter(DiagnosticsFilter,"Dryer unloading timeout(1) or no movement",__FILE__,temp,Arm_Drier_Center,RpWarning,ReadValue,0); @@ -1217,7 +1221,8 @@ uint32_t LoadingArmReset (callback_fptr callback,uint32_t timeout) //TODO ReportWithPackageFilter(DiagnosticsFilter,"LoadingArmReset",__FILE__,__LINE__,timeout,RpMessage, 0,0); MotorRunWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize, - MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius, LoadingArmReset_Callback, 300000); + MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius, + LoadingArmReset_Callback, 300000); return OK; diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index 059b8fc4c..829261533 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -154,14 +154,14 @@ typedef enum typedef struct { - uint16_t Frequency; //1/10/100/1000 + //uint16_t Frequency; //1/10/100/1000 AlarmSourceType AlarmSource; uint16_t DeviceId; uint8_t ModuleDeviceId; uint16_t AlarmValue; bool AlarmDirection; DebugLogCategory Severity; - uint16_t Predecessor; + //uint16_t Predecessor; uint8_t DebounceValue; EventType EventType; bool isPersistent; diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c index 7e1424b8a..0e235e043 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c @@ -481,17 +481,12 @@ uint32_t Diagnostics_Set_Load_Arm_To_Stopper_Callback(uint32_t deviceID, uint32_ { MessageContainer responseContainer; MotorHomingResponse response = MOTOR_HOMING_RESPONSE__INIT; - uint32_t angle, temp = Read_Dryer_ENC_Position(); + uint32_t temp = Read_Dryer_ENC_Position(); + int angle; - angle = Calculate_Arm_Distance(D_DrierPrevLocation,temp); + angle = Calculate_Arm_Distance(Drier_Center_read,temp); - if ((abs (angle)<14000 )||(BusyFlag == BUSY)) // OK - take another round - { - responseContainer.has_error = true; - responseContainer.error = ERROR_CODE__GENERAL_ERROR; - - } - ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics_Set_Load_Arm_To_Stopper time",__FILE__,__LINE__,msec_millisecondCounter,RpMessage,0,0); + ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics_Set_Load_Arm_To_Stopper time",__FILE__,__LINE__,msec_millisecondCounter,RpMessage,angle,0); if (HomingControlId[deviceID] != 0xff) { ReportWithPackageFilter(DiagnosticsFilter,"MotorHomingProgressReport stopped",__FILE__,__LINE__,deviceID,RpMessage,HomingCounter[deviceID],0); @@ -506,6 +501,11 @@ uint32_t Diagnostics_Set_Load_Arm_To_Stopper_Callback(uint32_t deviceID, uint32_ responseContainer = createContainer(MESSAGE_TYPE__MotorHomingResponse, HomingToken[deviceID], true, &response, &motor_homing_response__pack, &motor_homing_response__get_packed_size); responseContainer.has_continuous = true; responseContainer.continuous = true; + if (abs (angle)>20) // arm not at center position + { + responseContainer.has_error = true; + responseContainer.error = ERROR_CODE__GENERAL_ERROR; + } 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); @@ -556,7 +556,7 @@ uint32_t Diagnostics_Set_Load_Arm_To_Stopper_Callback(uint32_t deviceID, uint32_ uint32_t Diagnostics_Dryer_UnLoading(void) { D_DrierPrevLocation = Read_Dryer_ENC_Position(); - + MCU_E2PromRead(EEPROM_STORAGE_DRYER_CENTER,&Drier_Center_read); LoadingArmReset(Diagnostics_Set_Load_Arm_To_Stopper_Callback,300000); /*uint32_t temp; @@ -615,13 +615,14 @@ uint32_t Diagnostics_Dryer_MovetoEncoderPosition_Callback(uint32_t MotorId, uint uint32_t Diagnostics_Dryer_Loading_Callback(uint32_t MotorId, uint32_t ReadValue) { D_numberOfCycles++; - uint32_t angle, temp = Read_Dryer_ENC_Position(); + int angle; + uint32_t temp = Read_Dryer_ENC_Position(); angle = Calculate_Arm_Distance(D_DrierPrevLocation,temp); ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics_Dryer_Loading_Callback",__FILE__,(int)angle,(int)ReadValue,RpMessage,temp,0); MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,D_numberOfCycles); - if ((abs(angle)>14000 )&&(ReadValue == NOTBUSY)) // OK - take another round + if ((abs(angle)<400 )&&(ReadValue == NOTBUSY)) // OK - take another round { D_DrierPrevLocation = temp; ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics_Dryer_Loading_Callback",__FILE__,ReadValue,temp,RpMessage,angle,0); @@ -653,6 +654,7 @@ uint32_t Diagnostics_Dryer_Loading(void) if (dryerbufferlength) LoadArmRounds = (int)dryerbufferlength; MCU_E2PromRead(EEPROM_STORAGE_DRYER_CENTER,&D_DrierPrevLocation); + //MCU_E2PromProgram(EEPROM_DRIER_LOADING_ARM_ANGLE,Calc_angle); ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics_Dryer_Loading request: current ",__FILE__,D_DrierPrevLocation,D_numberOfCycles,RpMessage,LoadArmRounds,0); Drier_Center_read = D_DrierPrevLocation; diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 3fbb4e70c..c572d29e6 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -217,6 +217,13 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) EmbeddedParameters->has_openvalvetimeout = true; EmbeddedParameters->openvalvetimeout = 52; + EmbeddedParameters->has_initialdispenserpressure = true; + EmbeddedParameters->initialdispenserpressure=3.85; + EmbeddedParameters->has_initialdispensertimeout = true; + EmbeddedParameters->initialdispensertimeout=120000.0 ; + EmbeddedParameters->has_initialdispensertimelag = true; + EmbeddedParameters->initialdispensertimelag=100.0 ; + EmbeddedParameters->has_dispenserbuildpressurespeed = true; EmbeddedParameters->dispenserbuildpressurespeed=500; EmbeddedParameters->has_dispenserbuildpressurelimit = true; diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_Blowers.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_Blowers.c index eefd42d75..2f8de1643 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_Blowers.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_Blowers.c @@ -260,7 +260,7 @@ void setArcHeadAlarms(uint32_t AlarmId, bool value) } void FlatHeadAlarms(void) { - if (FPGA_Read_limit_Switches(Motor_Id_to_LS_IdUp [HARDWARE_MOTOR_TYPE__MOTO_DH_LID]) != LIMIT) { + if (FPGA_Read_limit_Switches(Motor_Id_to_LS_IdUp [HARDWARE_MOTOR_TYPE__MOTO_DH_LID]) == LIMIT) { if (++count9 == ARC_ALARM_LIMIT) setArcHeadAlarms(EVENT_TYPE__DYEING_HEAD_COVER_IS_OPEN, true); count9 = (count9 > ARC_ALARM_LIMIT)?(ARC_ALARM_LIMIT):(count9); diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c index 750dc81af..73282fa97 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c @@ -1033,7 +1033,9 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) Read_Dryer_ENC_Position(); Task_sleep(500); - response.progress = (double)MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CENTER,Read_Dryer_ENC_Position(0,0)); + (double)MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CENTER,Read_Dryer_ENC_Position(0,0)); + + response.progress = (double)Read_Dryer_ENC_Position(0,0); response.has_progress = true; } else diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index f2ca4e8d7..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,12 +259,14 @@ { CallbackCounter--; } - if ((abs(angle)>14000 )&&(BusyFlag == NOTBUSY)) // OK - take another round + if (abs(angle)<10 ) // OK { Report("Thread_Load_Set_Load_Arm_To_Stopper time",__FILE__,msec_millisecondCounter - UnloadingStart,msec_millisecondCounter,RpMessage,UnloadingStart,0); Report("Thread_Load_Set_Load_Arm_To_Stopper_Callback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); NumberOfDrierLoaderCycles=0; + MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,0); + //storeLoadArmParameters(); LoadStages++; @@ -272,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; @@ -317,7 +320,7 @@ { TimeoutsCounter = 0; load.color = fastBILNK; - usnprintf(LoadErrorMsg, 100, "Stage %s - %s timeout",LoadStagesStr[LoadStages], MotorStr[MotorId]); + usnprintf(LoadErrorMsg, 100, "/Stage %s - %s timeout",LoadStagesStr[LoadStages], MotorStr[MotorId]); Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0); LoadStatus = ERROR; @@ -687,7 +690,7 @@ TimeoutsCounter = 0; CallbackCounter = 0; load.color = fastBILNK; - usnprintf(LoadErrorMsg, 100, "Stage %s - Dryer load arm timeout",LoadStagesStr[LoadStages]); + usnprintf(LoadErrorMsg, 100, "$Stage %s - Dryer load arm timeout",LoadStagesStr[LoadStages]); Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0); LoadStatus = ERROR; MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, 200); @@ -729,6 +732,13 @@ { LoadArmRounds -= CurrentlyLoaded; } + if (LoadArmRounds == CurrentlyLoaded) + { + Report("Thread_Load_Dryer_Loading no need for cycles",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); + LoadStages++; + ThreadLoadStateMachine(LoadStages); + return OK; + } ThreadMotorIdToMotorId[FEEDER_MOTOR] = HARDWARE_MOTOR_TYPE__MOTO_RDRIVING ; ThreadMotorIdToMotorId[DRYER_MOTOR] = HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING; @@ -932,7 +942,7 @@ MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,Hard_Hiz); load.color = fastBILNK; - usnprintf(LoadErrorMsg, 100, "Stage %s - Dryer load arm timeout",LoadStagesStr[LoadStages]); + usnprintf(LoadErrorMsg, 100, "&Stage %s - Dryer load arm timeout",LoadStagesStr[LoadStages]); Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0); Report("Dryer unloading timeout(1) or no movement",__FILE__,temp,DrierPrevLocation,RpWarning,ReadValue,0); LoadStatus = ERROR; @@ -1489,6 +1499,8 @@ uint32_t ThreadLoadingRestartReport(void) //sending after a failure in the final if (ThreadLoadingToken[0] == 0) return OK; + if (LoadStages == THREAD_LOAD_INIT) + return OK; ThreadLoadingRestartFlag = true; response.has_state = true; @@ -1520,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); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index ba505493d..c3fb17460 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -1061,7 +1061,7 @@ uint32_t ThreadPrepare_Tension (int DancerId, double tension) return status; } //******************************************************************************************************************** -bool SkipOpenLids = true; +bool SkipOpenLids = false; uint32_t ThreadPrepareState(void *JobDetails) { int Motor_i,i, HW_Motor_Id, Pid_Id; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 21bf400de..dedf8ba98 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -109,6 +109,7 @@ HeadCleaningParameters *CleaningParameters = NULL; bool CopyConfigured[MAX_SYSTEM_MODULES]; bool CleaningJobActive = false, JoggingJobActive = false; char ErrorMsg[100]; +uint32_t JobEndTimeMillisec = 0; ModuleStateEnum PrepareWaiting[MAX_SYSTEM_MODULES] = {ModuleIdle,ModuleIdle,ModuleIdle,ModuleIdle,ModuleIdle}; double job_length = 0.0; @@ -396,58 +397,77 @@ uint32_t ThreadJoggingFunc(int speed) { ProcessParameters ProcessParametersCopy; uint32_t status = OK; - if ((JobIsActive() == true)||(JoggingJobActive == true)||(MachineReadyForHeating == false)||(FPGABurningActive==true)) +// JobEndTimeMillisec = msec_millisecondCounter; + + if (JobIsActive() == true) { - status = ERROR; - Report("Jog JobIsActive or machine initialisation", __FILE__, __LINE__, JobIsActive(), RpWarning, JoggingJobActive, 0); + Report("cannot jog while JobIsActive", __FILE__, __LINE__, JobIsActive(), RpWarning, JoggingJobActive, 0); + return ERROR; + } + if (JoggingJobActive == true) + { + Report("cannot jog while JoggingJobActive", __FILE__, __LINE__, JoggingJobActive, RpWarning, JoggingJobActive, 0); + return ERROR; + } + if (MachineReadyForHeating == false) + { + Report("cannot jog while Machine not ReadyForHeating", __FILE__, __LINE__, MachineReadyForHeating, RpWarning, JoggingJobActive, 0); + return ERROR; + } + if (FPGABurningActive==true) + { + Report("cannot jog while FPGABurningActive", __FILE__, __LINE__, FPGABurningActive, RpWarning, JoggingJobActive, 0); + return ERROR; + } + if ((msec_millisecondCounter - JobEndTimeMillisec) <2000) + { + Report("cannot jog while Job Is ending", __FILE__, __LINE__, msec_millisecondCounter, RpWarning, JobEndTimeMillisec, 0); + return ERROR; } + //memcpy(&CopyConfigured,&Configured,sizeof(CopyConfigured)); + //usnprintf(ErrorMsg, 80,"Copy Configured T %d W %d I %d H %d W %d",CopyConfigured[Module_Thread],CopyConfigured[Module_Winder],CopyConfigured[Module_IDS],CopyConfigured[Module_Heaters],CopyConfigured[Module_Waste]); + //Report(ErrorMsg, __FILE__, __LINE__, 0, RpWarning, 0, 0); + + //set the job handler to ignore heaters, ids and waste in the state machine + Configured[Module_Thread] = true; + Configured[Module_Winder] = true; + Configured[Module_IDS] = false; + Configured[Module_Heaters] = false; + Configured[Module_Waste] = false; + //set the requested speed without changing other process parameters + memcpy (&ProcessParametersCopy,&ProcessParametersKeep,sizeof(ProcessParameters)); + if(speed) + ProcessParametersCopy.dyeingspeed = speed; else + ProcessParametersCopy.dyeingspeed = 40; + if (HandleProcessParameters(&ProcessParametersCopy,false)!= OK) { - //memcpy(&CopyConfigured,&Configured,sizeof(CopyConfigured)); - //usnprintf(ErrorMsg, 80,"Copy Configured T %d W %d I %d H %d W %d",CopyConfigured[Module_Thread],CopyConfigured[Module_Winder],CopyConfigured[Module_IDS],CopyConfigured[Module_Heaters],CopyConfigured[Module_Waste]); - //Report(ErrorMsg, __FILE__, __LINE__, 0, RpWarning, 0, 0); - - //set the job handler to ignore heaters, ids and waste in the state machine - Configured[Module_Thread] = true; - Configured[Module_Winder] = true; - Configured[Module_IDS] = false; - Configured[Module_Heaters] = false; - Configured[Module_Waste] = false; - //set the requested speed without changing other process parameters - memcpy (&ProcessParametersCopy,&ProcessParametersKeep,sizeof(ProcessParameters)); - if(speed) - ProcessParametersCopy.dyeingspeed = speed; - else - ProcessParametersCopy.dyeingspeed = 40; - if (HandleProcessParameters(&ProcessParametersCopy,false)!= OK) - { - Report("Process parameters handling failed", __FILE__, __LINE__, 0, RpWarning, 0, 0); - status = FAILED; - } - else - { - //load essential job prameters to enable thread running - Ticket.n_segments = 1; - n_segments = 1; - Ticket.segments = my_malloc(sizeof(Ticket.segments)); - TSegment = my_malloc(sizeof(JobSegment)); - Tspool = my_malloc(sizeof(JobSpool)); - TSegment->length = 200.0; - TSegment->n_brushstops = 0; - Ticket.segments[0] = TSegment; - Tspool->backingrate = 32; - Tspool->bottombackingrate = 32; - Tspool->segmentoffsetpulses = 1000; - Tspool->startoffsetpulses = 220; - Tspool->rotationsperpassage = 3.1415926*2; - Tspool->has_limitswitchstartpointoffset = false; - Ticket.spool = Tspool; - Ticket.threadparameters = &SavedThreadParameters; - CurrentJob = &Ticket; - InternalWindingConfigMessage(Tspool); - JoggingJobActive = true; - StartJob(&Ticket); - } + Report("Process parameters handling failed", __FILE__, __LINE__, 0, RpWarning, 0, 0); + status = FAILED; + } + else + { + //load essential job prameters to enable thread running + Ticket.n_segments = 1; + n_segments = 1; + Ticket.segments = my_malloc(sizeof(Ticket.segments)); + TSegment = my_malloc(sizeof(JobSegment)); + Tspool = my_malloc(sizeof(JobSpool)); + TSegment->length = 200.0; + TSegment->n_brushstops = 0; + Ticket.segments[0] = TSegment; + Tspool->backingrate = 32; + Tspool->bottombackingrate = 32; + Tspool->segmentoffsetpulses = 1000; + Tspool->startoffsetpulses = 220; + Tspool->rotationsperpassage = 3.1415926*2; + Tspool->has_limitswitchstartpointoffset = false; + Ticket.spool = Tspool; + Ticket.threadparameters = &SavedThreadParameters; + CurrentJob = &Ticket; + InternalWindingConfigMessage(Tspool); + JoggingJobActive = true; + StartJob(&Ticket); } return status; } diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c index 7db59946e..3e790eabe 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c @@ -59,6 +59,7 @@ uint16_t n_units = 1; uint16_t n_unit_segments = 0; extern bool JobActive; +extern uint32_t JobEndTimeMillisec; /********************************************************************** * the array and enum of PrintingState_t below must be in sync order ***********************************************************************/ @@ -656,6 +657,7 @@ uint32_t EndState(void *JobDetails, char *Message) CloseJobFile(); //ROM_IntMasterEnable(); JobActive = false; //bug 4162 - test carefully + JobEndTimeMillisec = msec_millisecondCounter; //#4027 SendJobProgress(0.0,0,true,Message); if ((JoggingJobActive==false)&&(CleaningJobActive == false)) { diff --git a/Software/Stubs Collection/stubs/read WHS V0.cs b/Software/Stubs Collection/stubs/read WHS V0.cs new file mode 100644 index 000000000..fb67ba2cc --- /dev/null +++ b/Software/Stubs Collection/stubs/read WHS V0.cs @@ -0,0 +1,33 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +public void OnExecute(StubManager stubManager) +{ + + ProgressRequest progressRequest = new ProgressRequest(); + progressRequest.Amount = 0xD11; //turn off blower and PID + progressRequest.Delay = 0; + + var response = stubManager.Run(progressRequest); + + Thread.Sleep(3000); + + progressRequest.Amount = 0xD12; //run V0 recalculation + response = stubManager.Run(progressRequest); + + + Thread.Sleep(20000); + + progressRequest.Amount = 0xD11; //turn on blower and PID + progressRequest.Delay = 1; + response = stubManager.Run(progressRequest); +} \ No newline at end of file -- cgit v1.3.1 From 389aef8ec68dd58a9b40c95c5b55d339a5f67528 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Thu, 3 Dec 2020 12:31:12 +0200 Subject: thread load merge --- .../Embedded/Drivers/Motors/MotorActions.c | 34 +++++++++++----------- .../Embedded/Modules/Thread/ThreadLoad.c | 13 +++++++-- 2 files changed, 27 insertions(+), 20 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') 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); -- cgit v1.3.1 From 19960336594324a57d3bfd01bfec1aab44c95138 Mon Sep 17 00:00:00 2001 From: Ronen Sberlo Date: Mon, 7 Dec 2020 14:53:04 +0200 Subject: bug 4045: "SCREW_MOTOR_LIMIT_TIMEOUT" after the job ended --- Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index a75241671..f5e012a1e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -685,10 +685,13 @@ uint32_t ScrewDTSCallback(uint32_t deviceID, uint32_t BusyFlag) uint32_t WinderDistanceToSpoolState(void ) { double DTS_Time = (dryerbufferCentimeters/dyeingspeed)*1000;//distance to spool time in milliseconds + double WinderBackTimeBySpeed = WinderBackToBaseTime; + WinderBackTimeBySpeed /= 50; + WinderBackTimeBySpeed *= dyeingspeed; REPORT_MSG ((int)DTS_Time,"WinderDistanceToSpoolState"); - ScrewDTSControlId = AddControlCallback("screw DTS",ScrewDTSCallback, DTS_Time-WinderBackToBaseTime,TemplateDataReadCBFunction,0,0,0); - Report("ScrewDTSCallback start", __FILE__,DTS_Time,msec_millisecondCounter, RpMessage, WinderBackToBaseTime, 0); + ScrewDTSControlId = AddControlCallback("screw DTS",ScrewDTSCallback, DTS_Time-WinderBackTimeBySpeed,TemplateDataReadCBFunction,0,0,0); + Report("ScrewDTSCallback start", __FILE__,DTS_Time,msec_millisecondCounter, RpMessage, (int)WinderBackTimeBySpeed, 0); return OK; } -- cgit v1.3.1 From b4062b0eace7983126d87001739ddcd3ad9c2c32 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 7 Dec 2020 23:32:59 +0200 Subject: fixes --- Software/Embedded_SW/Embedded/Main.c | 7 +-- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 4 -- .../Embedded/Modules/Diagnostics/Diagnostics.c | 2 +- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 55 ++++------------------ .../Embedded/Modules/Thread/Thread_Winder.c | 12 ++--- 5 files changed, 19 insertions(+), 61 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index 5a98b5ece..d046df48d 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -136,7 +136,7 @@ Void MyswitchFxn(Task_Handle prev, Task_Handle next) PrevTask = prev; NextTask = next; } -void updateresetreasonineeprom(void) +void updateresetreasonineeprom(int i) { #define Head_Address 40 #define Max_Address 100 @@ -146,6 +146,7 @@ void updateresetreasonineeprom(void) EEPROMRead(&Head,Head_Address*4, 4); if (Head>=Max_Address) Head=0; Head++; + RESC+=(i*0x1000); EEPROMProgram(&Head, Head_Address*4, 4); EEPROMProgram(&RESC, (Head_Address+Head)*4, 4); @@ -159,7 +160,7 @@ Void errHook(Error_Block *eb) //char File[50] = "";*/ char message[300]; int len; - updateresetreasonineeprom(); + updateresetreasonineeprom(InitFailures); //STATUS_GREEN_LED_OFF; ACTIVITY_GREEN_LED_OFF; @@ -268,7 +269,7 @@ int main(void) uint32_t Data,i; MCU_E2PromInit(); - updateresetreasonineeprom(); + updateresetreasonineeprom(0); #endif #ifdef EVALUATION_BOARD diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index 829261533..160c3a0b5 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -490,16 +490,12 @@ uint32_t AlarmHandlingLoadFile(void) F_count = 0; for (i = 0; i < AlarmParametersTable->n_alarmitem ;i++) { - FileAlarmItem[F_count].AlarmDirection = AlarmParametersTable->alarmitem[i]->alarmdirection; FileAlarmItem[F_count].AlarmDirection = AlarmParametersTable->alarmitem[i]->alarmdirection; - //FileAlarmItem[F_count].Frequency = AlarmParametersTable->alarmitem[i]->frequency; //1/10/100/1000 FileAlarmItem[F_count].AlarmSource = AlarmParametersTable->alarmitem[i]->alarmsource; FileAlarmItem[F_count].DeviceId = AlarmParametersTable->alarmitem[i]->deviceid; FileAlarmItem[F_count].ModuleDeviceId = AlarmParametersTable->alarmitem[i]->moduledeviceid; FileAlarmItem[F_count].AlarmValue = AlarmParametersTable->alarmitem[i]->alarmvalue; - FileAlarmItem[F_count].AlarmDirection = AlarmParametersTable->alarmitem[i]->alarmdirection; FileAlarmItem[F_count].Severity = AlarmParametersTable->alarmitem[i]->severity; - //FileAlarmItem[F_count].Predecessor = AlarmParametersTable->alarmitem[i]->predecessor; FileAlarmItem[F_count].DebounceValue = AlarmParametersTable->alarmitem[i]->debouncevalue; FileAlarmItem[F_count].EventType = AlarmParametersTable->alarmitem[i]->eventtype; FileAlarmItem[F_count].isPersistent = AlarmParametersTable->alarmitem[i]->ispersistent; diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index d880b1381..9cad274b9 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -78,7 +78,7 @@ DiagnosticsMonitors DiagnosticsMonitor = DIAGNOSTICS_MONITORS__INIT; #define DIAGNOSTICS_LIMIT 3 #define DIAGNOSTICS_DANCER_LIMIT 30 int DiagnosticsIndex = 0; -int DiagnosticCollectionLimit = 3; //number of data samples to collect before sending to the host +int DiagnosticCollectionLimit = 1; //number of data samples to collect before sending to the host //int DiagnosticLimit = eHundredMillisecond; //frequency of data collection //int DiagnosticFastLimit = eTenMillisecond; //frequency of data collection int DiagnosticLimit =eHundredMillisecond; //frequency of data collection diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index d567f8ad9..879aa84a6 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -693,6 +693,8 @@ bool AdjustDispenserSpeedToPressure(int DispenserId, double RefMaxPressure,doubl for (Dispenser_i = 0; Dispenser_i < n_dispensers; Dispenser_i++) { DispenserId = Dispensers[Dispenser_i]->index; + if (DispenserId!=Dispenser_i) + ReportWithPackageFilter(IDSFilter,"DispenserId!=Dispenser_i",__FILE__,__LINE__,DispenserId,RpWarning,(int)Dispenser_i,0); HW_Motor_Id = DispenserIdToMotorId[DispenserId]; if (MotorsCfg[HW_Motor_Id].hardwaremotortype != DispenserIdToMotorId[DispenserId]) @@ -729,7 +731,7 @@ bool AdjustDispenserSpeedToPressure(int DispenserId, double RefMaxPressure,doubl { MotorSetSpeed(HW_Motor_Id, segmentfirst_speed); } - CurrentDispenserSpeed[Dispenser_i] = segmentfirst_speed; + CurrentDispenserSpeed[DispenserId] = segmentfirst_speed; /*usnprintf(IdMessage, 80, "WFCF Dispenser %d nl/sec %d nl/pulse %d Pulse/sec %d speed %d", @@ -747,7 +749,7 @@ bool AdjustDispenserSpeedToPressure(int DispenserId, double RefMaxPressure,doubl if (DispenserUsedInJob[DispenserId] == true) { MotorStop(HW_Motor_Id, Hard_Hiz); - CurrentDispenserSpeed[Dispenser_i] = 0; + CurrentDispenserSpeed[DispenserId] = 0; //usnprintf(IdsMessage, 80,"WFCF Prepare Dispenser %d stopped",DispenserId,(int) segmentfirst_speed); //ReportWithPackageFilter(IDSFilter,IdsMessage, __FILE__, __LINE__, Dispenser_i, RpWarning, segmentfirst_speed, 0); } @@ -1085,9 +1087,9 @@ bool AdjustDispenserSpeedToPressure(int DispenserId, double RefMaxPressure,doubl / Dispensers[Dispenser_i]->nanoliterperpulse; if (segmentfirst_speed > MINIMAL_MOTOR_SPEED) { - DispenserUsedInSegment[Dispenser_i] = true; + DispenserUsedInSegment[DispenserId] = true; MotorSetSpeed(HW_Motor_Id, DispenserPrepareSpeed); - CurrentDispenserSpeed[Dispenser_i] = DispenserPrepareSpeed; + CurrentDispenserSpeed[DispenserId] = DispenserPrepareSpeed; //usnprintf(IdsMessage, 80,"Presegment Prepare Dispenser %d speed %d",DispenserId,(int) DispenserPrepareSpeed); //REPORT_MSG(segmentfirst_speed,IdsMessage); //ReportWithPackageFilter(IDSFilter,IdsMessage, __FILE__, __LINE__, Dispenser_i, RpWarning, DispenserPrepareSpeed, 0); @@ -1105,7 +1107,7 @@ bool AdjustDispenserSpeedToPressure(int DispenserId, double RefMaxPressure,doubl { MotorStop(HW_Motor_Id, Hard_Hiz); } - CurrentDispenserSpeed[Dispenser_i] = 0; + CurrentDispenserSpeed[DispenserId] = 0; //usnprintf(IdsMessage, 80,"Presegment Prepare Dispenser %d stopped",DispenserId,(int) segmentfirst_speed); //ReportWithPackageFilter(IDSFilter,IdsMessage, __FILE__, __LINE__, Dispenser_i, RpWarning, segmentfirst_speed, 0); } @@ -1302,7 +1304,7 @@ uint32_t IDS_Cleaning_Stop_Cleaning_Solution (callback_fptr callback); //Control3WayValvesWithCallback (DispenserId, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer //IDS_Dispenser_Start_Motor_and_Open_Valve(DispenserId,segmentfirst_speed,NULL); MotorSetSpeed(HW_Motor_Id, segmentfirst_speed); - CurrentDispenserSpeed[Dispenser_i] = segmentfirst_speed; + CurrentDispenserSpeed[DispenserId] = segmentfirst_speed; /*usnprintf(IdMessage, 80, "WFCF Dispenser %d nl/sec %d nl/pulse %d Pulse/sec %d speed %d", @@ -1422,47 +1424,8 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) } ReportWithPackageFilter(IDSFilter,"Add control callback ",__FILE__,__LINE__,(int)100,RpWarning,(int)lInterSegmentLength,0); } - /*if (EnableCleaning == true) - { - InterSegmentStartSprayCleaner = 500; - InterSegmentStartRocking = 1000; - InterSegmentCenterRockers = 3000; - }*/ - - //InterSegmentStartWFCFDispensers = (lInterSegmentLength>5000)?lInterSegmentLength-5000:lInterSegmentLength; } } - /*if (SegmentId == 0)//first segment - running the DTS out of the drier - { - Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); //if intersegment is defined throw the ink away - for (Dispenser_i = 0; Dispenser_i < MAX_SYSTEM_DISPENSERS; Dispenser_i++) - { - HW_Motor_Id = DispenserIdToMotorId[Dispenser_i]; - //MotorStop(HW_Motor_Id,Hard_Hiz); //26/03/19 test without valves - if (DispenserUsedInJob[Dispenser_i]==true)//unconfigured dispenser - { - MotorStop(HW_Motor_Id, Soft_Hiz); - CurrentDispenserSpeed[Dispenser_i] = 0; - } - } - lInterSegmentLength = (dryerbufferCentimeters*1000/dyeingspeed); - lInterSegmentLength-=(lInterSegmentLength%100); //round to a 100 multiplication - InterSegmentStepsCount = 0; - DispenserPreSegmentControlId = AddControlCallback( IDSPreSegmentStateCallbackRunner, IDS_PRESEGMENT_TIME_STEP,TemplateDataReadCBFunction ,0, 0, 0 ); - if (DispenserPreSegmentControlId == 0xFF) - { - ReportWithPackageFilter(IDSFilter,"Add control callback failed",__FILE__,__LINE__,(int)100,RpWarning,(int)0,0); - return ERROR; - } - ReportWithPackageFilter(IDSFilter,"Add control callback ",__FILE__,__LINE__,(int)100,RpWarning,(int)lInterSegmentLength,0); - if (EnableCleaning == true) - { - InterSegmentStartSprayCleaner = 500; - InterSegmentStartRocking = 1000; - InterSegmentCenterRockers = 3000; - } - InterSegmentStartWFCFDispensers = lInterSegmentLength-5000; - }*/ if (uploadstrategy == JOB_UPLOAD_STRATEGY__Default) { @@ -1539,8 +1502,6 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) MotorStop(HW_Motor_Id,Soft_Hiz); //26/03/19 test without valves } CurrentDispenserSpeed[DispenserId] = 0; - //MotorSetSpeed(HW_Motor_Id, 5); - //CurrentDispenserSpeed[Dispenser_i] = 5; DispenserPreSegmentReady[DispenserId] = true; //27/03/19 check if job should be stopped REPORT_MSG(DispenserId,"Dispenser stopped pre Segment"); } diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index f5e012a1e..8f9246f8f 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -673,11 +673,11 @@ uint32_t ScrewDTSCallback(uint32_t deviceID, uint32_t BusyFlag) //move the cart to the edge so the spool can be easily replaced //MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, 1000, GPI_LS_SCREW_RIGHT, NULL,0); //MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, WinderDistanceToSpoolEnded,2000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, WinderDistanceToSpoolEnded,4000); #ifdef FOUR_WINDERS - MotorMovetoLimitSwitch (SCREW_2_Motor,MotorsCfg[SCREW_2_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE2_2, NULL,2000); - MotorMovetoLimitSwitch (SCREW_3_Motor,MotorsCfg[SCREW_3_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE1_2, NULL,2000); - MotorMovetoLimitSwitch (SCREW_4_Motor,MotorsCfg[SCREW_4_Motor].directionthreadwize, ScrewSpeed, GPI_LS_RDANCER_UP, NULL,2000); + MotorMovetoLimitSwitch (SCREW_2_Motor,MotorsCfg[SCREW_2_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE2_2, NULL,4000); + MotorMovetoLimitSwitch (SCREW_3_Motor,MotorsCfg[SCREW_3_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE1_2, NULL,4000); + MotorMovetoLimitSwitch (SCREW_4_Motor,MotorsCfg[SCREW_4_Motor].directionthreadwize, ScrewSpeed, GPI_LS_RDANCER_UP, NULL,4000); #endif return OK; @@ -686,8 +686,8 @@ uint32_t WinderDistanceToSpoolState(void ) { double DTS_Time = (dryerbufferCentimeters/dyeingspeed)*1000;//distance to spool time in milliseconds double WinderBackTimeBySpeed = WinderBackToBaseTime; - WinderBackTimeBySpeed /= 50; - WinderBackTimeBySpeed *= dyeingspeed; + WinderBackTimeBySpeed *= 50; + WinderBackTimeBySpeed /= dyeingspeed; REPORT_MSG ((int)DTS_Time,"WinderDistanceToSpoolState"); ScrewDTSControlId = AddControlCallback("screw DTS",ScrewDTSCallback, DTS_Time-WinderBackTimeBySpeed,TemplateDataReadCBFunction,0,0,0); -- cgit v1.3.1 From 8cf2490a30fd21959cea4baa0afc9cdced434593 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Thu, 10 Dec 2020 00:06:49 +0200 Subject: file handling --- .../Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c | 13 +++++++++---- Software/Embedded_SW/Embedded/Common/report/reportInit.c | 2 ++ .../Embedded/Modules/General/GeneralHardware.c | 5 +++-- .../Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c | 15 +++++++++------ .../Embedded/StateMachines/Printing/PrintingSTM.c | 4 ++-- 5 files changed, 25 insertions(+), 14 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index f3d42b01a..a59a14dcf 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -794,8 +794,11 @@ FRESULT FileWrite(void * buffer, uint16_t size,char *path, uint32_t timeout) { LOG_ERROR (Fresult,"fwrite error"); } - //LOG_ERROR (Bytes,"f_write ok no of bytes"); - Report("f_write ok no of bytes", __FILE__, __LINE__, Bytes, RpWarning, (int)size, 0); + else + { + //LOG_ERROR (Bytes,"f_write ok no of bytes"); + Report("f_write ok no of bytes", __FILE__, __LINE__, Bytes, RpWarning, (int)size, 0); + } f_close(FileHandle); } else @@ -875,12 +878,14 @@ FRESULT FileRead(char *path, uint32_t *Size, void **Buffer) } else { - LOG_ERROR (Fresult,"malloc error"); + Report("malloc error", __FILE__, __LINE__, Fresult, RpWarning, (int)fno->fsize, 0); + Fresult = FR_DENIED; } } else { - LOG_ERROR (Fresult,"f_stat error"); + Report("f_stat error", __FILE__, __LINE__, Fresult, RpWarning, (int)0, 0); + Fresult = FR_DENIED; } my_free(fno); return Fresult; diff --git a/Software/Embedded_SW/Embedded/Common/report/reportInit.c b/Software/Embedded_SW/Embedded/Common/report/reportInit.c index a11f9db73..633b8ca34 100644 --- a/Software/Embedded_SW/Embedded/Common/report/reportInit.c +++ b/Software/Embedded_SW/Embedded/Common/report/reportInit.c @@ -134,6 +134,8 @@ uint32_t LogToFile(char *message, /* The formatted message len = usnprintf(RepMessage, 300, "\r\nfile %s\t line %d\t code %d\t sev %d,\tparam %d,\t %s",FileName, LineNumber,errorCode, Severity, parameter,message); LogFresult = f_write(LogFileHandle,RepMessage,len,&Bytes ); + if (LogFileHandle->fsize > 100000) + f_lseek(LogFileHandle, 0); return LogFresult; } diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 7b4a30dd2..010fc9607 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -220,7 +220,7 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) EmbeddedParameters->has_initialdispenserpressure = true; EmbeddedParameters->initialdispenserpressure=3.85; EmbeddedParameters->has_initialdispensertimeout = true; - EmbeddedParameters->initialdispensertimeout=120000.0 ; + EmbeddedParameters->initialdispensertimeout=119999.0 ; EmbeddedParameters->has_initialdispensertimelag = true; EmbeddedParameters->initialdispensertimelag=100.0 ; @@ -229,7 +229,7 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) EmbeddedParameters->has_dispenserbuildpressurelimit = true; EmbeddedParameters->dispenserbuildpressurelimit=1.0 ; EmbeddedParameters->has_dispenserbuildpressuretimeout = true; - EmbeddedParameters->dispenserbuildpressuretimeout=150000; + EmbeddedParameters->dispenserbuildpressuretimeout=419999.0; EmbeddedParameters->has_dispenserbuildpressurelag = true; EmbeddedParameters->dispenserbuildpressurelag=50; @@ -297,6 +297,7 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) EmbeddedParameters->powerofftemperaturelimit = 90; EmbeddedParameters->has_ids_presegment_wfcf_timebeforesegment = true; EmbeddedParameters->ids_presegment_wfcf_timebeforesegment = 20000; + EmbeddedParameters->description = "default embedded parameters"; uint8_t* response_buffer = my_malloc(configuration_parameters__get_packed_size(EmbeddedParameters)); if (response_buffer) diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 8f9246f8f..03bc9d24d 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -50,6 +50,7 @@ bool WinderMotorSpeedRollOver = false; int StartWinderCalculation = 0; #define DEFAULT_SCREW_SPEED 1200 double ScrewSpeed = DEFAULT_SCREW_SPEED; +double RetreatTime = 0; double ScrewRunningTime = 0; uint32_t ScrewNumberOfSteps = 0; //holds the current number of steps for the next screw run - will be used to build the cone bool SCREW_TimerActivated = false; @@ -635,6 +636,7 @@ uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId) temp *= ScrewNumberOfSteps; temp /= ScrewSpeed; ScrewRunningTime = temp;//(SYS_CLK_FREQ*InternalWinderCfg.segmentoffsetpulses)/ScrewSpeed; + RetreatTime = ScrewNumberOfSteps*1000/ScrewSpeed; REPORT_MSG((int)ScrewNumberOfSteps,"Winder pre segment - ScrewNumberOfSteps"); REPORT_MSG((int)ScrewRunningTime,"Winder pre segment - ScrewRunningTime"); //MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection); @@ -673,11 +675,11 @@ uint32_t ScrewDTSCallback(uint32_t deviceID, uint32_t BusyFlag) //move the cart to the edge so the spool can be easily replaced //MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, 1000, GPI_LS_SCREW_RIGHT, NULL,0); //MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, WinderDistanceToSpoolEnded,4000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, WinderDistanceToSpoolEnded,RetreatTime*2); #ifdef FOUR_WINDERS - MotorMovetoLimitSwitch (SCREW_2_Motor,MotorsCfg[SCREW_2_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE2_2, NULL,4000); - MotorMovetoLimitSwitch (SCREW_3_Motor,MotorsCfg[SCREW_3_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE1_2, NULL,4000); - MotorMovetoLimitSwitch (SCREW_4_Motor,MotorsCfg[SCREW_4_Motor].directionthreadwize, ScrewSpeed, GPI_LS_RDANCER_UP, NULL,4000); + MotorMovetoLimitSwitch (SCREW_2_Motor,MotorsCfg[SCREW_2_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE2_2, NULL,RetreatTime*2); + MotorMovetoLimitSwitch (SCREW_3_Motor,MotorsCfg[SCREW_3_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE1_2, NULL,RetreatTime*2); + MotorMovetoLimitSwitch (SCREW_4_Motor,MotorsCfg[SCREW_4_Motor].directionthreadwize, ScrewSpeed, GPI_LS_RDANCER_UP, NULL,RetreatTime*2); #endif return OK; @@ -688,9 +690,10 @@ uint32_t WinderDistanceToSpoolState(void ) double WinderBackTimeBySpeed = WinderBackToBaseTime; WinderBackTimeBySpeed *= 50; WinderBackTimeBySpeed /= dyeingspeed; - REPORT_MSG ((int)DTS_Time,"WinderDistanceToSpoolState"); + Report("WinderDistanceToSpoolState start", __FILE__,DTS_Time,RetreatTime, RpMessage, (int)WinderBackTimeBySpeed, 0); + //REPORT_MSG ((int)DTS_Time,"WinderDistanceToSpoolState"); - ScrewDTSControlId = AddControlCallback("screw DTS",ScrewDTSCallback, DTS_Time-WinderBackTimeBySpeed,TemplateDataReadCBFunction,0,0,0); + ScrewDTSControlId = AddControlCallback("screw DTS",ScrewDTSCallback, DTS_Time-RetreatTime,TemplateDataReadCBFunction,0,0,0); Report("ScrewDTSCallback start", __FILE__,DTS_Time,msec_millisecondCounter, RpMessage, (int)WinderBackTimeBySpeed, 0); return OK; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c index 3e790eabe..cb0703f27 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c @@ -203,7 +203,7 @@ JobDescriptionFileSegment *GetNextSegmentFromJobFile() }//segment malloc else { - LOG_ERROR (SegmentPtr, "malloc error"); + LOG_ERROR (SegmentSize, "malloc error"); //status = ERROR; } }//segment read size @@ -270,7 +270,7 @@ JobDescriptionFileBrushStop *GetNextBrushStopFromJobFile() }//brushstop size read ok else { - LOG_ERROR (BrushStopPtr, "malloc error"); + Report("malloc error", __FILE__, __LINE__, BrushStopSize, RpWarning, (int)0, 0); //status = ERROR; } }// if brush stop count -- cgit v1.3.1 From 9bbfc1a62c8177ea2d1122b6564d6e8b219f1f47 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 15 Dec 2020 23:17:54 +0200 Subject: small fixes over 1.5.3.4 --- .../Embedded/Common/SWUpdate/FileSystem.c | 14 +---- Software/Embedded_SW/Embedded/DataDef.h | 2 + .../Embedded/Drivers/Flash_Memory/FATFS/ff.c | 70 ++++++++++++++++++---- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 6 +- .../Embedded/Modules/Heaters/Heaters_print.c | 2 + Software/Embedded_SW/Embedded/Modules/IDS/IDS.h | 2 + .../Embedded_SW/Embedded/Modules/IDS/IDS_maint.c | 20 +++++-- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 9 ++- .../Embedded/Modules/Thread/Thread_print.c | 10 +++- .../StateMachines/Initialization/InitSequence.c | 12 ++-- .../Embedded/StateMachines/Printing/PrintingSTM.c | 4 +- 11 files changed, 112 insertions(+), 39 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index a59a14dcf..17c1f164b 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -566,20 +566,12 @@ uint32_t DeleteRequestFunc(MessageContainer* requestContainer) //int NumOfFiles = 0; FRESULT Fresult = FR_OK; - if (1)//(Semaphore_pend(FFS_Sem, BIOS_NO_WAIT)) - { - Fresult = f_unlink(request->path); - Semaphore_post(FFS_Sem); - } - else - { - Fresult = FR_DENIED; - Report("Semaphore_pend failed", __FILE__, __LINE__, 4, RpWarning, (int)0, 0); - } + Fresult = f_unlink(request->path); + Semaphore_post(FFS_Sem); REPORT_MSG(Fresult, "File Delete"); responseContainer = createContainer(MESSAGE_TYPE__DeleteResponse, requestContainer->token, false, &response, &delete_response__pack, &delete_response__get_packed_size); - if (Fresult!= OK) + if ((Fresult!= FR_OK)&&(Fresult!= FR_NO_FILE)) { //usnprintf(ErrorMsg, 100, "File Operation failed error code %d",Fresult); responseContainer.has_error = true; diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index 291c94e9d..c29f34c62 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -32,7 +32,9 @@ #ifdef FOUR_WINDERS #define BTSR_NO_FEEDER_TFU #define BTSR_NO_PULLER_TFU +#define BTSR_ROTATED_WINDER_TFU #endif +//#define BTSR_ROTATED_WINDER_TFU //#define USE_RFID_STUB //stub only. to use it undef USE_RFID_LOGIC //#define RFID_READ_ONLY // diff --git a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/ff.c b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/ff.c index 66f209421..632dfb0d5 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/ff.c +++ b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/ff.c @@ -98,7 +98,9 @@ #include "ff.h" /* FatFs configurations and declarations */ //#include "diskio.h" /* Declarations of low level disk I/O functions */ +#include #include "third_party/fatfs/src/diskio.h" +#include "Common/report/report.h" /*-------------------------------------------------------------------------- @@ -894,7 +896,10 @@ FRESULT put_fat ( if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; + { + res = FR_INT_ERR; + Report("put_fat FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->n_fatent,0); + } } else { switch (fs->fs_type) { @@ -929,6 +934,8 @@ FRESULT put_fat ( default : res = FR_INT_ERR; + Report("put_fat FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->fs_type,0); + } fs->wflag = 1; } @@ -958,13 +965,16 @@ FRESULT remove_chain ( if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ res = FR_INT_ERR; - + Report("remove_chain FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->n_fatent,0); } else { res = FR_OK; while (clst < fs->n_fatent) { /* Not a last link? */ nxt = get_fat(fs, clst); /* Get cluster status */ if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ + if (nxt == 1) { + res = FR_INT_ERR; + Report("remove_chain FR_INT_ERR",__FILE__,__LINE__,(int)res,RpWarning,(int)fs->n_fatent,0); + break; } /* Internal error? */ if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ if (res != FR_OK) break; @@ -1097,14 +1107,20 @@ FRESULT dir_sdi ( dj->index = idx; clst = dj->sclust; if (clst == 1 || clst >= dj->fs->n_fatent) /* Check start cluster range */ + { + Report("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)dj->fs->n_fatent,0); return FR_INT_ERR; + } if (!clst && dj->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ clst = dj->fs->dirbase; if (clst == 0) { /* Static table (root-dir in FAT12/16) */ dj->clust = clst; if (idx >= dj->fs->n_rootdir) /* Index is out of range */ - return FR_INT_ERR; + { + Report("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)idx,RpWarning,(int)dj->fs->n_rootdir,0); + return FR_INT_ERR; + } dj->sect = dj->fs->dirbase + idx / (SS(dj->fs) / SZ_DIR); /* Sector# */ } else { /* Dynamic table (sub-dirs or root-dir in FAT32) */ @@ -1113,7 +1129,10 @@ FRESULT dir_sdi ( clst = get_fat(dj->fs, clst); /* Get next cluster */ if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ if (clst < 2 || clst >= dj->fs->n_fatent) /* Reached to end of table or int error */ + { + Report("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)dj->fs->n_fatent,0); return FR_INT_ERR; + } idx -= ic; } dj->clust = clst; @@ -2558,7 +2577,10 @@ FRESULT f_write ( res = validate(fp); /* Check validity */ if (res != FR_OK) LEAVE_FF(fp->fs, res); if (fp->flag & FA__ERROR) /* Aborted file? */ + { + Report("f_write FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)btw,0); LEAVE_FF(fp->fs, FR_INT_ERR); + } if (!(fp->flag & FA_WRITE)) /* Check access mode */ LEAVE_FF(fp->fs, FR_DENIED); if ((DWORD)(fp->fsize + btw) < fp->fsize) btw = 0; /* File size cannot reach 4GB */ @@ -2596,7 +2618,11 @@ FRESULT f_write ( } #endif sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); + if (!sect) + { + Report("f_write FR_INT_ERR",__FILE__,__LINE__,(int)sect,RpWarning,(int)btw,0); + ABORT(fp->fs, FR_INT_ERR); + } sect += csect; cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ if (cc) { /* Write maximum contiguous sectors directly */ @@ -2886,7 +2912,10 @@ FRESULT f_lseek ( res = validate(fp); /* Check validity of the object */ if (res != FR_OK) LEAVE_FF(fp->fs, res); if (fp->flag & FA__ERROR) /* Check abort flag */ + { + Report("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)FA__ERROR,0); LEAVE_FF(fp->fs, FR_INT_ERR); + } #if _USE_FASTSEEK if (fp->cltbl) { /* Fast seek */ @@ -2969,7 +2998,11 @@ FRESULT f_lseek ( #if !_FS_READONLY if (clst == 0) { /* If no cluster chain, create a new chain */ clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); + if (clst == 1) + { + Report("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)FA__ERROR,0); + ABORT(fp->fs, FR_INT_ERR); + } if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); fp->sclust = clst; } @@ -2988,7 +3021,11 @@ FRESULT f_lseek ( #endif clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); + if (clst <= 1 || clst >= fp->fs->n_fatent) + { + Report("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fp->fs->n_fatent,0); + ABORT(fp->fs, FR_INT_ERR); + } fp->clust = clst; fp->fptr += bcs; ofs -= bcs; @@ -2996,7 +3033,11 @@ FRESULT f_lseek ( fp->fptr += ofs; if (ofs % SS(fp->fs)) { nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); + if (!nsect) + { + Report("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)nsect,RpWarning,(int)0,0); + ABORT(fp->fs, FR_INT_ERR); + } nsect += ofs / SS(fp->fs); } } @@ -3184,7 +3225,10 @@ FRESULT f_getfree ( do { stat = get_fat(fs, clst); if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } + if (stat == 1) + { + Report("f_getfree FR_INT_ERR",__FILE__,__LINE__,(int)stat,RpWarning,(int)0,0); + res = FR_INT_ERR; break; } if (stat == 0) n++; } while (++clst < fs->n_fatent); } else { @@ -3233,6 +3277,7 @@ FRESULT f_truncate ( res = validate(fp); /* Check validity of the object */ if (res == FR_OK) { if (fp->flag & FA__ERROR) { /* Check abort flag */ + Report("f_truncate FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)0,0); res = FR_INT_ERR; } else { if (!(fp->flag & FA_WRITE)) /* Check access mode */ @@ -3250,7 +3295,11 @@ FRESULT f_truncate ( ncl = get_fat(fp->fs, fp->clust); res = FR_OK; if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; + if (ncl == 1) + { + Report("f_truncate FR_INT_ERR",__FILE__,__LINE__,(int)ncl,RpWarning,(int)0,0); + res = FR_INT_ERR; + } if (res == FR_OK && ncl < fp->fs->n_fatent) { res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); if (res == FR_OK) res = remove_chain(fp->fs, ncl); @@ -3301,6 +3350,7 @@ FRESULT f_unlink ( dclst = ld_clust(dj.fs, dir); if (res == FR_OK && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-dir? */ if (dclst < 2) { + Report("f_unlink FR_INT_ERR",__FILE__,__LINE__,(int)dclst,RpWarning,(int)0,0); res = FR_INT_ERR; } else { mem_cpy(&sdj, &dj, sizeof (DIR)); /* Check if the sub-dir is empty or not */ diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index db4535e06..07ebfa747 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -638,10 +638,10 @@ JobEndReasonEnum getEndReason(uint32_t AlarmId) return JOB_TEMPERATURE_ALARM; } case ALARM_SOURCE_TYPE__LimitSwitchAlarm: - usnprintf(AlarmReasonStr, 100, "Dispenser %d empty",AlarmItem[AlarmId].DeviceId); + usnprintf(AlarmReasonStr, 100, "Dispenser %d empty",AlarmItem[AlarmId].DeviceId+1); return JOB_OUT_OF_DYE; case ALARM_SOURCE_TYPE__PressureAlarm: - usnprintf(AlarmReasonStr, 100, "Over pressure in dispenser %d",AlarmItem[AlarmId].DeviceId); + usnprintf(AlarmReasonStr, 100, "Over pressure in dispenser %d",AlarmItem[AlarmId].DeviceId+1); return JOB_PRESSURE_ALARM; case ALARM_SOURCE_TYPE__CurrentAlarm: usnprintf(AlarmReasonStr, 100, "over/under current (%d) in %d",AlarmId,AlarmItem[AlarmId].DeviceId); @@ -653,7 +653,7 @@ JobEndReasonEnum getEndReason(uint32_t AlarmId) usnprintf(AlarmReasonStr, 100, "Machine door %d removed during a run",AlarmItem[AlarmId].DeviceId); return JOB_TAMPER_ALARM; case ALARM_SOURCE_TYPE__HardLimitAlarm: - usnprintf(AlarmReasonStr, 100, "Dispenser %d hit the hard limit",AlarmItem[AlarmId].DeviceId); + usnprintf(AlarmReasonStr, 100, "Dispenser %d hit the hard limit",AlarmItem[AlarmId].DeviceId+1); return JOB_LS_ALARM; case ALARM_SOURCE_TYPE__DoNotPollAlarm: if (AlarmItem[AlarmId].Severity == DEBUG_LOG_CATEGORY__Critical) diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index f396d78d9..db7261090 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -1012,6 +1012,8 @@ void HeaterPrepareFailureCheck(void) HeaterPrepareFailureCheckCounter = 0; return; } + if (HeaterPrepareFailureCheckCounter%60 == 0) + ReportWithPackageFilter(HeatersFilter,"HeaterPrepareFailureCheck",__FILE__,HeaterPrepareFailureCheckCounter,GetHeatersPrepareWaiting(),RpWarning,HeaterCheckReady(), 0); if ((HeaterPrepareFailureCheckCounter>=300)&&(HeaterPrepareFailureCheckCounter%60 == 0)) { for (i = 0; i