Newer
Older
Malaurie Bernard
committed
void Web :: web_setup()
Malaurie Bernard
committed
Malaurie Bernard
committed
last_time = 0;
Malaurie Bernard
committed
couleurs[0] = couleur1;
couleurs[1] = couleur2;
couleurs[2] = couleur3;
couleurs[3] = couleur4;
couleurs[4] = couleur5;
couleurs[5] = couleur6;
couleurs[6] = couleur7;
couleurs[7] = couleur8;
couleurs[8] = couleur9;
couleurs[9] = couleur10;
//Create tabs
configurations = ESPUI.addControl(ControlType::Tab, "Configurations", "Configurations");
new_syringe = ESPUI.addControl(ControlType::Tab, "Nouvelle Seringue", "Nouvelle seringue");
features = ESPUI.addControl(ControlType::Tab, "Caracteristiques du pousse-seringue", "Caracteristiques du pousse-seringue");
//***ABOVE***//
//***Syringe-pump***//
status_syringe_pump = ESPUI.label("Etat du pousse-seringue :", ControlColor::None, "A l'arrêt");
Malaurie Bernard
committed
stop_syringe_pump = ESPUI.addControl(ControlType::Button, "Mise en marche", "\u26D4", ControlColor::None, status_syringe_pump, [&](Control* sender, int value){stop_syringe_pump_callback(sender, value);});
//***Syringe-filled***//
Malaurie Bernard
committed
status_syringe_filled_placement = ESPUI.label("Etat de la seringue :", ControlColor::None, "Enlevée");
Malaurie Bernard
committed
syringe_filled_placement = ESPUI.addControl(ControlType::Switcher, "Mise en marche", "Arrêt", ControlColor::None, status_syringe_filled_placement,[&](Control* sender, int value){syringe_filled_placement_callback(sender, value);});
ESPUI.addControl(ControlType::Separator, "", "", ControlColor::None);
Malaurie Bernard
committed
//***Limit-switch***//
status_limit_switch = ESPUI.label("Etat du capteur de fin de course:", ControlColor::None, "Off");
//***Initialisation***//
Malaurie Bernard
committed
calibration = ESPUI.button("Callibration", [&](Control* sender, int value){calibration_callback(sender, value);}, ControlColor::None, "\u21E4");
Malaurie Bernard
committed
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);});
Malaurie Bernard
committed
Malaurie Bernard
committed
confirm_initialisation = ESPUI.button("Valider l'initialisation", [&](Control* sender, int value){confirm_initialisation_callback(sender, value);}, ControlColor::None, "\u2714");
Malaurie Bernard
committed
ESPUI.addControl(ControlType::Separator, "", "", ControlColor::None);
Malaurie Bernard
committed
initial_volume_mL_label =ESPUI.addControl( ControlType::Label, "Configuration de l'échange", "Volume initial contenu dans la seringue : ", ControlColor::None);
Malaurie Bernard
committed
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);});
Malaurie Bernard
committed
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);
Malaurie Bernard
committed
volume_exchange_mL = ESPUI.addControl(ControlType::Number,"Configuration de l'échange", "0", ControlColor::None, initial_volume_mL_label, [&](Control* sender, int value){volume_exchange_mL_callback(sender, value);});
Malaurie Bernard
committed
number_max_min(0, 500, volume_exchange_mL);
exchange_throughtput_uL_per_sec_label = ESPUI.addControl(ControlType::Label, "Configuration de l'échange", "Débit de l'échange en uL/sec", ControlColor::None, initial_volume_mL_label);
Malaurie Bernard
committed
exchange_throughtput_uL_per_sec = ESPUI.addControl(ControlType::Number,"Configuration de l'échange", "0", ControlColor::None, initial_volume_mL_label, [&](Control* sender, int value){exchange_throughtput_uL_per_sec_callback(sender, value);});
Malaurie Bernard
committed
number_max_min(0, 500, exchange_throughtput_uL_per_sec);
label_push_pull_choice = ESPUI.addControl(ControlType::Label, "Injection ou Aspiration", "Injection", ControlColor::None, initial_volume_mL_label);
Malaurie Bernard
committed
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
Malaurie Bernard
committed
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);});
Malaurie Bernard
committed
//Remaning_values
label_remaining_volume_mL = ESPUI.label("Caractéristiques de l'échange en cours", ControlColor::None, "Volume restant en mL");
Malaurie Bernard
committed
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);});
Malaurie Bernard
committed
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);
Malaurie Bernard
committed
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);});
Malaurie Bernard
committed
syringe_selection = ESPUI.addControl(ControlType::Select, "Choix de la seringue :", "", ControlColor::None, configurations, [&](Control* sender, int value){syringe_selection_callback(sender, value);});
select_syringe_maj(configurations);
syringe_volume_mL_value = 5;
syringe_volume_mL_string = "Volume total: " + std::to_string(syringe_volume_mL_value) + "mL";
syringe_volume_mL =ESPUI.addControl( ControlType::Label, "Caractéristiques de la seringue : ", syringe_volume_mL_string.c_str() , ControlColor::None, configurations);
syringe_diameter_mm_value = 5;
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);
Malaurie Bernard
committed
Malaurie Bernard
committed
choose_syringe = ESPUI.addControl(ControlType::Button, "Choisir cette seringue", "\u2714", ControlColor::None, syringe_selection, [&](Control* sender, int value){choose_syringe_callback(sender, value);});
Malaurie Bernard
committed
ESPUI.addControl(ControlType::Separator, "", "", ControlColor::None, configurations);
name_new_syringe_label = ESPUI.addControl(ControlType::Label, "Nouvelle seringue", "Nom de la seringue :", ControlColor::None, new_syringe);
Malaurie Bernard
committed
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);});
Malaurie Bernard
committed
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);
Malaurie Bernard
committed
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);});
Malaurie Bernard
committed
internal_diameter_mm_new_syringe_value = 5;
Malaurie Bernard
committed
number_max_min(0, 500, internal_diameter_mm_new_syringe);
Malaurie Bernard
committed
total_volume_mL_new_syringe_label =ESPUI.addControl(ControlType::Label, "Nouvelle seringue", "Volume total de la seringue en mL :", ControlColor::None, name_new_syringe_label);
Malaurie Bernard
committed
total_volume_mL_new_syringe = ESPUI.addControl(ControlType::Number, "Volume total de la seringue en mL", "5", ControlColor::None, name_new_syringe_label, [&](Control* sender, int value){total_volume_mL_new_syringe_callback(sender, value);});
Malaurie Bernard
committed
total_volume_mL_new_syringe_value = 5;
Malaurie Bernard
committed
number_max_min(0, 500, total_volume_mL_new_syringe);
Malaurie Bernard
committed
ESPUI.addControl(ControlType::Separator, "Je suis là", "", ControlColor::None, name_new_syringe_label);
Malaurie Bernard
committed
add_syringe = ESPUI.addControl(ControlType::Button, "Ajouter la seringue", "\u2714", ControlColor::None, new_syringe, [&](Control* sender, int value){add_syringe_callback(sender, value);});
Malaurie Bernard
committed
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);});
Malaurie Bernard
committed
Malaurie Bernard
committed
lead_screw_pitch_mm = ESPUI.addControl(ControlType::Number, "Avance par tour", "0.7", ControlColor::None, features, [&](Control* sender, int value){number_callback(sender, value);});
Malaurie Bernard
committed
clockwise_equals_push_label = ESPUI.addControl(ControlType::Label, "Sens de rotation du moteur", "Horaire = Injection", ControlColor::None, features);
Malaurie Bernard
committed
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
Malaurie Bernard
committed
microstep_configuration = ESPUI.addControl(ControlType::Number, "Configuration Hardware des microsteps", "16", ControlColor::None, features, [&](Control* sender, int value){microstep_configuration_callback(sender, value);});
Malaurie Bernard
committed
motor_steps = ESPUI.addControl(ControlType::Number, "Caractéristique du moteur (nombre de pas possibles ?)", "2000", ControlColor::None, features,[&](Control* sender, int value){motor_steps_callback(sender, value);});
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);});
Malaurie Bernard
committed
set_initial_style();
ESPUI.begin("ESPUI Control");
Malaurie Bernard
committed
void Web :: number_callback(Control* sender, int type)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Print the value of the number controller via the serial port.
***/
Serial.println("Type: number");
Serial.println(String("Value: ") + String(sender->value));
Serial.println(String("ID: ") + sender->id);
Serial.println("");
//SPECIFIC CALLBACKS//
//***ABOVE***//
Malaurie Bernard
committed
void Web :: stop_syringe_pump_callback (Control* sender, int value)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Linking the switch of the syringe pump status and the actions.
***/
Malaurie Bernard
committed
{
style_syringe_pump_off();
Serial.println("Syringe_pump stopped");
Serial.println(String("ID: ") + sender->id);
Serial.println("");
Malaurie Bernard
committed
void Web :: syringe_filled_placement_callback (Control* sender, int value)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Linking the switch of the syringe filled status(placed or not) and the actions.
***/
Malaurie Bernard
committed
{
style_syringe_filled_placement_on();
break;
case S_INACTIVE:
style_syringe_filled_placement_off();
Serial.println("Syringe_filled_placement");
Serial.println(String("Value: ") + String(sender->value));
Serial.println(String("ID: ") + sender->id);
Serial.println("");
Malaurie Bernard
committed
void Web :: calibration_callback (Control *sender, int type)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Enable the syringe-pump calibration and change the style appropriately.
***/
{
if((type == B_UP)) {
syringe_filled.go_to_zero();
ESPUI.print(status_syringe_pump, "En marche");
style (status_syringe_pump, 1);
Malaurie Bernard
committed
style (stop_syringe_pump, 1);
Serial.println("Calibration");
Serial.println(String("Value: ") + String(sender->type));
Serial.println(String("ID: ") + sender->id);
Serial.println("");
Malaurie Bernard
committed
void Web :: fast_backward_callback (Control *sender, int type)
Malaurie Bernard
committed
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action :
***/
{
switch (type)
{
case B_DOWN:
digitalWrite(SLEEP, LOW);
Malaurie Bernard
committed
syringe_filled.move_to_mm(syringe_filled.get_clockwise_equals_push()? -50:50);
Malaurie Bernard
committed
syringe_filled.set_speed_mm_per_sec(50);
break;
case B_UP:
style_syringe_pump_off();
Malaurie Bernard
committed
motor_release_action();
Malaurie Bernard
committed
break;
}
serial_print ("Fast_backward", sender);
Malaurie Bernard
committed
}
Malaurie Bernard
committed
void Web :: fast_forward_callback (Control *sender, int type)
Malaurie Bernard
committed
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action :
***/
{
switch (type)
{
case B_DOWN:
digitalWrite(SLEEP, LOW);
Malaurie Bernard
committed
syringe_filled.move_to_mm(syringe_filled.get_clockwise_equals_push()? 50:-50);
Malaurie Bernard
committed
syringe_filled.set_speed_mm_per_sec(50);
break;
case B_UP:
style_syringe_pump_off();
motor_release_action();
Malaurie Bernard
committed
break;
}
serial_print ("Fast_forward", sender);
Malaurie Bernard
committed
}
Malaurie Bernard
committed
void Web :: slow_backward_callback (Control *sender, int type)
Malaurie Bernard
committed
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action :
***/
{
switch (type)
{
case B_DOWN:
digitalWrite(SLEEP, LOW);
Malaurie Bernard
committed
syringe_filled.move_to_mm(syringe_filled.get_clockwise_equals_push()? -50:50);
Malaurie Bernard
committed
syringe_filled.set_speed_mm_per_sec(0.5);
break;
case B_UP:
style_syringe_pump_off();
motor_release_action();
Malaurie Bernard
committed
break;
}
serial_print ("Slow_backward", sender);
Malaurie Bernard
committed
}
Malaurie Bernard
committed
void Web :: slow_forward_callback (Control *sender, int type)
Malaurie Bernard
committed
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action :
***/
{
switch (type)
{
case B_DOWN:
digitalWrite(SLEEP, LOW);
Malaurie Bernard
committed
syringe_filled.move_to_mm(syringe_filled.get_clockwise_equals_push()? 50:-50);
Malaurie Bernard
committed
syringe_filled.set_speed_mm_per_sec(0.5);
break;
case B_UP:
style_syringe_pump_off();
motor_release_action();
Malaurie Bernard
committed
break;
}
serial_print ("Slow_forward", sender);
Malaurie Bernard
committed
}
Malaurie Bernard
committed
void Web :: confirm_initialisation_callback (Control *sender, int type)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action :
***/
{
switch (type)
{
case B_DOWN:
syringe_filled.reset_position();
break;
case B_UP:
break;
}
serial_print ("Confirm_initialisation", sender);
Malaurie Bernard
committed
void Web :: volume_exchange_mL_callback (Control* sender, int value)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Enable to choose the volume that woud be exchanged.
***/
Malaurie Bernard
committed
{
Malaurie Bernard
committed
syringe_filled.set_exchange_volume_mL(atof(sender->value.c_str()));
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("");
Malaurie Bernard
committed
void Web :: exchange_throughtput_uL_per_sec_callback (Control* sender, int value)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Enable to choose the volume that woud be exchanged.
***/
Malaurie Bernard
committed
{
syringe_filled.set_exchange_throughput_uL_per_sec(atof(sender->value.c_str()));
syringe_filled.write_Json ();
serial_print ("Exchange_throughtput (sender->value)", sender);
Serial.println("Exchange_throughtput (json value)");
Serial.println(String("Value: ") + String(syringe_filled.get_exchange_throughput_uL_per_sec()));
Serial.println("");
Malaurie Bernard
committed
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.
-Return : /
-Action : Change the label_push_pull_choice to display the choice.
Change the style of the controller involved.
***/
Malaurie Bernard
committed
{
switch (value)
{
case S_ACTIVE:
syringe_filled.set_push(true);
break;
case S_INACTIVE:
syringe_filled.set_push(false);
ESPUI.print(label_push_pull_choice, "Aspiration");
syringe_filled.write_Json();
serial_print ("Push_pull_choice (sender->value)", sender);
Serial.println("Push_pull_choice (json value)");
Serial.println(String("Value: ") + String(syringe_filled.get_push()));
Serial.println("");
Malaurie Bernard
committed
void Web :: remaining_volume_mL_callback (Control* sender, int value)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Linking the display with the current volume remaining.
***/
Malaurie Bernard
committed
{
ESPUI.updateSlider(remaining_volume_mL, syringe_filled.get_remaining_volume_mL());
}
Malaurie Bernard
committed
void Web :: remaining_time_sec_callback (Control* sender, int value)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Linking the display with the current time remaining for the exchange.
***/
Malaurie Bernard
committed
{
float remaining_time_sec_value = syringe_filled.get_remaining_volume_mL()/syringe_filled.get_exchange_throughput_uL_per_sec();
ESPUI.updateSlider(remaining_time_sec, remaining_time_sec_value);
}
Malaurie Bernard
committed
void Web :: start_exchange_callback (Control* sender, int value)
{
syringe_filled.start_exchange();
style_syringe_pump_on();
serial_print ("Exchange start", sender);
Malaurie Bernard
committed
}
//configurations = Configurations
Malaurie Bernard
committed
Malaurie Bernard
committed
void Web :: initial_volume_mL_callback (Control* sender, int value)
{
Malaurie Bernard
committed
syringe_filled.set_remaining_volume_mL((sender->value).toFloat());
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("");
Malaurie Bernard
committed
}
Malaurie Bernard
committed
void Web :: choose_syringe_callback (Control* sender, int value)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Print the value of the button state via the serial port.
***/
Malaurie Bernard
committed
{
switch (value)
{
case B_DOWN:
//syringe_volume_mL_value = 2; //Mettre la valeur associé au nom choisit du select
syringe_volume_mL_value = syringe.get_syringe_database()[select_value]["total_volume_mL"];
syringe_volume_mL_string = "Volume total: " + std::to_string(syringe_volume_mL_value) + "mL";
ESPUI.print(syringe_volume_mL, syringe_volume_mL_string.c_str());
//syringe_diameter_mm_value = 1; //Mettre la valeur associé au nom choisit du select
syringe_diameter_mm_value = syringe.get_syringe_database()[select_value]["internal_diameter_mm"];
syringe_diameter_mm_string = "internal diameter : " + std::to_string(syringe_diameter_mm_value) + "mm";
ESPUI.print(syringe_diameter_mm, syringe_diameter_mm_string.c_str());
case B_UP:
break;
}
serial_print ("choose_syringe", sender);
serial_print ("name_new_syringe (sender->value)", sender);
Serial.println("Volume_total (json value)");
Malaurie Bernard
committed
Serial.println(String("Value: ") + String((syringe.get_syringe_database()[syringe_filled.get_name_syringe()]["total_volume_mL"]).as<const char*>()));
Serial.println("");
Serial.println("internal_diameter (json value)");
Malaurie Bernard
committed
Serial.println(String("Value: ") + String(syringe.get_syringe_database()[syringe_filled.get_name_syringe()]["internal_diameter"].as<const char*>()));
Serial.println("");
}
Malaurie Bernard
committed
void Web :: name_new_syringe_callback(Control* sender, int type)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Print the value of the new syringe name chosen via the serial port.
***/
{
Malaurie Bernard
committed
name_new_syringe_value = sender->value;
serial_print ("name_new_syringe (sender->value)", sender);
Malaurie Bernard
committed
}
Malaurie Bernard
committed
void Web :: total_volume_mL_new_syringe_callback(Control* sender, int type)
Malaurie Bernard
committed
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Print the value of the new syringe name chosen via the serial port.
***/
{
total_volume_mL_new_syringe_value = sender->value;
serial_print ("total_volume_new_syringe", sender);
Malaurie Bernard
committed
}
Malaurie Bernard
committed
void Web :: internal_diameter_mm_new_syringe_callback(Control* sender, int type)
Malaurie Bernard
committed
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Print the value of the new syringe name chosen via the serial port.
***/
{
internal_diameter_mm_new_syringe_value = sender->value,
serial_print ("internal_diameter_new_syringe", sender);
Malaurie Bernard
committed
void Web :: add_syringe_callback (Control* sender, int value)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Print the value of the button state via the serial port.
Enable to save data in the syringe_json file.
***/
Malaurie Bernard
committed
{
switch (value)
{
Malaurie Bernard
committed
syringe.set_syringe(name_new_syringe_value, total_volume_mL_new_syringe_value.toFloat(), internal_diameter_mm_new_syringe_value.toFloat());
syringe.write_Json();
Malaurie Bernard
committed
ESPUI.addControl(ControlType::Option, name_new_syringe_value.c_str(), name_new_syringe_value.c_str(), ControlColor::None, syringe_selection);
case B_UP:
break;
}
serial_print ("add_syringe", sender);
//features : Configurations avancées
Malaurie Bernard
committed
void Web :: syringe_pump_length_mm_callback(Control* sender, int type)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Print the value of the number controller via the serial port.
Change the syringe_pump_length value
syringe_filled.set_syringe_pump_length_mm(sender->type);
serial_print ("syringe_pump_length (sender->value)", sender);
Serial.println("syringe_pump_length (json value)");
Serial.println(String("Value: ") + String(syringe_filled.get_syringe_pump_length_mm()));
Serial.println("");
Malaurie Bernard
committed
void Web :: clockwise_equals_push_callback(Control* sender, int value)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Print the value of the convention chosen via the serial port.
Change the clockwise_equals_push_label to display the information.
***/
{
switch (value)
{
case S_ACTIVE:
syringe_filled.set_clockwise_equals_push(true);
ESPUI.print(clockwise_equals_push_label, "Horaire = Injection");
break;
case S_INACTIVE:
syringe_filled.set_clockwise_equals_push(false);
ESPUI.print(clockwise_equals_push_label, "Horaire = Aspiration");
break;
serial_print ("clockwise_equals_push (sender->value)", sender);
Serial.println("clockwise_equals_push (json value)");
Serial.println(String("Value: ") + String(syringe_filled.get_clockwise_equals_push()));
Serial.println("");
}
Malaurie Bernard
committed
void Web :: microstep_configuration_callback(Control* sender, int type)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Print the value of the number controller via the serial port.
Change the microstep_configuration value.
***/
{
syringe_filled.set_microstep_configuration(sender->type);
syringe_filled.write_Json();
serial_print ("microstep_configuration (sender->value)", sender);
Serial.println("microstep_configuration (json value)");
Serial.println(String("Value: ") + String(syringe_filled.get_microstep_configuration()));
Serial.println("");
}
Malaurie Bernard
committed
void Web :: motor_steps_callback(Control* sender, int type)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Print the value of the number controller via the serial port.
Change the motor_steps value.
***/
{
syringe_filled.set_motor_steps(sender->type);
syringe_filled.write_Json();
serial_print ("motor_steps (sender->value)", sender);
Serial.println("motor_steps (json value)");
Serial.println(String("Value: ") + String(syringe_filled.get_motor_steps()));
Serial.println("");
}
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
void Web :: motor_release_callback(Control* sender, int value)
{
switch (value)
{
case S_ACTIVE:
syringe_filled.set_motor_release(true);
ESPUI.print(motor_release_label, "On");
syringe_filled.write_Json();
break;
case S_INACTIVE:
syringe_filled.set_motor_release(false);
if (!syringe_filled.is_running())
digitalWrite(SLEEP, HIGH);
ESPUI.print(motor_release_label, "Off");
syringe_filled.write_Json();
break;
}
serial_print ("motor_release (sender->value)", sender);
Serial.println("motor_release (json value)");
Serial.println(String("Value: ") + String(syringe_filled.get_motor_release()));
Serial.println("");
}
Malaurie Bernard
committed
void Web :: syringe_selection_callback(Control* sender, int value)
/***
-Argument : Pointer to the controller calling the function, integer according to the controller type.
-Return : /
-Action : Print the value of the syringe name chosen via the serial port.
***/
{
select_value = sender->value;
syringe_filled.set_name_syringe(select_value);
serial_print ("syringe_selection (sender->value)", sender);
}
Malaurie Bernard
committed
//ON_OFF METHODS
Malaurie Bernard
committed
Malaurie Bernard
committed
void Web :: syringe_pump_on_off()
/***
-Argument : /
-Return : /
-Action : Update the display of the syringe-pump status to match when the motor runs or not (so when we initialize, it stop by itself)
***/
{
if (syringe_filled.is_running())
{
Malaurie Bernard
committed
ESPUI.updateControlValue(status_syringe_pump, "1");
Malaurie Bernard
committed
ESPUI.updateControlValue(status_syringe_pump, "0");
/*************STYLE_METHODS****************/
Malaurie Bernard
committed
void Web :: style (uint16_t id, int style)
/***
-Argument : The controller id and the style wanted.
-Return : /
-Action : Change style (1 is active, green; 2 is inactive, red; 3 is neutral, brown)
***/
{
switch (style)
{
case 1:
ESPUI.setPanelStyle(id, couleurs[0]);
ESPUI.setElementStyle(id, couleurs[1]);
break;
case 2:
ESPUI.setPanelStyle(id, couleurs[2]);
ESPUI.setElementStyle(id, couleurs[3]);
break;
case 3:
ESPUI.setPanelStyle(id, couleurs[4]);
ESPUI.setElementStyle(id, couleurs[5]);
break;
}
}
Malaurie Bernard
committed
void Web :: set_initial_style()
/***
-Argument : /
-Return : /
-Action : Set up the initial style of every controller.
Malaurie Bernard
committed
{
//***ABOVE***//
style (status_syringe_pump, 2);
Malaurie Bernard
committed
style (stop_syringe_pump, 2);
Malaurie Bernard
committed
style (status_syringe_filled_placement, 2);
style (syringe_filled_placement, 2);
Malaurie Bernard
committed
style (status_limit_switch, 1);
Malaurie Bernard
committed
style (calibration, 1);
Malaurie Bernard
committed
Malaurie Bernard
committed
style_initialisation(3);
Malaurie Bernard
committed
style_exchange_configuration(3);
Malaurie Bernard
committed
style (label_remaining_volume_mL, 3);
style (label_remaining_time_sec, 3);
style (remaining_time_sec, 3);
style (syringe_volume_mL, 3);
style (syringe_diameter_mm, 3);
style (choose_syringe, 3);
style (name_new_syringe, 3);
style (internal_diameter_mm_new_syringe, 3);
style (total_volume_mL_new_syringe, 3);
style (add_syringe, 3);
style (name_new_syringe_label, 3);
style (internal_diameter_mm_new_syringe_label, 3);
style (total_volume_mL_new_syringe_label, 3);
style (add_syringe_label, 3);
style (syringe_pump_length_mm_value, 3);
style (clockwise_equals_push_label, 3);
style (clockwise_equals_push, 3);
style (microstep_configuration, 3);
style (motor_steps, 3);
style (motor_release_label, 3);
style (motor_release, 3);
Malaurie Bernard
committed
//
style (syringe_selection, 3);
Malaurie Bernard
committed
}
Malaurie Bernard
committed
void Web :: set_theme(int theme)
/***
-Argument : Integer defining the theme wanted.
-Return : /
-Action : Change the interface theme for dark, light of colorful theme.
***/
Malaurie Bernard
committed
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
{
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);
//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 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);
}
}
Malaurie Bernard
committed
void Web :: style_syringe_pump_on()
/***
-Argument : /
-Return : /
-Action : Change the status_syringe_pump label to display the information.
Change the style of the controller involved.
Causes the movement of the syringe pump.
***/
{
ESPUI.print(status_syringe_pump, "En marche");
style (status_syringe_pump, 1);
style (stop_syringe_pump, 1);
}
Malaurie Bernard
committed
void Web :: style_syringe_pump_off()
/***
-Argument : /
-Return : /
-Action : Change the status_syringe_pump label to display the information.
Change the style of the controller involved.
Causes the stop of the syringe pump.
***/
{
ESPUI.print(status_syringe_pump, "A l'arrêt");
style (status_syringe_pump, 2);
style (stop_syringe_pump, 2);
syringe_filled.stop();
}
Malaurie Bernard
committed
void Web :: style_syringe_filled_placement_on()
/***
-Argument : /
-Return : /
-Action : Change the status_syringe_filled label to display the information.
Change the style of the controller involved.
Disable the calibration.
***/
{
Malaurie Bernard
committed
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);
}
Malaurie Bernard
committed
void Web :: style_syringe_filled_placement_off()
/***
-Argument : /
-Return : /
-Action : Change the status_syringe_filled label to display the information.
Change the style of the controller involved.
Enable the calibration.
***/
{
Malaurie Bernard
committed
ESPUI.print(status_syringe_filled_placement, "Enlevée");
style (status_syringe_filled_placement, 2);
style (syringe_filled_placement, 2);
ESPUI.setEnabled(calibration, true);
style (calibration, 1);
}
Malaurie Bernard
committed
void Web :: style_initialisation(int style_choice)
Malaurie Bernard
committed
{
style (fast_forward, style_choice);
style (fast_backward, style_choice);
style (slow_forward, style_choice);
style (slow_backward, style_choice);
style (confirm_initialisation, style_choice);
}
Malaurie Bernard
committed
void Web :: style_exchange_configuration(int style_choice)
Malaurie Bernard
committed
{
style (initial_volume_mL, style_choice);
style (initial_volume_mL_label, style_choice);
style (volume_exchange_mL_label, style_choice);
style (volume_exchange_mL, style_choice);
style (exchange_throughtput_uL_per_sec_label, style_choice);
style (exchange_throughtput_uL_per_sec, style_choice);