diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-12-18 09:00:24 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-12-18 09:00:24 +0200 |
| commit | 1b92f30f6dfa27392ffd8460ebeb17c17550db7b (patch) | |
| tree | 5bfafc883cbed960766b4455f024f208f1f76375 /Software/Embedded_SW/Embedded/Modules | |
| parent | e1ef835095c9a6f98c8b15fedc585e2caf77ecd6 (diff) | |
| download | Tango-1b92f30f6dfa27392ffd8460ebeb17c17550db7b.tar.gz Tango-1b92f30f6dfa27392ffd8460ebeb17c17550db7b.zip | |
version 1.4.6.1 PMR: thread load and power down reporting. fix USB driver large files bug. ids pressure relief. some looking into the thread load sequence
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules')
9 files changed, 226 insertions, 39 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index 93246979b..eea72d6b5 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -72,7 +72,6 @@ uint8_t alarm_response_buffer[500]; /******************** Functions ********************************************/ void SendEventNotifications(void); -//uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Read); //********************************************************************** typedef enum { diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 76b7aa7a1..b5fff9340 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -113,7 +113,6 @@ static GateMutex_Handle gateMillisecDB; uint32_t Millisec_timerBase = TIMER1_BASE; //Timer handle /******************** Functions ********************************************/ -uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Read); void CalculateVOCAlarms(void); //********************************************************************** /******************** CODE ********************************************/ diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index b60fb3aa4..b75e44001 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -53,9 +53,11 @@ #include "drivers/adc_sampling/adc.h" #include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" +#include "drivers/FPGA/FPGA_SPI_Comm.h" #include "Modules/General/buttons.h" #include "Modules/General/GeneralHardware.h" +#include "Modules/AlarmHandling/AlarmHandling.h" #include "StateMachines/Printing/PrintingSTM.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 4c373bb54..6b2cf0021 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -140,7 +140,6 @@ bool blowervolatgedisplay = false; bool midtankDisplay = false; double diagvoltage = 0; /******************** Functions ********************************************/ -//uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Read); //********************************************************************** typedef enum { @@ -256,7 +255,7 @@ void DiagnosticLoadMotor(int MotorId, int frequency) { if (MotorId >= MAX_THREAD_MOTORS_NUM) { - LOG_ERROR(MotorId,"wrong Heater Id"); + ReportWithPackageFilter(DiagnosticsFilter,"wrong Motor Id",__FILE__,__LINE__,(int)MotorId,RpError,(int)0,0); return; } @@ -332,7 +331,7 @@ void DiagnosticLoadTemperature(int HeaterId, int temperature) double temp = temperature; if (HeaterId >= HEATER_TYPE_MAX_HEATERS) { - LOG_ERROR(HeaterId,"wrong Heater Id"); + ReportWithPackageFilter(DiagnosticsFilter,"wrong Heater Id",__FILE__,__LINE__,(int)HeaterId,RpError,(int)0,0); return; } if ((temperature < 1000)||(temperature>28000)) //error read, all 0xF or all 0 @@ -357,7 +356,7 @@ void DiagnosticLoadDancer(int DancerId, uint16_t value) { if (DancerId >= NUM_OF_DANCERS) { - LOG_ERROR(DancerId,"wrong Dancer Id"); + ReportWithPackageFilter(DiagnosticsFilter,"wrong Dancer Id",__FILE__,__LINE__,(int)DancerId,RpError,(int)0,0); return; } DancerValue[DancerId][DancerCounterIndex[DancerId]] = value; @@ -370,7 +369,7 @@ void DiagnosticLoadDancerError(int DancerId, double value) { if (DancerId >= NUM_OF_DANCERS) { - LOG_ERROR(DancerId,"wrong Dancer Id"); + ReportWithPackageFilter(DiagnosticsFilter,"wrong Dancer Id",__FILE__,__LINE__,(int)DancerId,RpError,(int)0,0); return; } DancerErrorValue[DancerId][DancerErrorCounterIndex[DancerId]] = value; @@ -871,20 +870,20 @@ void SendDiagnostics(void) } else { - LOG_ERROR(Task_self(),"my_malloc failed"); + ReportWithPackageFilter(DiagnosticsFilter,"my_malloc failed, DiagnosticsStop ",__FILE__,__LINE__,(int)Task_self(),RpError,(int)0,0); DiagnosticsStop(); //CommunicationMailboxFlush(); } } else { - LOG_ERROR(Task_self(),"previous packet not sent"); + ReportWithPackageFilter(DiagnosticsFilter,"previous packet not sent",__FILE__,__LINE__,(int)Task_self(),RpError,(int)0,0); } //my_free(diagnosticsresponseContainer.data.data); } else { - LOG_ERROR(Task_self(),"my_malloc failed"); + ReportWithPackageFilter(DiagnosticsFilter,"my_malloc failed, DiagnosticsStop ",__FILE__,__LINE__,(int)Task_self(),RpError,(int)0,0); DiagnosticsStop(); } DiagnosticsReset(); @@ -905,19 +904,19 @@ uint32_t DiagnosticsStart(void) if (DiagnosticsControlId == 0xFF) DiagnosticsControlId = AddControlCallback(NULL,Diagnostics_ControlTrigger,DiagnosticLimit,TemplateDataReadCBFunction,0,0,0); else - LOG_ERROR(DiagnosticsControlId,"Diagnostics restarted"); + ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics restarted ",__FILE__,__LINE__,(int)DiagnosticLimit,RpWarning,(int)DiagnosticsControlId,0); if (Diagnostics10MSControlId == 0xFF) Diagnostics10MSControlId = AddControlCallback(NULL,Diagnostics_TenMiliControlTrigger,DiagnosticFastLimit,TemplateDataReadCBFunction,0,0,0); else - LOG_ERROR(DiagnosticsControlId,"Diagnostics restarted"); + ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics restarted ",__FILE__,__LINE__,(int)DiagnosticFastLimit,RpWarning,(int)Diagnostics10MSControlId,0); if (Diagnostics1SecControlId == 0xFF) Diagnostics1SecControlId = AddControlCallback(NULL,Diagnostics_OneSecControlTrigger,eOneSecond,TemplateDataReadCBFunction,0,0,0); else - LOG_ERROR(Diagnostics1SecControlId,"Diagnostics restarted"); + ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics restarted ",__FILE__,__LINE__,(int)eOneSecond,RpWarning,(int)Diagnostics1SecControlId,0); if (Diagnostics1MinControlId == 0xFF) Diagnostics1MinControlId = AddControlCallback(NULL,Diagnostics_OneMinControlTrigger,eOneMinute,TemplateDataReadCBFunction,0,0,0); else - LOG_ERROR(Diagnostics1MinControlId,"Diagnostics restarted"); + ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics restarted ",__FILE__,__LINE__,(int)eOneMinute,RpWarning,(int)Diagnostics1MinControlId,0); } } diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c index 0e28ec736..c49fd81f0 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c @@ -509,7 +509,8 @@ uint32_t IDS_Check_Pressure_Callback(uint32_t DispenserId, uint32_t ReadValue) if (GetDispenserPressure(DispenserId)>3.0) { Report("Pulling dispenser down to reduce pressure",__FILE__,DispenserId,(int)(GetDispenserPressure(DispenserId)*100),RpWarning,200,0); - MotorMove(HW_Motor_Id,1-MotorsCfg[HW_Motor_Id].directionthreadwize,200); + + MotorMove(HW_Motor_Id,1-MotorsCfg[HW_Motor_Id].directionthreadwize,200*MotorsCfg[HW_Motor_Id].microstep); } return OK; } @@ -525,6 +526,6 @@ void IDS_Dispenser_Init(uint8_t DispenserId) Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF); Control3WayValvesWithCallback ((Valves_t)DispenserId, MidTank_Dispenser, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer if (ControlIdtoInactiveDispenserId[DispenserId] == 0xFF) - ControlIdtoInactiveDispenserId[DispenserId] = AddControlCallback("IDS_Check_Pressure", IDS_Check_Pressure_Callback, eOneMinute,TemplateDataReadCBFunction ,0, 0, 0 ); + ControlIdtoInactiveDispenserId[DispenserId] = AddControlCallback("IDS_Check_Pressure", IDS_Check_Pressure_Callback, eOneMinute,TemplateDataReadCBFunction ,DispenserId, 0, 0 ); } diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h index 56fb79c23..d1d23598f 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h @@ -82,6 +82,7 @@ void SetKeepWindingCone(bool value); void SetWinderBackToBaseTime(uint32_t value); uint32_t DancerConfigMessage(HardwareDancer * request); +uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Read); void SetOriginMotorSpeed(float process_speed); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 852c19a1a..aeacde455 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -36,6 +36,10 @@ #include "PMR/Stubs/StubHeatingTestResponse.pb-c.h" #include "PMR/Stubs/StubHeatingTestPollRequest.pb-c.h" #include "PMR/Stubs/StubHeatingTestPollResponse.pb-c.h" +#include "PMR/ThreadLoading/StartThreadLoadingRequest.pb-c.h" +#include "PMR/ThreadLoading/StartThreadLoadingResponse.pb-c.h" +#include "PMR/ThreadLoading/ContinueThreadLoadingRequest.pb-c.h" +#include "PMR/ThreadLoading/ContinueThreadLoadingResponse.pb-c.h" //#include <stdint.h> //#include <stdbool.h> @@ -62,6 +66,8 @@ THREAD_LOAD_STAGES_ENUM LoadStages = THREAD_LOAD_INIT; ProcessParameters ProcessParametersClear,ProcessParametersRecover; + uint32_t LoadStatus = OK; + char LoadErrorMsg[100]; int32_t keepmicrostep; int32_t keepkvalrun,keepkvalhold; uint8_t CallbackCounter = 0; @@ -70,10 +76,16 @@ uint32_t UnloadingStart = 0; uint8_t NumberOfDrierLoaderCycles = 0; uint32_t status = OK; - uint32_t LoadingControlId = 0xFF,PullerControlId = 0xFF,WinderControlId = 0xFF; + uint32_t LoadingControlId = 0xFF,PullerControlId = 0xFF,WinderControlId = 0xFF, SpeedTControlId = 0xFF; + uint32_t previousPosition = 0, currentPosition = 0,Tinitialpos = 0xFFFF; + uint32_t LoadCounter = 0; + double TotalProcessedLen = 0.0; + double LengthCalculationMultiplier; uint32_t ThreadLoadStateMachine( THREAD_LOAD_STAGES_ENUM LoadStages); uint32_t ThreadLoadControlCBFunction(uint32_t index, uint32_t ReadValue); + uint32_t ThreadLoadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue); uint32_t Thread_Load_Dryer_UnLoading(void); + uint32_t ThreadLoadingReport(void); typedef struct { @@ -104,13 +116,17 @@ //FRESULT Fresult = FR_OK; REPORT_MSG(LoadStages, "Thread Load State Machine step"); - LoadArmInfo.LoadArmBackLash = 5; + LoadStatus = OK; + LoadArmInfo.LoadArmBackLash = MCU_E2PromDryerBacklashRead(); + REPORT_MSG(LoadArmInfo.LoadArmBackLash, "Thread Load MCU_E2PromDryerBacklashRead"); + if (LoadArmInfo.LoadArmBackLash > 10) + LoadArmInfo.LoadArmBackLash = 5; //LoadArmInfo.LoadArmRounds = 0xFF; //EEPROM_STORAGE_DRYER_CYCLES MCU_E2PromRead(EEPROM_STORAGE_DRYER_CYCLES,&LoadArmInfo.LoadArmRounds); + if (LoadArmInfo.LoadArmRounds <= 2) LoadArmInfo.LoadArmRounds = 20; - MCU_E2PromRead(EEPROM_STORAGE_DRYER_CYCLES,&LoadArmInfo.LoadArmRounds); Report("MotorMovetoEncoderPosition",__FILE__,__LINE__,LoadArmInfo.LoadArmRounds,RpWarning,LoadArmInfo.LoadArmBackLash,0); /*Fresult = f_mkdir(SW_INFO_DIR); @@ -156,6 +172,8 @@ if (HandleProcessParameters(&ProcessParametersClear,false)!= OK) { LOG_ERROR (LoadStages, "Thread_Load_Init failed"); + strcpy(LoadErrorMsg,"Thread_Load_Init failed"); + LoadStatus = ERROR; } else { @@ -294,6 +312,9 @@ LOG_ERROR(LoadStages,"Load sequence timeout"); TimeoutsCounter = 0; load.color = fastBILNK; + usnprintf(LoadErrorMsg, 100, "Load sequence timeout %d motor %d",LoadStages, MotorId); + LoadStatus = ERROR; + ThreadLoadingReport(); } else { @@ -310,6 +331,7 @@ else { load.color = fastBILNK; + ThreadLoadingReport(); } } } @@ -472,6 +494,13 @@ RemoveControlCallback(LoadingControlId, ThreadLoadControlCBFunction ); LoadingControlId = 0xFF; } + if (SpeedTControlId != 0xFF) + { + RemoveControlCallback(SpeedTControlId, ThreadLoadLengthCBFunction ); + SpeedTControlId = 0xFF; + } + Report("Total Feeder load",__FILE__,__LINE__,dryerbufferCentimeters,RpMessage,TotalProcessedLen,0); + if (CallbackCounter) { CallbackCounter--; @@ -546,6 +575,15 @@ LoadingControlId = AddControlCallback(NULL,ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); Report("AddControlCallback feeder",__FILE__,__LINE__,LoadingControlId,RpMessage,IfTypeThread*0x100+FEEDER_MOTOR,0); + if (SpeedTControlId != 0xFF) + { + RemoveControlCallback(SpeedTControlId,ThreadLoadLengthCBFunction); + SpeedTControlId = 0xFF; + } + //SetMotHome(ThreadMotorIdToMotorId[Motor_i]); + LengthCalculationMultiplier = (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].pulleyradius*2*PI)/(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].pulseperround*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].microstep); + SpeedTControlId = AddControlCallback(NULL,ThreadLoadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+HARDWARE_MOTOR_TYPE__MOTO_RDRIVING),HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,0); + Tinitialpos = 0xFFFF;previousPosition = 0; currentPosition = 0; CallbackCounter++; Report("Thread_Load_Dryer_Loading",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize, @@ -596,6 +634,11 @@ RemoveControlCallback(WinderControlId, ThreadLoadControlCBFunction ); WinderControlId = 0xFF; } + if (SpeedTControlId != 0xFF) + { + RemoveControlCallback(SpeedTControlId, ThreadLoadLengthCBFunction ); + SpeedTControlId = 0xFF; + } MotorStopAction(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM); MotorStopAction(HARDWARE_MOTOR_TYPE__MOTO_RLOADING); @@ -673,12 +716,10 @@ // numberOfSteps, Thread_Load_Dryer_Loading_Callback, 100000); UnloadingStart = msec_millisecondCounter; Report("Thread_Load_Set_Load_Arm_To_Start_Position",__FILE__,UnloadingStart,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); - LoadArmInfo.LoadArmBackLash = 5; status |= MotorMoveToStopper(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize), MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/2, Thread_Load_Set_Load_Arm_To_Stopper_Callback,LoadArmInfo.LoadArmBackLash,1000); //Keep Notation How Many Rotations In The Dryer - //LoadArmInfo.LoadArmBackLash = 0; LoadArmInfo.LoadArmRounds = (int)dryerbufferlength; load.color = BLINK; return OK; @@ -752,6 +793,7 @@ case THREAD_LOAD_JOG_THREAD: //JOG THREAD SHORTLY TO MAKE SURE SPOOL IS RUNNING. REPORT END OF LOADING //LoadStages++; Thread_Load_Jog_Thread(); + ThreadLoadingReport(); break; case THREAD_LOAD_END: LoadStages = THREAD_LOAD_END; @@ -770,6 +812,11 @@ uint32_t ThreadLoadButton(THREAD_LOAD_STAGES_ENUM ReadValue) Report("ThreadLoadButton called on job",__FILE__,__LINE__,LoadStages,RpMessage,ReadValue,0); return ERROR; } + if (CallbackCounter) + { + Report("ThreadLoadButton called when the loading is active",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); + return ERROR; + } Report("ThreadLoadButton",__FILE__,__LINE__,LoadStages,RpMessage,ReadValue,0); if (LoadStages > ReadValue) { @@ -781,8 +828,60 @@ uint32_t ThreadLoadButton(THREAD_LOAD_STAGES_ENUM ReadValue) } return OK; } -uint32_t LoadCounter = 0; +uint32_t ThreadLoadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) +{ + uint32_t positionDiff = 0,prevprev; + double length = 0.0; + char lenstr[150]; + + int index = MAX_THREAD_MOTORS_NUM; + if (IfIndex>>8 != IfTypeThread) + { + LOG_ERROR (IfIndex, "Wrong Interface type"); + return 0xFFFFFFFF; + } + index = IfIndex&0xFF; +// if (CurrentRequestedLength == 0.0) +// return OK; + if (index != HARDWARE_MOTOR_TYPE__MOTO_RDRIVING) + { + LOG_ERROR (IfIndex, "Wrong Motor"); + return 0xFFFFFFFF; + } + currentPosition = MotorGetPosition(HARDWARE_MOTOR_TYPE__MOTO_RDRIVING); + if (currentPosition != 0) + { + if (Tinitialpos == 0xFFFF) + { + previousPosition = currentPosition; + Tinitialpos = 0; + } + prevprev = previousPosition; + positionDiff = Control_Delta_Position_Pass(currentPosition,previousPosition); + //positionDiff = positionDiff / MotorsCfg[ThreadMotorIdToMotorId[index]].microstep; + previousPosition = currentPosition; + + // total length = (position diff / full cycle) * pulley perimeter + //(positionDiff/pulseperround)*((2*PI*motor_Radius) + + //positionDiff = positionDiff / MotorsCfg[ThreadMotorIdToMotorId[index]].microstep; + length = (double)(positionDiff)*LengthCalculationMultiplier; + + //if (length > 1000) + { + usnprintf(lenstr, 100, " length %d, diff 0x%x, pos 0x%x prev 0x%x",(int)length*100,(int)positionDiff,previousPosition,prevprev); + SendJobProgress(0.0,0,false, lenstr); + ReportWithPackageFilter(ThreadFilter,lenstr,__FILE__,__LINE__,(int)TotalProcessedLen,RpWarning,(int)TotalProcessedLen,0); + length = 0; + + } + + } + TotalProcessedLen += length; + + return OK; +} uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) { //read value is the dancer angle @@ -911,6 +1010,7 @@ void ThreadLoadRequest(MessageContainer* requestContainer) // return ERROR; //#endif } + void ThreadLoadPollRequest(MessageContainer* requestContainer) { uint8_t* container_buffer; @@ -936,3 +1036,86 @@ void ThreadLoadPollRequest(MessageContainer* requestContainer) SendChars(container_buffer, container_size); stub_heating_test_poll_request__free_unpacked(request,NULL); } +char ThreadLoadingToken[36+1] = {0}; +int MessageState = 0; //0 - none, 1 = start, 2 = continue +uint32_t ThreadLoadingReport(void) +{ + MessageContainer responseContainer; + bool last = false; + StartThreadLoadingResponse response = START_THREAD_LOADING_RESPONSE__INIT; + ContinueThreadLoadingResponse Cresponse = CONTINUE_THREAD_LOADING_RESPONSE__INIT; + + if (ThreadLoadingToken[0] == 0) + return OK; + + if (MessageState == 1) + { + response.has_state = true; + if (LoadStatus == OK) + { + response.state = THREAD_LOADING_STATE__Preparing; + if (LoadStages == THREAD_LOAD_INITIAL_TENSION) + { + response.state = THREAD_LOADING_STATE__ReadyForLoading; + last = true; + } + } + else + { + response.state = THREAD_LOADING_STATE__PreparationError; + response.errorreason = LoadErrorMsg; + } + responseContainer = createContainer(MESSAGE_TYPE__StartThreadLoadingResponse, ThreadLoadingToken, last, &response, &start_thread_loading_response__pack, &start_thread_loading_response__get_packed_size); + responseContainer.continuous = true; + } + else if (MessageState == 2) + { + Cresponse.has_state = true; + if (LoadStatus == OK) + { + Cresponse.state = THREAD_LOADING_STATE__Finalizing; + if (LoadStages >= THREAD_LOAD_JOG_THREAD) + { + Cresponse.state = THREAD_LOADING_STATE__Completed; + last = true; + } + } + else + { + Cresponse.state = THREAD_LOADING_STATE__FinalizationError; + Cresponse.errorreason = LoadErrorMsg; + } + responseContainer = createContainer(MESSAGE_TYPE__ContinueThreadLoadingResponse, ThreadLoadingToken, last, &Cresponse, &continue_thread_loading_response__pack, &continue_thread_loading_response__get_packed_size); + responseContainer.continuous = true; + } + else return 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); + SendChars((char*)container_buffer, container_size); + + return OK; + +} + +uint32_t StartThreadLoadingFunc(MessageContainer* requestContainer) +{ + StartThreadLoadingRequest *request = start_thread_loading_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + ustrncpy (ThreadLoadingToken, requestContainer->token,36); + MessageState = 1; + ThreadLoadingReport(); + return OK; + +} + +uint32_t ContinueThreadLoadingFunc(MessageContainer* requestContainer) +{ + ContinueThreadLoadingRequest *request = continue_thread_loading_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + ustrncpy (ThreadLoadingToken, requestContainer->token,36); + MessageState = 2; + ThreadLoadingReport(); + return OK; + +} diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index 29876549e..772025072 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -74,6 +74,9 @@ bool ThreadLoadingActive(void); void ThreadLoadPollRequest(MessageContainer* requestContainer); void ThreadLoadRequest(MessageContainer* requestContainer); +uint32_t StartThreadLoadingFunc(MessageContainer* requestContainer); +uint32_t ContinueThreadLoadingFunc(MessageContainer* requestContainer); + uint32_t Thread_Load_End(void); #endif diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 34934af0c..f0331b4bc 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -158,7 +158,7 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) #endif if (IfIndex>>8 != IfTypeThread) { - LOG_ERROR (IfIndex, "Wrong Interface type"); + ReportWithPackageFilter(ThreadFilter,"Wrong Interface type",__FILE__,__LINE__,(int)IfIndex,RpError,(int)PoolerTotalProcessedLength,0); return 0xFFFFFFFF; } index = IfIndex&0xFF; @@ -166,7 +166,7 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) // return OK; if (index != FEEDER_MOTOR) { - LOG_ERROR (IfIndex, "Wrong Motor"); + ReportWithPackageFilter(ThreadFilter,"Wrong Motor",__FILE__,__LINE__,(int)IfIndex,RpError,(int)index,0); return 0xFFFFFFFF; } CurrentPosition = MotorGetPosition(ThreadMotorIdToMotorId[index]); @@ -248,7 +248,7 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) #endif if (IfIndex>>8 != IfTypeThread) { - LOG_ERROR (IfIndex, "Wrong Interface type"); + ReportWithPackageFilter(ThreadFilter,"Wrong Interface type",__FILE__,__LINE__,(int)IfIndex,RpError,(int)PoolerTotalProcessedLength,0); return 0xFFFFFFFF; } index = IfIndex&0xFF; @@ -256,7 +256,7 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) // return OK; if (index != POOLER_MOTOR) { - LOG_ERROR (IfIndex, "Wrong Motor"); + ReportWithPackageFilter(ThreadFilter,"Wrong Motor",__FILE__,__LINE__,(int)IfIndex,RpError,(int)index,0); return 0xFFFFFFFF; } PoolerCurrentPosition = MotorGetPosition(ThreadMotorIdToMotorId[index]); @@ -343,7 +343,7 @@ uint32_t ThreadSpeedControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) float speed = getSensorSpeedData(); if (IfIndex>>8 != IfTypeThread) { - LOG_ERROR (IfIndex, "Wrong Interface type"); + ReportWithPackageFilter(ThreadFilter,"Wrong Interface type",__FILE__,__LINE__,(int)IfIndex,RpError,(int)PoolerTotalProcessedLength,0); return 0xFFFFFFFF; } index = IfIndex&0xFF; @@ -375,7 +375,7 @@ uint32_t ThreadControlSpeedReadFunction(uint32_t IfIndex, uint32_t ReadValue) int index; if (IfIndex>>8 != IfTypeThread) { - LOG_ERROR (IfIndex, "Wrong Interface type"); + ReportWithPackageFilter(ThreadFilter,"Wrong Interface type",__FILE__,__LINE__,(int)IfIndex,RpError,(int)PoolerTotalProcessedLength,0); return 0xFFFFFFFF; } index = IfIndex&0xFF; @@ -468,7 +468,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) #endif if (IfIndex>>8 != IfTypeThread) { - LOG_ERROR (IfIndex, "Wrong Interface type"); + ReportWithPackageFilter(ThreadFilter,"Wrong Interface type",__FILE__,__LINE__,(int)IfIndex,RpError,(int)PoolerTotalProcessedLength,0); return 0xFFFFFFFF; } index = IfIndex&0xFF; @@ -490,7 +490,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) if (dancerinvalid == false) { dancerinvalid = true; - LOG_ERROR(index, "Dancer value invalid."); + ReportWithPackageFilter(ThreadFilter,"Dancer value invalid.",__FILE__,__LINE__,(int)IfIndex,RpError,(int)ReadValue,0); } return OK; } @@ -795,7 +795,7 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) if (PoolerSpeedControlId != 0xFF) { if (RemoveControlCallback(PoolerSpeedControlId,PoolerThreadLengthCBFunction)!=OK) - LOG_ERROR(Motor_i,"Remove Control Failed"); + ReportWithPackageFilter(ThreadFilter,"Remove Control Failed.",__FILE__,__LINE__,(int)Motor_i,RpError,(int)PoolerSpeedControlId,0); PoolerSpeedControlId = 0xFF; } //SetMotHome(ThreadMotorIdToMotorId[Motor_i]); @@ -807,7 +807,7 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) if (ControlIdtoMotorId[Motor_i] != 0xFF) { if(RemoveControlCallback(ControlIdtoMotorId[Motor_i],ThreadControlCBFunction)!=OK) - LOG_ERROR(Motor_i,"Remove Control Failed"); + ReportWithPackageFilter(ThreadFilter,"Remove Control Failed.",__FILE__,__LINE__,(int)Motor_i,RpError,(int)PoolerSpeedControlId,0); ControlIdtoMotorId[Motor_i] = 0xFF; CurrentControlledSpeed[Motor_i] = 0; } @@ -821,7 +821,7 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) if (ControlIdtoMotorId[Motor_i] != 0xFF) { if(RemoveControlCallback(ControlIdtoMotorId[Motor_i],ThreadControlCBFunction)!=OK) - LOG_ERROR(Motor_i,"Remove Control Failed"); + ReportWithPackageFilter(ThreadFilter,"Remove Control Failed.",__FILE__,__LINE__,(int)Motor_i,RpError,(int)PoolerSpeedControlId,0); CurrentControlledSpeed[Motor_i] = 0; ControlIdtoMotorId[Motor_i] = 0xFF; } @@ -835,7 +835,7 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) if (ControlIdtoMotorId[Motor_i] != 0xFF) { if(RemoveControlCallback(ControlIdtoMotorId[Motor_i],ThreadControlCBFunction)!=OK) - LOG_ERROR(Motor_i,"Remove Control Failed"); + ReportWithPackageFilter(ThreadFilter,"Remove Control Failed.",__FILE__,__LINE__,(int)Motor_i,RpError,(int)PoolerSpeedControlId,0); CurrentControlledSpeed[Motor_i] = 0; ControlIdtoMotorId[Motor_i] = 0xFF; } @@ -913,10 +913,10 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) float process_speed = dyeingspeed; if (dyeingspeed == 0) { - LOG_ERROR (dyeingspeed," job speed zero"); + ReportWithPackageFilter(ThreadFilter,"job speed zero.",__FILE__,__LINE__,(int)dyeingspeed,RpError,(int)SegmentId,0); return ERROR; } - REPORT_MSG (dyeingspeed," ThreadPreSegmentState"); + ReportWithPackageFilter(ThreadFilter,"ThreadPreSegmentState",__FILE__,__LINE__,(int)dyeingspeed,RpWarning,(int)SegmentId,0); if (SegmentId == 0) // do all this only in the beginning of the job. do not touch after that (assuming spool does not change mid job) { SetOriginMotorSpeed(process_speed); @@ -1060,13 +1060,13 @@ char Endstr[150]; if (SpeedControlId != 0xFF) { if(RemoveControlCallback(SpeedControlId,ThreadLengthCBFunction)!=OK) - LOG_ERROR(SpeedControlId,"RemoveControl Failed"); + ReportWithPackageFilter(ThreadFilter,"Remove Control Failed.",__FILE__,__LINE__,(int)Motor_i,RpError,(int)SpeedControlId,0); SpeedControlId = 0xFF; } if (PoolerSpeedControlId != 0xFF) { if(RemoveControlCallback(PoolerSpeedControlId,PoolerThreadLengthCBFunction)!=OK) - LOG_ERROR(PoolerSpeedControlId,"RemoveControl Failed"); + ReportWithPackageFilter(ThreadFilter,"Remove Control Failed.",__FILE__,__LINE__,(int)Motor_i,RpError,(int)PoolerSpeedControlId,0); PoolerSpeedControlId = 0xFF; } @@ -1077,7 +1077,7 @@ char Endstr[150]; if(RemoveControlCallback(ControlIdtoMotorId[Motor_i],ThreadControlCBFunction) == OK) ControlIdtoMotorId[Motor_i] = 0xFF; else - LOG_ERROR (ControlIdtoMotorId[Motor_i],"Remove Control failed"); + ReportWithPackageFilter(ThreadFilter,"Remove Control Failed.",__FILE__,__LINE__,(int)Motor_i,RpError,(int)ControlIdtoMotorId[Motor_i],0); } } Task_sleep(10); |
