Skip to content
Snippets Groups Projects
Commit d9cc5a8e authored by Malaurie Bernard's avatar Malaurie Bernard
Browse files

Complete modification of the syringe class with basic functions (setters and getters)

parent a16256bf
No related branches found
No related tags found
1 merge request!17Malaurie's work on UI + CLI interface + AccelStepper interface
......@@ -3,119 +3,33 @@
#include "motor.h"
class Syringe: public Motor
{
public:
/************** STRUCTURE **************/
typedef struct
{
float diameter_mm;
float capacity_ul;
float rate_ul_per_s;
float volume_value; // see volume_unit_ul /***************************a quoi sert cette variable ? pk pas avoir directement fait volume_in_ul**************/
float volume_unit_ul; // volume in ul = volume_value * volume_unit_ul
int direction;
} Syringe_configuration_t;
/************** METHODES **************/
private:
float volumeToDistance(float volume);
void moveMotor(bool direction, float duration, float speed);
public:
Syringe (MotorHardware_t& stepper): Motor(stepper)
{
}
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(); }
/***EMERGENCY***/ /*(=limit switch management)*/
void setEmergency (bool emergency = true) { _emergency = emergency; }
bool emergency () const { return _emergency; }
void manageEmergency (bool pressed, bool stepperMoving);
void runFromEmergency (float mmPerSec = 0.1, float maxCourseMm = 10);
#include <ArduinoJson.h>
/***POSITION***/
void resetPosition();
void findZero (float mmPerSec = -1, float maxCourseMm = 200); //Provoque le déplacement jusqu'au capteur
float currentPosition ();
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 (); //lance le déplacement du pousse-seringue a partir des spécifications de la configuration
#if 0
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
/************** ATTRIBUTS **************/
private:
/***CONFIGURATION***/
Syringe_configuration_t current_configuration =
{
.diameter_mm = 10,
.capacity_ul = 1000,
.rate_ul_per_s = 100, //a enlever d'ici
.volume_value = 50,
.volume_unit_ul = 1,
.direction = 1, // 1 = push, -1 = pull
};
bool is_configured = false;
/***EMERGENCY***/
bool _emergency = false;
class Syringe : public Motor
{
private :
float _total_volume_mL;
float _internal_diameter_mm;
int _id;
/***INITIALISATION***/
float remaining_volume = 0;
float piston_surface = 0;
public :
//SET METHODS
void set_total_volume_mL(float total_volume_mL);
#include "syringefilled.h"
void set_internal_diameter_mm(float internal_diameter_mm);
void set_id(int id);
//GET METHODS
float get_total_volume_mL();
float get_internal_diameter_mm();
int get_id();
//JSON DOCUMENT
StaticJsonDocument<200> SyringeJSON; //200 = RAM allocated to this document
void setupJsonSyringe( float total_volume_mL, float internal_diameter_mm, int id);
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment