From 72e6775ecc4297d8dbcf683f399f59afe8273a68 Mon Sep 17 00:00:00 2001
From: Malaurie Bernard <mbernard@kinouby>
Date: Tue, 27 Jun 2023 14:01:21 +0200
Subject: [PATCH] Code formatting.

---
 motor.h     |  2 +-
 syringe.cpp | 20 ++++++++++----
 syringe.h   | 78 ++++++++++++++++++++++++++++++++---------------------
 3 files changed, 63 insertions(+), 37 deletions(-)

diff --git a/motor.h b/motor.h
index caa4718..d26c081 100644
--- a/motor.h
+++ b/motor.h
@@ -159,7 +159,7 @@ public:
 #if !CORE_MOCK
         cli();
         stepper.setAcceleration(1e20);
-	    stepper.moveTo(stepper.currentPosition()); // change target to here
+	      stepper.moveTo(stepper.currentPosition()); // change target to here
         setAccelMmPerSecPerSec(_retainAccel);
 	    sei();
 #endif
diff --git a/syringe.cpp b/syringe.cpp
index 805b2bf..f4cc08f 100644
--- a/syringe.cpp
+++ b/syringe.cpp
@@ -163,14 +163,24 @@ void Syringe::runFromEmergency (float mmPerSec, float maxCourseMm)
 }
 
 void Syringe::resetPosition ()
+/***
+-Argument : /
+-Return   : /
+-Action   : Changes the zero position as the current one
+***/
 {
-    //current_configuration.findZero = false;
-    Motor::resetPosition();
+  //current_configuration.findZero = false;
+  Motor::resetPosition();
 }
 
-void Syringe::manageEmergency (bool pressed, bool stepperMoving)
+void Syringe::manageEmergency (bool pressed, bool stepperMoving)/*************************************************************************************************/
+/***
+-Argument : two boolean to know the position of the limit switch and if the stepper is moving
+-Return   : /
+-Action   : Manage different emergency cases (move the pump if necessary)
+***/
 {
-    if (pressed)
+    if (pressed)  //if the limit switch is pressed
     {
         setEmergency();
         if (stepperMoving)
@@ -189,7 +199,7 @@ void Syringe::manageEmergency (bool pressed, bool stepperMoving)
         // emergency button released
         current_configuration.findZero = false;
         setEmergency(false);
-        resetPosition();
+        resetPosition();  //zero is here again
         Serial.printf("ZERO: reset\n");
     }
     else
diff --git a/syringe.h b/syringe.h
index 97c6e6c..3f67dc1 100644
--- a/syringe.h
+++ b/syringe.h
@@ -30,79 +30,95 @@ private:
 
 public:
 
-    Syringe (MotorHardware_t& stepper): Motor(stepper)
+    Syringe (MotorHardware_t& stepper): Motor(stepper)/*********************************************************************************************************/
     {
     }
 
-    void setPhysical (int stepsPerRevolution, float mmPerRevolution, bool forwardClockwise, bool emergencySensorBehind)
+    void setPhysical (int stepsPerRevolution, float mmPerRevolution, bool forwardClockwise, bool emergencySensorBehind)/*******************************************/
     {
         Motor::setPhysical(stepsPerRevolution, mmPerRevolution, forwardClockwise);
         _emergencySensorBehind = emergencySensorBehind;
     }
 
+    /***CONFIGURATION***/
     void showConfiguration (const Syringe_configuration_t& conf);
+    const Syringe_configuration_t& configuration () const { return current_configuration; }; /**********************************************************************/
+    bool infusing () { return current_configuration.direction == 1; }
+    bool configureSyringe(const Syringe_configuration_t& config);
+    void setInitialContent(float initial_volume);
+    void setPushClockwise (bool clockwise) { setForwardClockwise(clockwise); }
+    bool getPushClockwise () { return getForwardClockwise(); }
 
-    void setEmergency (bool emergency = true) { _emergency = emergency; }
-    bool emergency () const { return _emergency; }
+    /***EMERGENCY***/ /*(=limit switch management)*/
+    void setEmergency (bool emergency = true) { _emergency = emergency; }/***************************************************************************************************/
+    bool emergency () const { return _emergency; }/**********************************************************************************************************************/
 
-    void resetPosition();
-    void findZero (float mmPerSec = -1, float maxCourseMm = 200);
     void manageEmergency (bool pressed, bool stepperMoving);
     void runFromEmergency (float mmPerSec = 0.1, float maxCourseMm = 10);
 
-    const Syringe_configuration_t& configuration () const { return current_configuration; };
 
-    bool infusing () { return current_configuration.direction == 1; }
+    /***POSITION***/
+    void resetPosition();
+    void findZero (float mmPerSec = -1, float maxCourseMm = 200);  //Provoque le déplacement jusqu'au capteur
+
 
-	// Configuration
+    float currentPosition ();
 
-	bool configureSyringe(const Syringe_configuration_t& config);
-	void setInitialContent(float initial_volume);
-	void setPushClockwise (bool clockwise) { setForwardClockwise(clockwise); }
-	bool getPushClockwise () { return getForwardClockwise(); }
+    void updateValue ();
 
+    bool  isRunning ();
+
+    /***CONVERSIONS***/
     float mm3ToMm (float mm3) const;
     float mmToMm3 (float mm) const;
     float confToMm () const;
     float confToMm3 () const;
     float sectionMm2 () const;
 
-	// Actions
-
-    void fill ();
+    /***ACTIONS***/
+    void fill (); //lance le déplacement du pousse-seringue a partir des spécifications de la configuration
 
 #if 0
-	void push(float volume, float throughput); // Volume in mL, throughput in µL/min
-	void pushAll(float throughput); // Throughput in µL/min
-	void pushFor(float duration, float throughput); // Duration in min, throughput in µL/min
-	void pushVol(float volume, float duration); // Volume in mL, duration in min
-
-	void pull(float volume, float throughput); // Volume in mL, throughput in µL/min
-	void pullAll(float throughput); // Throughput in µL/min
-	void pullFor(float duration, float throughput); // Duration in min, throughput in µL/min
-	void pullVol(float volume, float duration); // Volume in mL, duration in min
+	void push(float volume, float throughput);
+	void pushAll(float throughput);
+	void pushFor(float duration, float throughput);
+	void pushVol(float volume, float duration);
+
+	void pull(float volume, float throughput);
+	void pullAll(float throughput);
+	void pullFor(float duration, float throughput);
+	void pullVol(float volume, float duration);
 #endif	
 
-private:
 
+/************** ATTRIBUTS **************/
+
+private:
+  /***CONFIGURATION***/
 	Syringe_configuration_t current_configuration =
 	{
 	    .diameter_mm = 10,
 	    .capacity_ul = 1000,
-	    .rate_ul_per_s = 100,
+	    .rate_ul_per_s = 100,  //a enlever d'iciy
 	    .volume_value = 50,
 	    .volume_unit_ul = 1,
-	    .direction = 1,
-        .findZero = false,
+	    .direction = 1,  // 1 = push, -1 = pull
+      .findZero = false,
 	};
+
+	bool is_configured = false;
 	
+  /***EMERGENCY***/
 	bool _emergency = false;
-    bool _emergencySensorBehind;
 
-	bool is_configured = false;
+
+  /***INITIALISATION***/
 	float remaining_volume = 0;
 	float piston_surface = 0;
 
+
+
+
 };
 
 extern Syringe syringe;
-- 
GitLab