diff --git a/RestServer/humidityserver/CMakeLists.txt b/RestServer/humidityserver/CMakeLists.txt index acf51fb..35593f5 100644 --- a/RestServer/humidityserver/CMakeLists.txt +++ b/RestServer/humidityserver/CMakeLists.txt @@ -19,35 +19,6 @@ add_custom_command(OUTPUT ${HUMIDITYSERVER_CODEGEN_SOURCES} file(GLOB HUMIDITYSERVER_SOURCES ${PROJECT_SOURCE_DIR}/*.c*) list(APPEND HUMIDITYSERVER_SOURCES ${HUMIDITYSERVER_CODEGEN_SOURCES}) -### ngrest-db BEGIN - -FUNCTION(CODEGEN_FILES_DB outVar prefix) - SET(listVar "") - FOREACH(file ${ARGN}) - get_filename_component(fileBase "${file}" NAME_WE) - LIST(APPEND listVar "${prefix}/${fileBase}Entities.h") - LIST(APPEND listVar "${prefix}/${fileBase}Entities.cpp") - ENDFOREACH(file) - SET(${outVar} "${listVar}" PARENT_SCOPE) -ENDFUNCTION(CODEGEN_FILES_DB) - - -set(HUMIDITYSERVER_DB_CODEGEN_DIR "${PROJECT_BINARY_DIR}/codegen-ngrest-db") - -PREPEND(HUMIDITYSERVER_DB_HEADERS_PATHS ${PROJECT_SOURCE_DIR} ${HUMIDITYSERVER_HEADERS}) - -CODEGEN_FILES_DB(HUMIDITYSERVER_DB_CODEGEN_SOURCES ${HUMIDITYSERVER_DB_CODEGEN_DIR} ${HUMIDITYSERVER_HEADERS}) - -add_custom_command(OUTPUT ${HUMIDITYSERVER_DB_CODEGEN_SOURCES} - COMMAND ${NGREST_BIN_PATH}ngrestcg -i "${PROJECT_SOURCE_DIR}" -o ${HUMIDITYSERVER_DB_CODEGEN_DIR} -t dbentity ${HUMIDITYSERVER_HEADERS} - DEPENDS ${HUMIDITYSERVER_HEADERS_PATHS} -) - -list(APPEND HUMIDITYSERVER_SOURCES ${HUMIDITYSERVER_DB_CODEGEN_SOURCES}) - -include_directories(${PROJECT_SOURCE_DIR} ${HUMIDITYSERVER_DB_CODEGEN_DIR}) - -### ngrest-db END include_directories(${PROJECT_SOURCE_DIR} $ENV{NGREST_EXT_INCLUDES}) @@ -59,8 +30,3 @@ set_target_properties(humidityserver PROPERTIES ) target_link_libraries(humidityserver ngrestutils ngrestcommon ngrestjson ngrestengine $ENV{NGREST_EXT_LIBS}) -### ngrest-db BEGIN - -target_link_libraries(humidityserver ngrestdbcommon ngrestdbmysql) - -### ngrest-db END diff --git a/RestServer/humidityserver/src/datatypes.h b/RestServer/humidityserver/src/datatypes.h deleted file mode 100644 index 6aac665..0000000 --- a/RestServer/humidityserver/src/datatypes.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef DATATYPES_H -#define DATATYPES_H - -#include - -#include - -namespace ngrest { -namespace humidityserver { - -// *table: stats -struct stat -{ - // *pk: true - // *autoincrement: true - int id; - - // *unique: false - // *type: int - int node_id; - - // *unique: false - // *type: int - int pin; - - // *unique: false - // *type: float - float humidity; - - // *unique: false - // *type: float - float temperature; - - // *unique: false - // *type: int - int isoutside; - - // *unique: false - // *type: float - float gm3; - - // *type: timestamp - // *default: CURRENT_TIMESTAMP - // *ignoreOnInsert: true - std::string created_at; -}; - -} // namespace humidityserver -} // namespace ngrest - -#endif diff --git a/RestServer/humidityserver/src/humidityserver.cpp b/RestServer/humidityserver/src/humidityserver.cpp index 1ef267a..3772ea4 100644 --- a/RestServer/humidityserver/src/humidityserver.cpp +++ b/RestServer/humidityserver/src/humidityserver.cpp @@ -5,56 +5,14 @@ #include "calculate.h" #include -//#include "datatypes.h" -/*std::string humidityserver::echo(const std::string& text) -{ - return "Hi, " + text; -}*/ - -struct stat -{ - // *pk: true - // *autoincrement: true - int id; - - // *unique: false - // *type: int - int node_id; - - // *unique: false - // *type: int - int pin; - - // *unique: false - // *type: float - float humidity; - - // *unique: false - // *type: float - float temperature; - - // *unique: false - // *type: int - int isoutside; - - // *unique: false - // *type: float - float gm3; - - // *type: timestamp - // *default: CURRENT_TIMESTAMP - // *ignoreOnInsert: true - std::string created_at; -}; float humidityserver::absolutehumidity(float temperature, float humidity) { - ngrest::MySqlDb mysqlDb({"stats", "dhtuser", "raspberry"}); - ngrest::Table stats(&mySqlDb); + //Format: node_id, pin, humidity, temperature, gm3, isoutside int node_id = 1; int pin = 0; int isoutside = 0; float absHum = absoluteHumidityFloat(temperature, humidity); - stats.insert({node_id, pin, humidity, temperature, absHum, isoutside}); + return absHum; } diff --git a/RestServer/humidityserver/src/humidityserver.h b/RestServer/humidityserver/src/humidityserver.h index cdbf2bf..85e043b 100644 --- a/RestServer/humidityserver/src/humidityserver.h +++ b/RestServer/humidityserver/src/humidityserver.h @@ -4,8 +4,6 @@ #ifndef HUMIDITYSERVER_H #define HUMIDITYSERVER_H -#include -#include #include //! Dummy description for the service