diff --git a/control/CMakeLists.txt b/control/CMakeLists.txt
index 9a9251c1..70cd4d15 100644
--- a/control/CMakeLists.txt
+++ b/control/CMakeLists.txt
@@ -1,11 +1,13 @@
-cmake_minimum_required(VERSION 3.8)
+cmake_minimum_required(VERSION 3.10)
project("MainControl" LANGUAGES CXX)
-# Path to local GoogleTest directory
-set(GOOGLETEST_PATH "${CMAKE_SOURCE_DIR}/googletest")
+# Set the C++ standard
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
-# Add GoogleTest
-add_subdirectory(${GOOGLETEST_PATH} ${CMAKE_BINARY_DIR}/googletest)
+# Locate GTest
+find_package(GTest REQUIRED)
+include_directories(${GTEST_INCLUDE_DIRS})
# Find and include bson library
find_package(PkgConfig REQUIRED)
@@ -16,20 +18,36 @@ include_directories(${BSON_INCLUDE_DIRS})
file(GLOB SOURCES "src/*.cpp")
list(REMOVE_ITEM SOURCES "${CMAKE_SOURCE_DIR}/src/main.cpp")
+# Path to local communication directory
+
file(GLOB SOURCES_COMMUNICATION "../communication/src/*.cpp")
file(GLOB HEADERS_COMMUNICATION "../communication/include/*.h")
-
file(GLOB SOCKETS_COMMUNICATIONS "../communication/sockets/*.*" )
file(GLOB PARSER "../parser_json/src/*.*")
+file(GLOB LOGGER "../logger/*.*")
+
# Main executable
-add_executable(${PROJECT_NAME} ${SOURCES} ${PARSER} ${SOURCES_COMMUNICATION} ${HEADERS_COMMUNICATION} ${SOCKETS_COMMUNICATIONS} ../logger/logger.h ../logger/logger.cpp src/main.cpp)
+add_executable(${PROJECT_NAME} ${SOURCES} ${PARSER} ${SOURCES_COMMUNICATION} ${HEADERS_COMMUNICATION} ${SOCKETS_COMMUNICATIONS} ${LOGGER} src/main.cpp )
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include)
-target_link_libraries(${PROJECT_NAME} PRIVATE ${BSON_LIBRARIES})
+target_link_libraries(${PROJECT_NAME} PRIVATE ${BSON_LIBRARIES} )
# Test executable, including additional source files
file(GLOB TEST_SOURCES "test/*.cpp")
-add_executable(RunTests ${SOURCES} ${PARSER} ${SOURCES_COMMUNICATION} ${HEADERS_COMMUNICATION} ${SOCKETS_COMMUNICATIONS} ../logger/logger.h ../logger/logger.cpp ${TEST_SOURCES})
+add_executable(RunTests ${SOURCES} ${PARSER} ${SOURCES_COMMUNICATION} ${HEADERS_COMMUNICATION} ${SOCKETS_COMMUNICATIONS} ${LOGGER} ${TEST_SOURCES} )
target_include_directories(RunTests PRIVATE ${CMAKE_SOURCE_DIR}/include)
-target_link_libraries(RunTests PRIVATE ${BSON_LIBRARIES} gtest_main)
\ No newline at end of file
+target_link_libraries(RunTests PRIVATE ${BSON_LIBRARIES} ${GTEST_LIBRARIES} pthread)
+
+
+include(../hsm-client/use_hsm_client.cmake)
+find_library(HSM_CLIENT_LIB hsm_client_lib PATHS ${HSM_CLIENT_LIB_PATH})
+if(HSM_CLIENT_LIB)
+ message(STATUS "Found hsm_client_lib: ${HSM_CLIENT_LIB}")
+ target_link_libraries(${PROJECT_NAME} PRIVATE ${HSM_CLIENT_LIB} ${HSM_CLIENT_LIB_DEPS})
+ target_link_libraries(RunTests PRIVATE ${HSM_CLIENT_LIB} ${HSM_CLIENT_LIB_DEPS})
+ target_include_directories(${PROJECT_NAME} PRIVATE ${HSM_CLIENT_INCLUDE_DIRS})
+ target_include_directories(RunTests PRIVATE ${HSM_CLIENT_INCLUDE_DIRS})
+else()
+ message(FATAL_ERROR "Could not find hsm_client_lib at ${HSM_CLIENT_LIB_PATH}")
+endif()
\ No newline at end of file
diff --git a/control/README.md b/control/README.md
index dd1769a4..6418576b 100644
--- a/control/README.md
+++ b/control/README.md
@@ -1,6 +1,29 @@
-# Project-in-CMake
-*link to the sensor docs:*
-https://docs.google.com/document/d/1BF9DZk_YQt1yE8mERVzNyPVUT7JgtQxV-Xuj32yoiyM
+# Vehicle Computing Simulator
+## Main Computer
+
+[link to the main control design](https://docs.google.com/document/d/1oIO82QiBhqgoNgWj_fBRt7iy48YRa9Y28SvaeaOq1Ms)
-*link to the main control design:*
-https://docs.google.com/document/d/1oIO82QiBhqgoNgWj_fBRt7iy48YRa9Y28SvaeaOq1Ms
\ No newline at end of file
+**Installations:**
+
+```bash
+
+sudo apt-get install libbson-dev
+sudo apt-get install nlohmann-json3-dev
+sudo apt install pkg-config
+
+```
+
+google tests:
+
+```bash
+
+sudo apt update
+sudo apt install cmake libgtest-dev
+cd /usr/src/googletest/googletest
+sudo mkdir build
+cd build
+sudo cmake ..
+sudo make
+sudo make install
+
+```
diff --git a/control/camera.json b/control/camera.json
new file mode 100644
index 00000000..7a1f8801
--- /dev/null
+++ b/control/camera.json
@@ -0,0 +1,43 @@
+{
+ "endianness": "little",
+ "HSMusage": true,
+ "fields": [
+ {
+ "fields": [
+ {
+ "name": "MessageType",
+ "size": 1,
+ "type": "unsigned_int",
+ "defaultValue": 1
+ },
+ {
+ "name": "Level",
+ "size": 3,
+ "type": "unsigned_int",
+ "defaultValue": 1
+ },
+ {
+ "name": "ObjectType",
+ "size": 4,
+ "type": "unsigned_int",
+ "defaultValue": 1
+ }
+ ],
+ "name": "AlertDetails",
+ "size": 8,
+ "type": "bit_field"
+ },
+ {
+ "name": "ObjectDistance",
+ "size": 32,
+ "type": "float_fixed",
+ "defaultValue": 100.0
+ },
+ {
+ "name": "relativeVelocity",
+ "size": 32,
+ "type": "float_fixed",
+ "defaultValue": 100
+ }
+ ]
+}
\ No newline at end of file
diff --git a/control/include/full_condition.h b/control/include/full_condition.h
index 0c89669b..a98e41a1 100644
--- a/control/include/full_condition.h
+++ b/control/include/full_condition.h
@@ -14,6 +14,7 @@
#include "basic_condition.h"
#include "root.h"
#include "condition_factory.h"
+#include "hsm_support.h"
class Root;
diff --git a/control/include/global_properties.h b/control/include/global_properties.h
index cc3eac17..9dddd8d7 100644
--- a/control/include/global_properties.h
+++ b/control/include/global_properties.h
@@ -13,6 +13,7 @@
#include "input.h"
#include "full_condition.h"
#include "sensor.h"
+#include "hsm_support.h"
#include "../../communication/include/communication.h"
#include "../../logger/logger.h"
@@ -23,6 +24,8 @@ class FullCondition;
// Forward declaration instead of #include
class Sensor;
+constexpr int BITS_IN_BYTE = 8;
+
// Singleton class managing global properties
class GlobalProperties {
private:
@@ -52,4 +55,4 @@ class GlobalProperties {
static logger controlLogger;
};
-#endif // _GLOBAL_PROPERTIES_H_
\ No newline at end of file
+#endif // _GLOBAL_PROPERTIES_H_
diff --git a/control/include/input.h b/control/include/input.h
index 8fcf3b6f..314e9717 100644
--- a/control/include/input.h
+++ b/control/include/input.h
@@ -19,10 +19,12 @@ class Input {
static void s_buildSensors(std::unordered_map &sensors);
// Function that builds the conditions according to the bson file
static void s_buildConditions();
+ // Function to set the path to the BSON file - for using specific path for the tests
+ static void s_setPathBson();
private:
// Function that read the bson file
- static bson_t *s_readData();
+ static bson_t *s_readData(string fileName);
// Member that contains the bson file data
static bson_t *document;
};
diff --git a/control/include/sensor.h b/control/include/sensor.h
index 1bb1beeb..d3f86376 100644
--- a/control/include/sensor.h
+++ b/control/include/sensor.h
@@ -6,7 +6,10 @@
#include