diff options
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
| -rw-r--r-- | Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index a91781ce4..abfdd2237 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -44,26 +44,28 @@ #include "PMR/ThreadLoading/StartThreadLoadingResponse.pb-c.h" #include "PMR/ThreadLoading/ContinueThreadLoadingRequest.pb-c.h" #include "PMR/ThreadLoading/ContinueThreadLoadingResponse.pb-c.h" +#include "PMR/ThreadLoading/TryThreadLoadingRequest.pb-c.h" +#include "PMR/ThreadLoading/TryThreadLoadingResponse.pb-c.h" #include "PMR/ThreadLoading/StopThreadLoadingRequest.pb-c.h" #include "PMR/ThreadLoading/StopThreadLoadingResponse.pb-c.h" //#include <stdint.h> //#include <stdbool.h> static char* LoadStagesStr[15] = { - /*00*/ "INIT", - /*01*/ "REDUCE_HEAT", - /*02*/ "LIFT_ROCKERS", - /*03*/ "SET_LOAD_ARM", - /*04*/ "OPEN_COVERS", - /*05*/ "LIFT_DANCERS", - /*06*/ "INITIAL_TENSION", - /*07*/ "CLOSE_ROCKERS", - /*08*/ "CLOSE_DANCERS", - /*09*/ "CLOSE_LIDS", - /*10*/ "JOG_FEEDER", - /*11*/ "DRYER_LOADING", - /*12*/ "RESUME_HEATING", - /*13*/ "JOG_THREAD" , + /*00*/ "Initialization", + /*01*/ "heating stop", + /*02*/ "Rockers opening", + /*03*/ "Drier unloading", + /*04*/ "Lids opening", + /*05*/ "Dancers opening", + /*06*/ "Initial tension building", + /*07*/ "Rockers closing", + /*08*/ "Dancers closing", + /*09*/ "Lids closing", + /*10*/ "Feeder jogging", + /*11*/ "Drier loading", + /*12*/ "Heating resuming", + /*13*/ "Thread jogging" , /*14*/ "END"}; /* typedef enum @@ -284,7 +286,7 @@ { TimeoutsCounter = 0; load.color = fastBILNK; - usnprintf(LoadErrorMsg, 100, "Load sequence timeout %s motor %d",LoadStagesStr[LoadStages], MotorId); + usnprintf(LoadErrorMsg, 100, "Stage %s - motor %s timeout",LoadStagesStr[LoadStages], MotorStr[MotorId]); Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0); LoadStatus = ERROR; @@ -493,7 +495,7 @@ if (HandleProcessParameters(&ProcessParametersRecover,false)!= OK) { - usnprintf(LoadErrorMsg, 100, "Load sequence error %d",LoadStagesStr[LoadStages]); + usnprintf(LoadErrorMsg, 100, "Stage %s error",LoadStagesStr[LoadStages]); Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0); } else @@ -617,8 +619,9 @@ Report("Store Number of cycles in drier - halted",__FILE__,__LINE__,numberOfCycles,RpMessage,LoadArmRounds,0); MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,numberOfCycles); TimeoutsCounter = 0; + CallbackCounter = 0; load.color = fastBILNK; - usnprintf(LoadErrorMsg, 100, "Load sequence timeout %s motor %d",LoadStagesStr[LoadStages], HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM); + usnprintf(LoadErrorMsg, 100, "Stage %s - Drier load arm timeout",LoadStagesStr[LoadStages]); Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0); LoadStatus = ERROR; MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, 200); @@ -834,7 +837,7 @@ MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,Hard_Hiz); MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Hard_Stop); load.color = fastBILNK; - usnprintf(LoadErrorMsg, 100, "Load sequence timeout %s motor %d",LoadStagesStr[LoadStages], HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM); + usnprintf(LoadErrorMsg, 100, "Stage %s - Drier load arm timeout",LoadStagesStr[LoadStages]); Report(LoadErrorMsg,__FILE__,__LINE__,LoadStages,RpWarning,TimeoutsCounter,0); Report("Drier unloading timeout(1) or no movement",__FILE__,temp,DrierPrevLocation,RpWarning,ReadValue,0); LoadStatus = ERROR; @@ -950,6 +953,8 @@ { REPORT_MSG(ReadValue,"ThreadLoadStateMachine"); ThreadLoaded(); + ThreadLoadingReport(); + if (LoadStages!=ReadValue) LoadStages = ReadValue; switch (ReadValue) @@ -1038,6 +1043,7 @@ LOG_ERROR(LoadStages,"ERROR IN LOAD STATE MACHINE"); break; } + return OK; } uint32_t ThreadLoadButton(THREAD_LOAD_STAGES_ENUM ReadValue) @@ -1054,6 +1060,7 @@ uint32_t ThreadLoadButton(THREAD_LOAD_STAGES_ENUM ReadValue) } Report("ThreadLoadButton",__FILE__,__LINE__,LoadStages,RpMessage,ReadValue,0); Report("ThreadLoadButton params",__FILE__,LoadStatus,TryAgain,RpMessage,SecondTry,0); + ThreadLoadingReport(); if (LoadStatus == ERROR) { if ((SecondTry == false)&&(TryAgain == true)) @@ -1387,6 +1394,25 @@ uint32_t ThreadLoadingReport(void) } +uint32_t TryThreadLoadingFunc(MessageContainer* requestContainer) +{ + TryThreadLoadingRequest *request = continue_thread_loading_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + TryThreadLoadingResponse Cresponse = TRY_THREAD_LOADING_RESPONSE__INIT; + MessageContainer responseContainer; + MessageState = 2; + ThreadLoadingReport(); + Report("TryThreadLoadingFunc",__FILE__,__LINE__,MESSAGE_TYPE__TryThreadLoadingResponse,RpWarning,(int)LoadStages,0); + + responseContainer = createContainer(MESSAGE_TYPE__TryThreadLoadingResponse, requestContainer->token, true, &Cresponse, &try_thread_loading_response__pack, &try_thread_loading_response__get_packed_size); + responseContainer.continuous = false; + 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); + SendChars((char*)container_buffer, container_size); + + ThreadLoadButton(LoadStages); + return OK; +} uint32_t StartThreadLoadingFunc(MessageContainer* requestContainer) { StartThreadLoadingRequest *request = start_thread_loading_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); |
