diff --git a/syringe.cpp b/syringe.cpp index c8fa660018333e4e3fe37ac4d5438aba7909b9b4..7e5157577dbcd291930bcc3f28e5fdbf64f80ca2 100644 --- a/syringe.cpp +++ b/syringe.cpp @@ -3,26 +3,19 @@ #include "syringe.h" +Syringe syringe; + StaticJsonDocument<200> Syringe :: syringe_json; //200 = RAM allocated to this document -//CONSTRUCTORS +//CONSTRUCTOR Syringe :: Syringe() { //First Syringe + Serial.println("okk"); set_syringe("BD_10mL", "300912","BD", 10, 14.5); set_syringe("Terumo_5mL", "0197","Terumo", 5, 10); } -Syringe :: Syringe(String name, string ref, string brand, float total_volume_mL, float internal_diameter_mm) -{ - set_ref(name, ref); - set_brand(name, brand); - set_total_volume_mL(name, total_volume_mL); - set_internal_diameter_mm(name, internal_diameter_mm); - -} - - //SET METHODS void Syringe :: set_syringe(String name, string ref, string brand, float total_volume_mL, float internal_diameter_mm) @@ -82,6 +75,10 @@ const StaticJsonDocument<200>& Syringe :: get_syringe_database() { return syringe_json; } +const JsonObject Syringe :: get_syringe_database_object() +{ + return syringe_json.as<JsonObject>(); +} //CONFIGURATION @@ -111,9 +108,9 @@ void Syringe :: write_Json () -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 -serializeJson(syringe_json, f); +//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 +serializeJson(syringe_json, Serial); //remettre f a la plce de json } diff --git a/syringe.h b/syringe.h index 64b476f37cff51e27cb9424c5af3db11d87bf249..555badca0da9a09217e84d6a3dc6a5af801b3867 100644 --- a/syringe.h +++ b/syringe.h @@ -29,10 +29,9 @@ class Syringe public : - //CONSTRUCTORS + //CONSTRUCTOR Syringe(); //There is no arguments because we add the generic syringe to use - Syringe(String name, string ref, string brand, float total_volume_mL, float internal_diameter_mm); //There are arguments because we need to know what values to add in the Json document (no default syringe) - + //SET METHODS void set_syringe(String name, string ref, string brand, float total_volume_mL, float internal_diameter_mm); @@ -46,8 +45,11 @@ class Syringe string get_brand(String name); float get_total_volume_mL(String name); float get_internal_diameter_mm(String name); + static const StaticJsonDocument<200>& get_syringe_database(); + const JsonObject get_syringe_database_object(); + //CONFIGURATION bool check_configuration(String name); diff --git a/web.h b/web.h index e5092f706aeb551c9661afa604d92fbedc47ae73..3a0413e916068a66703f070f0492ca1935673a68 100644 --- a/web.h +++ b/web.h @@ -4,6 +4,7 @@ #include <DNSServer.h> #include <ESPUI.h> // https://github.com/s00500/ESPUI +#include <ArduinoJson.h> #include "common.h" #include "syringe.h"