aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-01-02 08:47:29 +0200
committerShlomo Hecht <shlomo@twine-s.com>2019-01-02 08:47:29 +0200
commit520e878bf98efcec9c75abcfe483175ff72620a2 (patch)
tree62a7221e3c22187821f6a5e399eca0f7bd31168a /Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
parent30574fe4a6e1bb4f60a43e9000acaf919811689a (diff)
parent25f5e6ddef7ef2fa0a747305847eeb4ceee5a2c9 (diff)
downloadTango-520e878bf98efcec9c75abcfe483175ff72620a2.tar.gz
Tango-520e878bf98efcec9c75abcfe483175ff72620a2.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c94
1 files changed, 51 insertions, 43 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index 76c0fbfd8..94858cae2 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
@@ -355,6 +355,8 @@ void testDancersControl()
bool dancerinvalid = false;
int MotorFailedSample[MAX_THREAD_MOTORS_NUM] = {0,0,0,0,0};
char Message[60];
+uint16_t BreakSensorCounter = 0;
+uint16_t BreakSensorLatchCounter = 0;
uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
//#define MAX_CONTROL_SAMPLES 6
@@ -425,16 +427,29 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
if (ReadBreakSensor()==ERROR)
{
- //consider applying the debouce parameters later
- //BreakSensordebouncetimemilli
- JobEndReason = JOB_THREAD_BREAK;
- ThreadControlActive = false;
- SendJobProgress(0.0,0,false, "ReadBreakSensor Error");
- SegmentReady(Module_Thread,ModuleFail);
- AlarmHandlingSetAlarm(EVENT_TYPE__ThreadBreak,true);
- //EndState(CurrentJob,"ReadBreakSensor Error" );
- LOG_ERROR(index, "ReadBreakSensor Error");
- return OK;
+ BreakSensorCounter++;
+ BreakSensorLatchCounter++;
+ if (BreakSensorCounter>=BreakSensordebouncetimemilli)
+ {
+ //consider applying the debouce parameters later
+ //BreakSensordebouncetimemilli
+ JobEndReason = JOB_THREAD_BREAK;
+ ThreadControlActive = false;
+ SendJobProgress(0.0,0,false, "ReadBreakSensor Error");
+ SegmentReady(Module_Thread,ModuleFail);
+ AlarmHandlingSetAlarm(EVENT_TYPE__ThreadBreak,true);
+ //EndState(CurrentJob,"ReadBreakSensor Error" );
+ LOG_ERROR(index, "ReadBreakSensor Error");
+ return OK;
+ } //passed limit
+ }//ReadBreakSensor()==ERROR
+ else //reset counter - we are looking for consequent calls
+ {
+ if (BreakSensorCounter)
+ {
+ LOG_ERROR(BreakSensorCounter, "ReadBreakSensor Spike");
+ }
+ BreakSensorCounter = 0;
}
}
}
@@ -447,7 +462,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
usnprintf(Message, 60, "Dancer %d limit %d value %d Zero %d",DancerId,DancerStopActivityLimit[index],avreageSampleValue,DancersCfg[DancerId].zeropoint);
//JobAbortedByUser = true;
ThreadControlActive = false;
- MotorGetStatusFromFPGA(ThreadMotorIdToMotorId[index]);
+ //MotorGetStatusFromFPGA(ThreadMotorIdToMotorId[index]);
JobEndReason = JOB_WINDER_DANCER_FAIL+DancerId;
SendJobProgress(0.0,0,false, Message);
//EndState(CurrentJob,Message );
@@ -525,7 +540,7 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request)
//MotorsConfigMessage(request);
ThreadPrepareState(request);
- ThreadPreSegmentState(request);
+ ThreadPreSegmentState(request,0);
return OK;
}
bool InitialProcess = false;
@@ -659,7 +674,7 @@ void SetOriginMotorSpeed(float process_speed)
}
//********************************************************************************************************************
-uint32_t ThreadPreSegmentState(void *JobDetails)
+uint32_t ThreadPreSegmentState(void *JobDetails, uint32_t SegmentId)
{
//set the speed only before the first segment, speed is constant across all job segments and intersegments
JobTicket* JobTicket = JobDetails;
@@ -670,33 +685,26 @@ uint32_t ThreadPreSegmentState(void *JobDetails)
LOG_ERROR (dyeingspeed," job speed zero");
return ERROR;
}
- LOG_ERROR (dyeingspeed," ThreadPreSegmentState");
-
- SetOriginMotorSpeed(process_speed);
- ThreadControlActive = true;
- PrepareState = false;
- // set the new speed in the dryer motor to the speed of the new segment
- MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING, OriginalMotorSpd_2PPS[DRYER_MOTOR]);
- //only for testing - when control works, these motors will take their speed from the dryer
- //MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LDRIVING, OriginalMotorSpd_2PPS[POOLER_MOTOR]);
- //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].maxfrequency > 0)
+ REPORT_MSG (dyeingspeed," ThreadPreSegmentState");
+ 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)
{
- MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize);
- MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 1);
- }
- if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].maxfrequency > 0)
- {
- MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_LLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize);
- MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 1);
- }
-// #warning rocker disabled
-
-// MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].directionthreadwize, 0, GPI_LS_RLOADMOTOR_UP, EndState); //TODO
+ SetOriginMotorSpeed(process_speed);
+ ThreadControlActive = true;
+ PrepareState = false;
+ // set the new speed in the dryer motor to the speed of the new segment
+ MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING, OriginalMotorSpd_2PPS[DRYER_MOTOR]);
+ if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].maxfrequency > 0)
+ {
+ MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize);
+ MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 1);
+ }
+ if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].maxfrequency > 0)
+ {
+ MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_LLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize);
+ MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 1);
+ }
+ }
// activate control fr all motors
//set speed for both rocker motors
//wait for all motors to get to the required speed (set the target speed for the control to check)
@@ -718,17 +726,17 @@ uint32_t ThreadPreSegmentState(void *JobDetails)
int REPSegmentId = 0;
void ThreadInterSegmentEnded(void)
{
- LOG_ERROR (REPSegmentId,"ThreadInterSegmentEnded");
+ REPORT_MSG (REPSegmentId,"ThreadInterSegmentEnded");
PreSegmentReady(Module_Thread,ModuleDone);
}
void ThreadSegmentEnded(void)
{
- LOG_ERROR (REPSegmentId," ThreadSegmentState");
+ REPORT_MSG (REPSegmentId," ThreadSegmentState");
SegmentReady(Module_Thread,ModuleDone);
}
void ThreadDistanceToSpoolEnded(void)
{
- LOG_ERROR (REPSegmentId," ThreadDistanceToSpoolEnded");
+ REPORT_MSG (REPSegmentId," ThreadDistanceToSpoolEnded");
DistanceToSpoolReady(Module_Thread,ModuleDone);
}
double seglength = 0.0;
@@ -739,7 +747,7 @@ uint32_t ThreadSegmentState(void *JobDetails, int SegmentId)
REPSegmentId = SegmentId;
seglength = JobTicket->segments[SegmentId]->length;
CurrentSegmentId = SegmentId;
- LOG_ERROR (seglength," ThreadSegmentState");
+ REPORT_MSG (seglength," ThreadSegmentState");
ThreadUpdateProcessLength (seglength,(void *)ThreadSegmentEnded);
return OK;
}
@@ -748,7 +756,7 @@ uint32_t ThreadSegmentState(void *JobDetails, int SegmentId)
uint32_t ThreadDistanceToSpoolState(void )
{
seglength = dryerbufferlength;
- LOG_ERROR (seglength,"ThreadDistanceToSpoolState");
+ REPORT_MSG (seglength,"ThreadDistanceToSpoolState");
ThreadUpdateProcessLength (seglength,(void *)ThreadDistanceToSpoolEnded);
return OK;
}