Skip to content
Snippets Groups Projects
syringe.cpp 2.6 KiB
Newer Older
#include <math.h>

#include "syringe.h"
    set_syringe("BD_10mL",  10, 14.5);
    //set_syringe("Terumo_5mL", 5, 10);
    //set_syringe("Terumo_2mL", 2, 3);
    //set_syringe("FisherBrand_1mL", 1, 0.5);
Malaurie Bernard's avatar
Malaurie Bernard committed
//SET METHODS
void Syringe :: set_syringe(String name, float total_volume_mL, float internal_diameter_mm)
{
    set_total_volume_mL(name, total_volume_mL);
    set_internal_diameter_mm(name, internal_diameter_mm);
}

void Syringe :: set_total_volume_mL(String name, float total_volume_mL)
    syringe_json[name]["total_volume_mL"] = total_volume_mL;
void Syringe :: set_internal_diameter_mm(String name, float internal_diameter_mm)
David Gauchard's avatar
David Gauchard committed
{
    syringe_json[name]["internal_diameter_mm"] = internal_diameter_mm;
David Gauchard's avatar
David Gauchard committed
}

David Gauchard's avatar
David Gauchard committed

Malaurie Bernard's avatar
Malaurie Bernard committed
//GET METHODS
float Syringe :: get_total_volume_mL(String name)
    return syringe_json[name]["total_volume_mL"].as<float>();
float Syringe :: get_internal_diameter_mm(String name)
    return syringe_json[name]["internal_diameter_mm"].as<float>();
const StaticJsonDocument<200>& Syringe :: get_syringe_database()
{
const JsonObject Syringe :: get_syringe_database_object()
{
    return syringe_json.as<JsonObject>();
}
//CONFIGURATION
bool Syringe :: check_configuration(String name)
{
    else if (syringe_json[name]["internal_diameter_mm"] < 0)
//Example : File f = ({ InterruptLock lock; filesystem->open(filename, "w"); }); and the f becomes the argument input_stream
void Syringe :: write_Json ()
-Argument : input_stream (= serial or a file)
-Return   : /
-Action   : Save the Json structure in a file (convert it to text)
***/
InterruptLock lock; //useful thanks to its constructor (so a is not visible in the code)
File f = filesystem->open("syringe_json", "w"); //Creation du fichier
size_t a = serializeJson(syringe_json, f); //remettre f a la plce de json
Serial.println("Taille de syringe_json");
Serial.println(a);
f.close();
}

//useful in setup of pousse-seringue.cpp(to check at the begining what has already been saved) and web.cpp via a button to recover data
void Syringe :: read_Json ()
-Argument : output_stream (= serial or a file)
-Action   : Check if a Json Document alredy exist or not, if it does it is load
InterruptLock lock; //useful thanks to its constructor (so a is not visible in the code)
Malaurie Bernard's avatar
Malaurie Bernard committed
File f = filesystem->open("syringe_json", "r");
deserializeJson(syringe_json, f);