From e87e79c28a28b576f94079e807e1f83cb1820f18 Mon Sep 17 00:00:00 2001 From: Malaurie Bernard <mbernard@kinouby> Date: Thu, 24 Aug 2023 10:58:28 +0200 Subject: [PATCH] Cede edditting --- syringefilled.h | 3 +- web.cpp | 109 +++++++++++++----------------------------------- 2 files changed, 31 insertions(+), 81 deletions(-) diff --git a/syringefilled.h b/syringefilled.h index 06da047..49db0be 100644 --- a/syringefilled.h +++ b/syringefilled.h @@ -25,7 +25,7 @@ class SyringeFilled : public Motor private : //SyringeFilled - float _exchange_throughput_uL_per_sec; + float _exchange_throughput_uL_per_min; float _exchange_volume_mL; float _remaining_volume_mL; bool _push; //false means pull @@ -41,6 +41,7 @@ class SyringeFilled : public Motor float _lead_screw_pitch_mm; int _microstep_configuration; int _motor_steps; + bool _motor_release; //Limit_Switch bool _emergency; diff --git a/web.cpp b/web.cpp index 6b0118c..7eb8419 100644 --- a/web.cpp +++ b/web.cpp @@ -49,18 +49,17 @@ void Web :: web_setup() fast_backward = ESPUI.button("Initialisation", [&](Control* sender, int value){fast_backward_callback(sender, value);}, ControlColor::None, "\u2BC7 \u2BC7"); slow_backward = ESPUI.addControl(ControlType::Button, "Initialisation", "\u2BC7", ControlColor::None, fast_backward, [&](Control* sender, int value){slow_backward_callback(sender, value);}); slow_forward = ESPUI.addControl(ControlType::Button, "Initialisation", "\u2BC8", ControlColor::None, fast_backward, [&](Control* sender, int value){slow_forward_callback(sender, value);}); - fast_forward = ESPUI.addControl(ControlType::Button, "Initialisation", "\u2BC8 \u2BC8", ControlColor::None, fast_backward, [&](Control* sender, int value){fast_forward_callback(sender, value);}); + fast_forward = ESPUI.addControl(ControlType::Button, "Initialisation", "\u2BC8 \u2BC8", ControlColor::None, fast_backward, [&](Control* sender, int value){fast_forward_callback(sender, value);}); confirm_initialisation = ESPUI.button("Valider l'initialisation", [&](Control* sender, int value){confirm_initialisation_callback(sender, value);}, ControlColor::None, "\u2714"); - ESPUI.addControl(ControlType::Separator, "", "", ControlColor::None); //Exchange_values_wanted initial_volume_mL_label =ESPUI.addControl( ControlType::Label, "Configuration de l'échange", "Volume initial contenu dans la seringue : ", ControlColor::None); - initial_volume_mL = ESPUI.addControl( ControlType::Number, "Volume initial contenu dans la seringue : ", "0", ControlColor::None, initial_volume_mL_label, [&](Control* sender, int value){initial_volume_mL_callback(sender, value);}); + initial_volume_mL = ESPUI.addControl( ControlType::Number, "Volume initial contenu dans la seringue : ", "0", ControlColor::None, initial_volume_mL_label, [&](Control* sender, int value){initial_volume_mL_callback(sender, value);}); number_max_min(0, 500, initial_volume_mL); volume_exchange_mL_label = ESPUI.addControl(ControlType::Label, "Configuration de l'échange", "Volume à échanger en mL", ControlColor::None, initial_volume_mL_label); @@ -72,27 +71,21 @@ void Web :: web_setup() number_max_min(0, 500, exchange_throughtput_uL_per_min_or_duration_sec); throughput_or_duration = ESPUI.addControl(ControlType::Button, "Configuration de l'échange", "\u21C6", ControlColor::None, initial_volume_mL_label, [&](Control* sender, int value){throughput_or_duration_callback(sender, value);}); - label_push_pull_choice = ESPUI.addControl(ControlType::Label, "Injection ou Aspiration", "Injection", ControlColor::None, initial_volume_mL_label); switch_push_pull_choice = ESPUI.addControl(ControlType::Switcher, "Injection ou Aspiration", "Injection", ControlColor::None, initial_volume_mL_label, [&](Control* sender, int value){switch_push_pull_choice_callback(sender, value);}); ESPUI.updateSwitcher(switch_push_pull_choice, true); //pour mettre a "Injection" par défaut au début - start_exchange = ESPUI.addControl(ControlType::Button, "Start exchange", "\xF0\x9F\x8F\x81", ControlColor::None, initial_volume_mL_label, [&](Control* sender, int value){start_exchange_callback(sender, value);}); - //Remaning_values label_remaining_volume_mL = ESPUI.label("Caractéristiques de l'échange en cours", ControlColor::None, "Volume restant en mL"); remaining_volume_mL = ESPUI.addControl(ControlType::Slider, "Volume", "0", ControlColor::None, label_remaining_volume_mL, [&](Control* sender, int value){remaining_volume_mL_callback(sender, value);}); - label_remaining_time_sec = ESPUI.addControl( ControlType::Label, "Caractéristiques de l'échange en cours", "Temps restant en sec", ControlColor::None, label_remaining_volume_mL); remaining_time_sec = ESPUI.addControl(ControlType::Slider, "Temps", "0", ControlColor::None, label_remaining_volume_mL, [&](Control* sender, int value){remaining_time_sec_callback(sender, value);}); - ESPUI.sliderContinuous = true; - //Configurations //Choice_of_syringe_model @@ -108,20 +101,15 @@ void Web :: web_setup() syringe_diameter_mm_string = "internal diameter : " + std::to_string(syringe_diameter_mm_value) + "mm"; syringe_diameter_mm =ESPUI.addControl( ControlType::Label, "Caractéristiques de la seringue : ", syringe_diameter_mm_string.c_str(), ControlColor::None, syringe_volume_mL); - choose_syringe = ESPUI.addControl(ControlType::Button, "Choisir cette seringue", "\u2714", ControlColor::None, syringe_selection, [&](Control* sender, int value){choose_syringe_callback(sender, value);}); - load_syringe_json = ESPUI.addControl(ControlType::Button, "Charger les seringues", "\u2714", ControlColor::None, configurations, [&](Control* sender, int value){load_syringe_json_callback(sender, value);}); - ESPUI.addControl(ControlType::Separator, "", "", ControlColor::None, configurations); - //New_syringe name_new_syringe_label = ESPUI.addControl(ControlType::Label, "Nouvelle seringue", "Nom de la seringue :", ControlColor::None, new_syringe); name_new_syringe = ESPUI.addControl(ControlType::Text, "Nouvelle seringue", "", ControlColor::None, name_new_syringe_label, [&](Control* sender, int value){name_new_syringe_callback(sender, value);}); - internal_diameter_mm_new_syringe_label =ESPUI.addControl(ControlType::Label, "Nouvelle seringue", "Diamètre interne de la seringue en mm :", ControlColor::None, name_new_syringe_label); internal_diameter_mm_new_syringe = ESPUI.addControl(ControlType::Number, "Diamètre interne de la seringue en mm", "5", ControlColor::None, name_new_syringe_label, [&](Control* sender, int value){internal_diameter_mm_new_syringe_callback(sender, value);}); internal_diameter_mm_new_syringe_value = 5; @@ -136,15 +124,12 @@ void Web :: web_setup() save_syringe = ESPUI.addControl(ControlType::Button, "Sauvegarder la seringue", "\u2714", ControlColor::None, new_syringe, [&](Control* sender, int value){save_syringe_callback(sender, value);}); - //Features - syringe_pump_length_mm_value = ESPUI.addControl(ControlType::Number, "Longueur totale du pousse-seringue", "50", ControlColor::None, features, [&](Control* sender, int value){syringe_pump_length_mm_callback(sender, value);}); - - lead_screw_pitch_mm = ESPUI.addControl(ControlType::Number, "Avance par tour", "0.7", ControlColor::None, features, [&](Control* sender, int value){number_callback(sender, value);}); - - clockwise_equals_push_label = ESPUI.addControl(ControlType::Label, "Sens de rotation du moteur", "Horaire = Injection", ControlColor::None, features); - clockwise_equals_push = ESPUI.addControl(ControlType::Switcher, "Sens de rotation du moteur", "Horaire =", ControlColor::None, clockwise_equals_push_label, [&](Control* sender, int value){clockwise_equals_push_callback(sender, value);}); - ESPUI.updateSwitcher(clockwise_equals_push, true); //set "Horaire = Injection" at the beginning + syringe_pump_length_mm_value = ESPUI.addControl(ControlType::Number, "Longueur totale du pousse-seringue", "50", ControlColor::None, features, [&](Control* sender, int value){syringe_pump_length_mm_callback(sender, value);}); + lead_screw_pitch_mm = ESPUI.addControl(ControlType::Number, "Avance par tour", "0.7", ControlColor::None, features, [&](Control* sender, int value){lead_screw_pitch_mm_callback(sender, value);}); + clockwise_equals_forward_label = ESPUI.addControl(ControlType::Label, "Sens de rotation du moteur", "Horaire = Injection", ControlColor::None, features); + clockwise_equals_forward = ESPUI.addControl(ControlType::Switcher, "Sens de rotation du moteur", "Horaire =", ControlColor::None, clockwise_equals_forward_label, [&](Control* sender, int value){clockwise_equals_forward_callback(sender, value);}); + ESPUI.updateSwitcher(clockwise_equals_forward, false); //set "Horaire = Injection" at the beginning microstep_configuration = ESPUI.addControl(ControlType::Number, "Configuration Hardware des microsteps", "16", ControlColor::None, features, [&](Control* sender, int value){microstep_configuration_callback(sender, value);}); @@ -152,7 +137,6 @@ void Web :: web_setup() motor_release_label = ESPUI.addControl(ControlType::Label, "Relachement du moteur", "Off", ControlColor::None, features); motor_release = ESPUI.addControl(ControlType::Switcher, "Relachement du moteur", "", ControlColor::None, motor_release_label, [&](Control* sender, int value){motor_release_callback(sender, value);}); - //Begin set_initial_style(); @@ -234,7 +218,6 @@ void Web :: calibration_callback (Control *sender, int type) style (status_syringe_pump, 1); style (stop_syringe_pump, 1); } - Serial.println("Calibration"); Serial.println(String("Value: ") + String(sender->type)); Serial.println(String("ID: ") + sender->id); @@ -381,7 +364,6 @@ void Web :: confirm_initialisation_callback (Control *sender, int type) syringe_filled.reset_position(); number_max_min(0, syringe.get_syringe_database_object()[syringe_filled.get_syringe_name()]["total_volume_mL"], remaining_volume_mL); ESPUI.updateSlider(remaining_volume_mL, syringe_filled.get_remaining_volume_mL()); - syringe_filled.set_update_remaining_volume(true); break; @@ -390,11 +372,9 @@ void Web :: confirm_initialisation_callback (Control *sender, int type) break; } - serial_print ("Confirm_initialisation", sender); } - void Web :: volume_exchange_mL_callback (Control* sender, int value) /*** -Argument : Pointer to the controller calling the function, integer according to the controller type. @@ -406,13 +386,11 @@ void Web :: volume_exchange_mL_callback (Control* sender, int value) syringe_filled.set_exchange_volume_mL(atof(sender->value.c_str())); syringe_filled.save_json (); - serial_print ("Volume_exchange (sender->value)", sender); Serial.println("Volume_exchange (json value)"); Serial.println(String("Value: ") + String(syringe_filled.get_exchange_volume_mL())); Serial.println(""); - } void Web :: throughput_or_duration_callback (Control *sender, int type) @@ -436,18 +414,15 @@ void Web :: throughput_or_duration_callback (Control *sender, int type) syringe_filled.set_throughput(true); ESPUI.print(exchange_throughtput_uL_per_min_or_duration_sec_label, "Débit de l'échange en uL/min"); } - break; case B_UP: break; } - serial_print ("throughput_or_duration", sender); } - void Web :: exchange_throughtput_uL_per_min_or_duration_sec_callback (Control* sender, int value) /*** -Argument : Pointer to the controller calling the function, integer according to the controller type. @@ -455,7 +430,7 @@ void Web :: exchange_throughtput_uL_per_min_or_duration_sec_callback (Control* s -Action : Enable to choose the volume that woud be exchanged. ***/ { - syringe_filled.set_exchange_throughput_uL_per_sec(atof(sender->value.c_str())); + syringe_filled.set_exchange_throughput_uL_per_min(atof(sender->value.c_str())); syringe_filled.save_json (); serial_print ("Exchange_throughtput (sender->value)", sender); @@ -466,7 +441,6 @@ void Web :: exchange_throughtput_uL_per_min_or_duration_sec_callback (Control* s } - void Web :: switch_push_pull_choice_callback (Control* sender, int value) /*** -Argument : Pointer to the controller calling the function, integer according to the controller type. @@ -512,7 +486,6 @@ void Web :: remaining_volume_mL_callback (Control* sender, int value) ESPUI.updateSlider(remaining_volume_mL, syringe_filled.get_remaining_volume_mL()); } - void Web :: remaining_time_sec_callback (Control* sender, int value) /*** -Argument : Pointer to the controller calling the function, integer according to the controller type. @@ -533,22 +506,19 @@ void Web :: start_exchange_callback (Control* sender, int value) serial_print ("Exchange start", sender); } -//configurations = Configurations - +//configurations = Configurations void Web :: initial_volume_mL_callback (Control* sender, int value) { syringe_filled.set_remaining_volume_mL((sender->value).toFloat()); syringe_filled.save_json(); - serial_print ("syringe_initial_volume (sender->value)", sender); Serial.println("syringe_initial_volume (json value)"); Serial.println(String("Value: ") + String(syringe_filled.get_remaining_volume_mL())); Serial.println(""); - } void Web :: choose_syringe_callback (Control* sender, int value) @@ -578,13 +548,12 @@ void Web :: choose_syringe_callback (Control* sender, int value) serial_print ("choose_syringe", sender); serial_print ("name_syringe_chosen (sender->value)", sender); - Serial.println("Volume_total (json value)"); Serial.println(String("Value: ") + String((syringe.get_syringe_database()[syringe_filled.get_syringe_name()]["total_volume_mL"]).as<const char*>())); Serial.println(""); Serial.println("internal_diameter (json value)"); - Serial.println(String("Value: ") + String(syringe.get_syringe_database()[syringe_filled.get_syringe_name()]["internal_diameter"].as<const char*>())); + Serial.println(String("Value: ") + String(syringe.get_syringe_database()[syringe_filled.get_syringe_name()]["internal_diameter_mm"].as<const char*>())); Serial.println(""); } @@ -600,15 +569,15 @@ void Web :: load_syringe_json_callback (Control* sender, int value) { case B_DOWN: - for (int i=0; i<option_nb; i++) { - ESPUI.removeControl(options_id[i], false); + ESPUI.removeControl(options_id[i], false); } option_nb = 0; select_syringe_update(configurations); + break; case B_UP: @@ -616,12 +585,10 @@ void Web :: load_syringe_json_callback (Control* sender, int value) } Serial.println ("load_syringe_json"); - } - void Web :: name_new_syringe_callback(Control* sender, int type) /*** -Argument : Pointer to the controller calling the function, integer according to the controller type. @@ -683,13 +650,11 @@ void Web :: save_syringe_callback (Control* sender, int value) case B_UP: break; } - serial_print ("save_syringe", sender); } - //features : Configurations avancées void Web :: syringe_pump_length_mm_callback(Control* sender, int type) @@ -804,8 +769,7 @@ void Web :: motor_release_callback(Control* sender, int value) Serial.println("motor_release (json value)"); Serial.println(String("Value: ") + String(syringe_filled.get_motor_release())); Serial.println(""); - } - +} // @@ -827,7 +791,6 @@ void Web :: syringe_selection_callback(Control* sender, int value) } - //ON_OFF METHODS void Web :: syringe_pump_on_off() @@ -839,14 +802,13 @@ void Web :: syringe_pump_on_off() { if (syringe_filled.is_running()) { - ESPUI.updateControlValue(status_syringe_pump, "1"); + ESPUI.updateControlValue(status_syringe_pump, "1"); } ESPUI.updateControlValue(status_syringe_pump, "0"); } - /*************STYLE_METHODS****************/ void Web :: style (uint16_t id, int style) @@ -886,37 +848,31 @@ void Web :: set_initial_style() ***/ { //***ABOVE***// - style (status_syringe_pump, 2); style (stop_syringe_pump, 2); style (status_syringe_filled_placement, 2); style (syringe_filled_placement, 2); - style (status_limit_switch, 1); - style (calibration, 1); style_initialisation(3); style_exchange_configuration(3); - style (label_remaining_volume_mL, 3); style (remaining_volume_mL, 3); style (label_remaining_time_sec, 3); style (remaining_time_sec, 3); - //configurations style (syringe_volume_mL, 3); style (syringe_diameter_mm, 3); style (choose_syringe, 3); style (load_syringe_json, 3); - style (name_new_syringe, 3); style (internal_diameter_mm_new_syringe, 3); @@ -957,33 +913,30 @@ void Web :: set_theme(int theme) { if (theme ==1) { - //Creation des différents styles - - //Les verts pour la mise en mrche de la seringue - sprintf(couleur1, "background-color: #%06X;", (unsigned int) 0xb2dbbf); - sprintf(couleur2, "background-color: #%06X;", (unsigned int) 0x5a8668); + //Creation des différents styles - //Le rouge pour la seringue a l'arrêt - sprintf(couleur3, "background-color: #%06X;", (unsigned int) 0xc97064); - sprintf(couleur4, "background-color: #%06X;", (unsigned int) 0x762419); + //Les verts pour la mise en mrche de la seringue + sprintf(couleur1, "background-color: #%06X;", (unsigned int) 0xb2dbbf); + sprintf(couleur2, "background-color: #%06X;", (unsigned int) 0x5a8668); - //Les marrons pour la config des seringues - sprintf(couleur5, "background-color: #%06X;", (unsigned int) 0xce9f6f); - sprintf(couleur6, "background-color: #%06X;", (unsigned int) 0x926448); + //Le rouge pour la seringue a l'arrêt + sprintf(couleur3, "background-color: #%06X;", (unsigned int) 0xc97064); + sprintf(couleur4, "background-color: #%06X;", (unsigned int) 0x762419); - //Pas utilisé pour le moment - sprintf(couleur7, "background-color: #%06X;", (unsigned int) 0x0a7477); - sprintf(couleur8, "background-color: #%06X;", (unsigned int) 0x052a38); - sprintf(couleur9, "background-color: #%06X;", (unsigned int) 0x044365); - sprintf(couleur10, "background-color: #%06X;", (unsigned int) 0x58b8c3); + //Les marrons pour la config des seringues + sprintf(couleur5, "background-color: #%06X;", (unsigned int) 0xce9f6f); + sprintf(couleur6, "background-color: #%06X;", (unsigned int) 0x926448); + //Pas utilisé pour le moment + sprintf(couleur7, "background-color: #%06X;", (unsigned int) 0x0a7477); + sprintf(couleur8, "background-color: #%06X;", (unsigned int) 0x052a38); + sprintf(couleur9, "background-color: #%06X;", (unsigned int) 0x044365); + sprintf(couleur10, "background-color: #%06X;", (unsigned int) 0x58b8c3); - } } - void Web :: style_syringe_pump_on() /*** -Argument : / @@ -1027,7 +980,6 @@ void Web :: style_syringe_filled_placement_on() ESPUI.print(status_syringe_filled_placement, "En place"); style (status_syringe_filled_placement, 1); style (syringe_filled_placement, 1); - ESPUI.setEnabled(calibration, false); style (calibration, 2); } @@ -1049,7 +1001,6 @@ void Web :: style_syringe_filled_placement_off() style (calibration, 1); } - void Web :: style_initialisation(int style_choice) { style (fast_forward, style_choice); @@ -1072,7 +1023,6 @@ void Web :: style_exchange_configuration(int style_choice) style (start_exchange, style_choice); } - //OTHER METHODS void Web :: select_syringe_update(uint16_t tab) /*** @@ -1091,7 +1041,6 @@ void Web :: select_syringe_update(uint16_t tab) option_nb++; } - } -- GitLab