diff options
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules')
3 files changed, 108 insertions, 14 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index e8779d265..23560bd06 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -27,6 +27,10 @@ #include <PMR/Diagnostics/StartDiagnosticsResponse.pb-c.h> #include <PMR/Diagnostics/StopDiagnosticsRequest.pb-c.h> #include <PMR/Diagnostics/StopDiagnosticsResponse.pb-c.h> +#include <PMR/Diagnostics/Event.pb-c.h> +#include <PMR/Diagnostics/EventType.pb-c.h> +#include "PMR/debugging/DebugLogCategory.pb-c.h" + char DiagnosticsToken[36] = {0}; bool DiagnosticsActive = false; @@ -131,8 +135,88 @@ void AlarmHandler_SendDiagnostics(void) return ; } +/*typedef enum _EventType { + EVENT_TYPE__ThreadBreak = 0, + EVENT_TYPE__ThreadTensionControlFailure = 1, + EVENT_TYPE__FeederConeInsufficiant = 2, + EVENT_TYPE__WinderGeneralError = 3, + EVENT_TYPE__WinderConeNotExists = 4, + EVENT_TYPE__ThreadFeedingGeneralError = 5, + EVENT_TYPE__DyeingHeadOverTemperature = 6, + EVENT_TYPE__DHThermalCutoff = 7, + EVENT_TYPE__DryerOverTemperature = 8, + EVENT_TYPE__DryerThermalCutoff = 9, + EVENT_TYPE__DyeingHeadHeatersCurrentOutOfRange = 10, + EVENT_TYPE__DryerHeatersCurrentOutOfRange = 11, + EVENT_TYPE__DryerDHeadCoverOpen = 12, + EVENT_TYPE__AirFilterClogged = 13, + EVENT_TYPE__AirFilterNotInstalled = 14, + EVENT_TYPE__WHSFailure = 15, + EVENT_TYPE__WasteContainerIsAlmostFull = 16, + EVENT_TYPE__WasteContainerIsFull = 17, + EVENT_TYPE__DispenserEmpty = 18, + EVENT_TYPE__DispenserLowLevel = 19, + EVENT_TYPE__DispenserRefillFailure = 20, + EVENT_TYPE__MidTankEmpty = 21, + EVENT_TYPE__MidTankLowLevel = 22, + EVENT_TYPE__MidTankNotInPlace = 23, + EVENT_TYPE__SystemBITFail = 24, + EVENT_TYPE__GeneralInternalOverTemperature = 25, + EVENT_TYPE__MachineCoverOpen = 26, + EVENT_TYPE__EmergencyPushButtonPressed = 27, + EVENT_TYPE__SystemGeneralError = 28, + EVENT_TYPE__RequestSent = 29, + EVENT_TYPE__ResponseReceived = 30, + EVENT_TYPE__RequestFailed = 31, + EVENT_TYPE__ApplicationException = 32, + EVENT_TYPE__ApplicationInformation = 33, + EVENT_TYPE__ApplicationStarted = 34, + EVENT_TYPE__ApplicationTerminated = 35, + EVENT_TYPE__RecordingStarted = 36, + EVENT_TYPE__RecordingStopped = 37 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(EVENT_TYPE) +} EventType; + * */ +uint32_t AlarmHandlingConsequentActions(EventType EventId, DebugLogCategory Severity) +{ + switch (Severity) + { + case DEBUG_LOG_CATEGORY__Warning: + + //raise flag fr next job + break; + case DEBUG_LOG_CATEGORY__Error: + AbortJob(NULL,event_type__descriptor.name[EventId]); +//Stop Job + break; + case DEBUG_LOG_CATEGORY__Critical: + EndState(NULL,event_type__descriptor.name[EventId]); + //stop job + //turn machine off + break; + case DEBUG_LOG_CATEGORY__Debug: + case DEBUG_LOG_CATEGORY__Info: + default: + //do nothing + break; + + } +} + uint32_t AlarmHandlingLoop(uint32_t tick) { + //read dispensers limit switches. 25 - send warning. up - stop job and send alarm + + //Cone missing + //Dyeing head over temperature + //mixer over temperature + //dryer over temperature + //heaters failure + //dispenser pressure + //valve OCD + //Motor Status + //machine cover open + return OK; } void SendDiagnostics(void) diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index 38ae19f36..ad3aaff6f 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -41,8 +41,8 @@ typedef struct HeatersControlMessage{ }HeatersControlMessageStruc; /******************** GLOBAL PARAMETERS ********************************************/ -HeaterCommand HeaterCmd[MAX_HEATERS_NUM] = {}; -uint32_t ControlIdtoHeaterId [MAX_HEATERS_NUM] = {0xFF}; +HeaterCommand HeaterCmd[MAX_HEATERS_NUM]; +uint32_t ControlIdtoHeaterId [MAX_HEATERS_NUM] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; uint32_t DryerHeaterMaxTempControl = 0xFF; uint32_t DryerInternalPT100Id = ANALOG_DRYER_TEMP2; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index f5462e398..fafc43fb5 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -15,6 +15,8 @@ #include "PMR/Printing/JobSegment.pb-c.h" #include "PMR/Printing/JobTicket.pb-c.h" +#include <utils/ustdlib.h> + #include "StateMachines/Printing/PrintingSTM.h" #include "drivers/Motors/Motor.h" @@ -178,7 +180,7 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) pooler_counter++; if (pooler_counter%10 == 0) { - SendJobProgress(CurrentProcessedLength/CurrentRequestedLength,CurrentSegmentId,false); + SendJobProgress(CurrentProcessedLength/CurrentRequestedLength,CurrentSegmentId,false, "Progress"); //SendJobProgress(/*KeepNormalizedError*/MotorControlConfig[index].m_calculatedError,CurrentSegmentId,false); } @@ -259,6 +261,8 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) int32_t TranslatedReadValue, avreageSampleValue = 0; uint32_t calculated_speed; double NormalizedError; + char Message[60]; + if (IfIndex>>8 != IfTypeThread) { LOG_ERROR (IfIndex, "Wrong Interface type"); @@ -293,7 +297,8 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) //TranslatedReadValue = 0;//test MotorSamples[index][MotorSamplePointer[index]] = TranslatedReadValue;//(-1 * TranslatedReadValue); MotorSamplePointer[index]++; - if (MotorSamplePointer[index] >= MotorsControl[index].pvinputfilterfactormode) MotorSamplePointer[index] = 0; + if (MotorSamplePointer[index] >= MotorsControl[index].pvinputfilterfactormode) + MotorSamplePointer[index] = 0; for (i=0;i<MotorsControl[index].pvinputfilterfactormode;i++) avreageSampleValue += MotorSamples[index][i]; avreageSampleValue = avreageSampleValue / MotorsControl[index].pvinputfilterfactormode; @@ -301,7 +306,9 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) if ((abs(avreageSampleValue)> DancerStopActivityLimit[index])&&(JobCounter > eOneSecond)) { - EndState(CurrentJob); + usnprintf(Message, 60, "Dancer % limit%d value %d Zero %d",DancerId,DancerStopActivityLimit[index],avreageSampleValue,DancersCfg[DancerId].zeropoint); + + EndState(CurrentJob,Message ); } NormalizedError = avreageSampleValue*NormalizedErrorCoEfficient[index]; MotorControlConfig[index].m_mesuredParam = NormalizedError; @@ -472,7 +479,9 @@ uint32_t ThreadPreSegmentState(void *JobDetails) //set the speed only before the first segment, speed is constant accros job JobTicket* JobTicket = JobDetails; - float process_speed = JobTicket->processparameters->dyeingspeed; + float process_speed; + if (JobTicket->processparameters) + process_speed= JobTicket->processparameters->dyeingspeed; SetOriginMotorSpeed(process_speed); //ControlStart(); @@ -483,14 +492,14 @@ uint32_t ThreadPreSegmentState(void *JobDetails) //only for testing - when control works, these motors will take their speed from the dryer //MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RDRIVING, OriginalMotorSpd_2PPS[FEEDER_MOTOR]); -//#warning rocker disabled - if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].has_directionthreadwize) - MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize); - MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 5); - if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].has_directionthreadwize) - MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_LLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize); - MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 5); -//#warning rocker disabled +#warning rocker disabled +// if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].has_directionthreadwize) +// MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize); +// MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 5); +// if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].has_directionthreadwize) +// MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_LLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize); +// MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 5); +#warning rocker disabled // MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].directionthreadwize, 0, GPI_LS_RLOADMOTOR_UP, EndState); //TODO @@ -506,6 +515,7 @@ uint32_t ThreadPreSegmentState(void *JobDetails) { ThreadUpdateProcessLength (0,(void *)NULL); PreSegmentReady(Module_Thread,ModuleDone); + JobCounter = 0; InitialProcess = false; } |
