init
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
idf_component_register(
|
||||
SRCS "com/ammonia.cpp"
|
||||
INCLUDE_DIRS "com"
|
||||
REQUIRES logger
|
||||
)
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @file ammonia.cpp
|
||||
* @brief Ammonia component implementation
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#include "ammonia.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
static const char* TAG = "Ammonia";
|
||||
|
||||
Ammonia::Ammonia()
|
||||
: m_isInitialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
Ammonia::~Ammonia()
|
||||
{
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
bool Ammonia::initialize()
|
||||
{
|
||||
// TODO: Implement initialization
|
||||
m_isInitialized = true;
|
||||
ASF_LOGI(TAG, 3400, asf::logger::Criticality::LOW, "Ammonia initialized successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Ammonia::deinitialize()
|
||||
{
|
||||
if (!m_isInitialized)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Implement deinitialization
|
||||
m_isInitialized = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Ammonia::isInitialized() const
|
||||
{
|
||||
return m_isInitialized;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @file ammonia.hpp
|
||||
* @brief Ammonia component header
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#ifndef AMMONIA_HPP
|
||||
#define AMMONIA_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* @brief Ammonia class
|
||||
*
|
||||
* Component description goes here.
|
||||
*/
|
||||
class Ammonia
|
||||
{
|
||||
public:
|
||||
Ammonia();
|
||||
~Ammonia();
|
||||
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
bool isInitialized() const;
|
||||
|
||||
private:
|
||||
bool m_isInitialized;
|
||||
};
|
||||
|
||||
#endif // AMMONIA_HPP
|
||||
@@ -0,0 +1,2 @@
|
||||
ID,Component,Level,Criticality,Message
|
||||
3400,Ammonia,INFO,Low,Ammonia initialized successfully
|
||||
|
@@ -0,0 +1,34 @@
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
|
||||
folder_path = os.path.abspath(os.path.join("components", "system_tests"))
|
||||
if folder_path not in sys.path:
|
||||
sys.path.append(folder_path)
|
||||
|
||||
from scan_serial import ESP32Runner
|
||||
|
||||
def test_ammonia_initialize():
|
||||
runner = ESP32Runner(mode="SIM", port="COM9")
|
||||
runner.start()
|
||||
print("--- QEMU Runner Started ---", flush=True)
|
||||
try:
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < 30:
|
||||
line = runner.get_line(timeout=1.0)
|
||||
if line:
|
||||
print(line, flush=True)
|
||||
if "Ammonia initialized successfully" in line:
|
||||
print("SUCCESS CRITERIA MET!", flush=True)
|
||||
return 0
|
||||
if runner.process.poll() is not None:
|
||||
print(f"Process exited with code: {runner.process.returncode}", flush=True)
|
||||
return 1
|
||||
finally:
|
||||
runner.stop()
|
||||
print("Done.", flush=True)
|
||||
return 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit_code = test_ammonia_initialize()
|
||||
sys.exit(exit_code)
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test_scenario>
|
||||
<!-- The configuration for the test environment. -->
|
||||
<!-- Available configurations: SIMULATE, HIL -->
|
||||
<config>SIMULATE</config>
|
||||
|
||||
<test_case>
|
||||
<test_case_id>AMMONIA_INIT_TEST</test_case_id>
|
||||
<!-- The main command that executes the test itself. -->
|
||||
<test_exec>python components/drivers/sensors/ammonia/test/ammonia_init_test.py</test_exec>
|
||||
</test_case>
|
||||
|
||||
|
||||
</test_scenario>
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @file test_ammonia.cpp
|
||||
* @brief Unit tests for Ammonia component
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#include "unity.h"
|
||||
#include "ammonia.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
void test_ammonia_initialize(void)
|
||||
{
|
||||
Ammonia comp;
|
||||
bool result = comp.initialize();
|
||||
TEST_ASSERT_TRUE(result);
|
||||
TEST_ASSERT_TRUE(comp.isInitialized());
|
||||
}
|
||||
|
||||
void test_ammonia_deinitialize(void)
|
||||
{
|
||||
Ammonia comp;
|
||||
comp.initialize();
|
||||
|
||||
bool result = comp.deinitialize();
|
||||
TEST_ASSERT_TRUE(result);
|
||||
TEST_ASSERT_FALSE(comp.isInitialized());
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,5 @@
|
||||
idf_component_register(
|
||||
SRCS "com/co2.cpp"
|
||||
INCLUDE_DIRS "com"
|
||||
REQUIRES logger
|
||||
)
|
||||
47
software design/components/drivers/sensors/co2/com/co2.cpp
Normal file
47
software design/components/drivers/sensors/co2/com/co2.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @file co2.cpp
|
||||
* @brief Co2 component implementation
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#include "co2.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
static const char* TAG = "Co2";
|
||||
|
||||
Co2::Co2()
|
||||
: m_isInitialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
Co2::~Co2()
|
||||
{
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
bool Co2::initialize()
|
||||
{
|
||||
// TODO: Implement initialization
|
||||
m_isInitialized = true;
|
||||
ASF_LOGI(TAG, 3500, asf::logger::Criticality::LOW, "Co2 initialized successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Co2::deinitialize()
|
||||
{
|
||||
if (!m_isInitialized)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Implement deinitialization
|
||||
m_isInitialized = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Co2::isInitialized() const
|
||||
{
|
||||
return m_isInitialized;
|
||||
}
|
||||
33
software design/components/drivers/sensors/co2/com/co2.hpp
Normal file
33
software design/components/drivers/sensors/co2/com/co2.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @file co2.hpp
|
||||
* @brief Co2 component header
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#ifndef CO2_HPP
|
||||
#define CO2_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* @brief Co2 class
|
||||
*
|
||||
* Component description goes here.
|
||||
*/
|
||||
class Co2
|
||||
{
|
||||
public:
|
||||
Co2();
|
||||
~Co2();
|
||||
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
bool isInitialized() const;
|
||||
|
||||
private:
|
||||
bool m_isInitialized;
|
||||
};
|
||||
|
||||
#endif // CO2_HPP
|
||||
@@ -0,0 +1,2 @@
|
||||
ID,Component,Level,Criticality,Message
|
||||
3500,Co2,INFO,Low,Co2 initialized successfully
|
||||
|
@@ -0,0 +1,34 @@
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
|
||||
folder_path = os.path.abspath(os.path.join("components", "system_tests"))
|
||||
if folder_path not in sys.path:
|
||||
sys.path.append(folder_path)
|
||||
|
||||
from scan_serial import ESP32Runner
|
||||
|
||||
def test_co2_initialize():
|
||||
runner = ESP32Runner(mode="SIM", port="COM9")
|
||||
runner.start()
|
||||
print("--- QEMU Runner Started ---", flush=True)
|
||||
try:
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < 30:
|
||||
line = runner.get_line(timeout=1.0)
|
||||
if line:
|
||||
print(line, flush=True)
|
||||
if "Co2 initialized successfully" in line:
|
||||
print("SUCCESS CRITERIA MET!", flush=True)
|
||||
return 0
|
||||
if runner.process.poll() is not None:
|
||||
print(f"Process exited with code: {runner.process.returncode}", flush=True)
|
||||
return 1
|
||||
finally:
|
||||
runner.stop()
|
||||
print("Done.", flush=True)
|
||||
return 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit_code = test_co2_initialize()
|
||||
sys.exit(exit_code)
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test_scenario>
|
||||
<!-- The configuration for the test environment. -->
|
||||
<!-- Available configurations: SIMULATE, HIL -->
|
||||
<config>SIMULATE</config>
|
||||
|
||||
<test_case>
|
||||
<test_case_id>CO2_INIT_TEST</test_case_id>
|
||||
<!-- The main command that executes the test itself. -->
|
||||
<test_exec>python components/drivers/sensors/co2/test/co2_init_test.py</test_exec>
|
||||
</test_case>
|
||||
|
||||
|
||||
</test_scenario>
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @file test_co2.cpp
|
||||
* @brief Unit tests for Co2 component
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#include "unity.h"
|
||||
#include "co2.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
void test_co2_initialize(void)
|
||||
{
|
||||
Co2 comp;
|
||||
bool result = comp.initialize();
|
||||
TEST_ASSERT_TRUE(result);
|
||||
TEST_ASSERT_TRUE(comp.isInitialized());
|
||||
}
|
||||
|
||||
void test_co2_deinitialize(void)
|
||||
{
|
||||
Co2 comp;
|
||||
comp.initialize();
|
||||
|
||||
bool result = comp.deinitialize();
|
||||
TEST_ASSERT_TRUE(result);
|
||||
TEST_ASSERT_FALSE(comp.isInitialized());
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,5 @@
|
||||
idf_component_register(
|
||||
SRCS "com/humidity.cpp"
|
||||
INCLUDE_DIRS "com"
|
||||
REQUIRES logger
|
||||
)
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @file humidity.cpp
|
||||
* @brief Humidity component implementation
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#include "humidity.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
static const char* TAG = "Humidity";
|
||||
|
||||
Humidity::Humidity()
|
||||
: m_isInitialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
Humidity::~Humidity()
|
||||
{
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
bool Humidity::initialize()
|
||||
{
|
||||
// TODO: Implement initialization
|
||||
m_isInitialized = true;
|
||||
ASF_LOGI(TAG, 3600, asf::logger::Criticality::LOW, "Humidity initialized successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Humidity::deinitialize()
|
||||
{
|
||||
if (!m_isInitialized)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Implement deinitialization
|
||||
m_isInitialized = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Humidity::isInitialized() const
|
||||
{
|
||||
return m_isInitialized;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @file humidity.hpp
|
||||
* @brief Humidity component header
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#ifndef HUMIDITY_HPP
|
||||
#define HUMIDITY_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* @brief Humidity class
|
||||
*
|
||||
* Component description goes here.
|
||||
*/
|
||||
class Humidity
|
||||
{
|
||||
public:
|
||||
Humidity();
|
||||
~Humidity();
|
||||
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
bool isInitialized() const;
|
||||
|
||||
private:
|
||||
bool m_isInitialized;
|
||||
};
|
||||
|
||||
#endif // HUMIDITY_HPP
|
||||
@@ -0,0 +1,2 @@
|
||||
ID,Component,Level,Criticality,Message
|
||||
3600,Humidity,INFO,Low,Humidity initialized successfully
|
||||
|
@@ -0,0 +1,34 @@
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
|
||||
folder_path = os.path.abspath(os.path.join("components", "system_tests"))
|
||||
if folder_path not in sys.path:
|
||||
sys.path.append(folder_path)
|
||||
|
||||
from scan_serial import ESP32Runner
|
||||
|
||||
def test_humidity_initialize():
|
||||
runner = ESP32Runner(mode="SIM", port="COM9")
|
||||
runner.start()
|
||||
print("--- QEMU Runner Started ---", flush=True)
|
||||
try:
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < 30:
|
||||
line = runner.get_line(timeout=1.0)
|
||||
if line:
|
||||
print(line, flush=True)
|
||||
if "Humidity initialized successfully" in line:
|
||||
print("SUCCESS CRITERIA MET!", flush=True)
|
||||
return 0
|
||||
if runner.process.poll() is not None:
|
||||
print(f"Process exited with code: {runner.process.returncode}", flush=True)
|
||||
return 1
|
||||
finally:
|
||||
runner.stop()
|
||||
print("Done.", flush=True)
|
||||
return 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit_code = test_humidity_initialize()
|
||||
sys.exit(exit_code)
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test_scenario>
|
||||
<!-- The configuration for the test environment. -->
|
||||
<!-- Available configurations: SIMULATE, HIL -->
|
||||
<config>SIMULATE</config>
|
||||
|
||||
<test_case>
|
||||
<test_case_id>HUMIDITY_INIT_TEST</test_case_id>
|
||||
<!-- The main command that executes the test itself. -->
|
||||
<test_exec>python components/drivers/sensors/humidity/test/humidity_init_test.py</test_exec>
|
||||
</test_case>
|
||||
|
||||
|
||||
</test_scenario>
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @file test_humidity.cpp
|
||||
* @brief Unit tests for Humidity component
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#include "unity.h"
|
||||
#include "humidity.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
void test_humidity_initialize(void)
|
||||
{
|
||||
Humidity comp;
|
||||
bool result = comp.initialize();
|
||||
TEST_ASSERT_TRUE(result);
|
||||
TEST_ASSERT_TRUE(comp.isInitialized());
|
||||
}
|
||||
|
||||
void test_humidity_deinitialize(void)
|
||||
{
|
||||
Humidity comp;
|
||||
comp.initialize();
|
||||
|
||||
bool result = comp.deinitialize();
|
||||
TEST_ASSERT_TRUE(result);
|
||||
TEST_ASSERT_FALSE(comp.isInitialized());
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,5 @@
|
||||
idf_component_register(
|
||||
SRCS "com/light.cpp"
|
||||
INCLUDE_DIRS "com"
|
||||
REQUIRES logger
|
||||
)
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @file light.cpp
|
||||
* @brief Light component implementation
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#include "light.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
static const char* TAG = "Light";
|
||||
|
||||
Light::Light()
|
||||
: m_isInitialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
Light::~Light()
|
||||
{
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
bool Light::initialize()
|
||||
{
|
||||
// TODO: Implement initialization
|
||||
m_isInitialized = true;
|
||||
ASF_LOGI(TAG, 3700, asf::logger::Criticality::LOW, "Light initialized successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Light::deinitialize()
|
||||
{
|
||||
if (!m_isInitialized)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Implement deinitialization
|
||||
m_isInitialized = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Light::isInitialized() const
|
||||
{
|
||||
return m_isInitialized;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @file light.hpp
|
||||
* @brief Light component header
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#ifndef LIGHT_HPP
|
||||
#define LIGHT_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* @brief Light class
|
||||
*
|
||||
* Component description goes here.
|
||||
*/
|
||||
class Light
|
||||
{
|
||||
public:
|
||||
Light();
|
||||
~Light();
|
||||
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
bool isInitialized() const;
|
||||
|
||||
private:
|
||||
bool m_isInitialized;
|
||||
};
|
||||
|
||||
#endif // LIGHT_HPP
|
||||
@@ -0,0 +1,2 @@
|
||||
ID,Component,Level,Criticality,Message
|
||||
3700,Light,INFO,Low,Light initialized successfully
|
||||
|
@@ -0,0 +1,34 @@
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
|
||||
folder_path = os.path.abspath(os.path.join("components", "system_tests"))
|
||||
if folder_path not in sys.path:
|
||||
sys.path.append(folder_path)
|
||||
|
||||
from scan_serial import ESP32Runner
|
||||
|
||||
def test_light_initialize():
|
||||
runner = ESP32Runner(mode="SIM", port="COM9")
|
||||
runner.start()
|
||||
print("--- QEMU Runner Started ---", flush=True)
|
||||
try:
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < 30:
|
||||
line = runner.get_line(timeout=1.0)
|
||||
if line:
|
||||
print(line, flush=True)
|
||||
if "Light initialized successfully" in line:
|
||||
print("SUCCESS CRITERIA MET!", flush=True)
|
||||
return 0
|
||||
if runner.process.poll() is not None:
|
||||
print(f"Process exited with code: {runner.process.returncode}", flush=True)
|
||||
return 1
|
||||
finally:
|
||||
runner.stop()
|
||||
print("Done.", flush=True)
|
||||
return 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit_code = test_light_initialize()
|
||||
sys.exit(exit_code)
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test_scenario>
|
||||
<!-- The configuration for the test environment. -->
|
||||
<!-- Available configurations: SIMULATE, HIL -->
|
||||
<config>SIMULATE</config>
|
||||
|
||||
<test_case>
|
||||
<test_case_id>LIGHT_INIT_TEST</test_case_id>
|
||||
<!-- The main command that executes the test itself. -->
|
||||
<test_exec>python components/drivers/sensors/light/test/light_init_test.py</test_exec>
|
||||
</test_case>
|
||||
|
||||
|
||||
</test_scenario>
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @file test_light.cpp
|
||||
* @brief Unit tests for Light component
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#include "unity.h"
|
||||
#include "light.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
void test_light_initialize(void)
|
||||
{
|
||||
Light comp;
|
||||
bool result = comp.initialize();
|
||||
TEST_ASSERT_TRUE(result);
|
||||
TEST_ASSERT_TRUE(comp.isInitialized());
|
||||
}
|
||||
|
||||
void test_light_deinitialize(void)
|
||||
{
|
||||
Light comp;
|
||||
comp.initialize();
|
||||
|
||||
bool result = comp.deinitialize();
|
||||
TEST_ASSERT_TRUE(result);
|
||||
TEST_ASSERT_FALSE(comp.isInitialized());
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,5 @@
|
||||
idf_component_register(
|
||||
SRCS "com/temprature.cpp"
|
||||
INCLUDE_DIRS "com"
|
||||
REQUIRES logger
|
||||
)
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @file temprature.cpp
|
||||
* @brief Temperature component implementation
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#include "temprature.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
static const char* TAG = "Temperature";
|
||||
|
||||
Temperature::Temperature()
|
||||
: m_isInitialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
Temperature::~Temperature()
|
||||
{
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
bool Temperature::initialize()
|
||||
{
|
||||
// TODO: Implement initialization
|
||||
m_isInitialized = true;
|
||||
ASF_LOGI(TAG, 3800, asf::logger::Criticality::LOW, "Temperature initialized successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Temperature::deinitialize()
|
||||
{
|
||||
if (!m_isInitialized)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Implement deinitialization
|
||||
m_isInitialized = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Temperature::isInitialized() const
|
||||
{
|
||||
return m_isInitialized;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @file temprature.hpp
|
||||
* @brief Temperature component header
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#ifndef TEMPRATURE_HPP
|
||||
#define TEMPRATURE_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* @brief Temperature class
|
||||
*
|
||||
* Component description goes here.
|
||||
*/
|
||||
class Temperature
|
||||
{
|
||||
public:
|
||||
Temperature();
|
||||
~Temperature();
|
||||
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
bool isInitialized() const;
|
||||
|
||||
private:
|
||||
bool m_isInitialized;
|
||||
};
|
||||
|
||||
#endif // TEMPRATURE_HPP
|
||||
@@ -0,0 +1,2 @@
|
||||
ID,Component,Level,Criticality,Message
|
||||
3800,Temperature,INFO,Low,Temperature initialized successfully
|
||||
|
@@ -0,0 +1,34 @@
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
|
||||
folder_path = os.path.abspath(os.path.join("components", "system_tests"))
|
||||
if folder_path not in sys.path:
|
||||
sys.path.append(folder_path)
|
||||
|
||||
from scan_serial import ESP32Runner
|
||||
|
||||
def test_temperature_initialize():
|
||||
runner = ESP32Runner(mode="SIM", port="COM9")
|
||||
runner.start()
|
||||
print("--- QEMU Runner Started ---", flush=True)
|
||||
try:
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < 30:
|
||||
line = runner.get_line(timeout=1.0)
|
||||
if line:
|
||||
print(line, flush=True)
|
||||
if "Temperature initialized successfully" in line:
|
||||
print("SUCCESS CRITERIA MET!", flush=True)
|
||||
return 0
|
||||
if runner.process.poll() is not None:
|
||||
print(f"Process exited with code: {runner.process.returncode}", flush=True)
|
||||
return 1
|
||||
finally:
|
||||
runner.stop()
|
||||
print("Done.", flush=True)
|
||||
return 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit_code = test_temperature_initialize()
|
||||
sys.exit(exit_code)
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test_scenario>
|
||||
<!-- The configuration for the test environment. -->
|
||||
<!-- Available configurations: SIMULATE, HIL -->
|
||||
<config>SIMULATE</config>
|
||||
|
||||
<test_case>
|
||||
<test_case_id>TEMPRATURE_INIT_TEST</test_case_id>
|
||||
<!-- The main command that executes the test itself. -->
|
||||
<test_exec>python components/drivers/sensors/temprature/test/temprature_init_test.py</test_exec>
|
||||
</test_case>
|
||||
|
||||
|
||||
</test_scenario>
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @file test_temprature.cpp
|
||||
* @brief Unit tests for Temperature component
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#include "unity.h"
|
||||
#include "temprature.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
void test_temprature_initialize(void)
|
||||
{
|
||||
Temperature comp;
|
||||
bool result = comp.initialize();
|
||||
TEST_ASSERT_TRUE(result);
|
||||
TEST_ASSERT_TRUE(comp.isInitialized());
|
||||
}
|
||||
|
||||
void test_temprature_deinitialize(void)
|
||||
{
|
||||
Temperature comp;
|
||||
comp.initialize();
|
||||
|
||||
bool result = comp.deinitialize();
|
||||
TEST_ASSERT_TRUE(result);
|
||||
TEST_ASSERT_FALSE(comp.isInitialized());
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,5 @@
|
||||
idf_component_register(
|
||||
SRCS "com/voc.cpp"
|
||||
INCLUDE_DIRS "com"
|
||||
REQUIRES logger
|
||||
)
|
||||
47
software design/components/drivers/sensors/voc/com/voc.cpp
Normal file
47
software design/components/drivers/sensors/voc/com/voc.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @file voc.cpp
|
||||
* @brief Voc component implementation
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#include "voc.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
static const char* TAG = "Voc";
|
||||
|
||||
Voc::Voc()
|
||||
: m_isInitialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
Voc::~Voc()
|
||||
{
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
bool Voc::initialize()
|
||||
{
|
||||
// TODO: Implement initialization
|
||||
m_isInitialized = true;
|
||||
ASF_LOGI(TAG, 3900, asf::logger::Criticality::LOW, "Voc initialized successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Voc::deinitialize()
|
||||
{
|
||||
if (!m_isInitialized)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Implement deinitialization
|
||||
m_isInitialized = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Voc::isInitialized() const
|
||||
{
|
||||
return m_isInitialized;
|
||||
}
|
||||
33
software design/components/drivers/sensors/voc/com/voc.hpp
Normal file
33
software design/components/drivers/sensors/voc/com/voc.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @file voc.hpp
|
||||
* @brief Voc component header
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#ifndef VOC_HPP
|
||||
#define VOC_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* @brief Voc class
|
||||
*
|
||||
* Component description goes here.
|
||||
*/
|
||||
class Voc
|
||||
{
|
||||
public:
|
||||
Voc();
|
||||
~Voc();
|
||||
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
bool isInitialized() const;
|
||||
|
||||
private:
|
||||
bool m_isInitialized;
|
||||
};
|
||||
|
||||
#endif // VOC_HPP
|
||||
@@ -0,0 +1,2 @@
|
||||
ID,Component,Level,Criticality,Message
|
||||
3900,Voc,INFO,Low,Voc initialized successfully
|
||||
|
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @file test_voc.cpp
|
||||
* @brief Unit tests for Voc component
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#include "unity.h"
|
||||
#include "voc.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
void test_voc_initialize(void)
|
||||
{
|
||||
Voc comp;
|
||||
bool result = comp.initialize();
|
||||
TEST_ASSERT_TRUE(result);
|
||||
TEST_ASSERT_TRUE(comp.isInitialized());
|
||||
}
|
||||
|
||||
void test_voc_deinitialize(void)
|
||||
{
|
||||
Voc comp;
|
||||
comp.initialize();
|
||||
|
||||
bool result = comp.deinitialize();
|
||||
TEST_ASSERT_TRUE(result);
|
||||
TEST_ASSERT_FALSE(comp.isInitialized());
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,34 @@
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
|
||||
folder_path = os.path.abspath(os.path.join("components", "system_tests"))
|
||||
if folder_path not in sys.path:
|
||||
sys.path.append(folder_path)
|
||||
|
||||
from scan_serial import ESP32Runner
|
||||
|
||||
def test_voc_initialize():
|
||||
runner = ESP32Runner(mode="SIM", port="COM9")
|
||||
runner.start()
|
||||
print("--- QEMU Runner Started ---", flush=True)
|
||||
try:
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < 30:
|
||||
line = runner.get_line(timeout=1.0)
|
||||
if line:
|
||||
print(line, flush=True)
|
||||
if "Voc initialized successfully" in line:
|
||||
print("SUCCESS CRITERIA MET!", flush=True)
|
||||
return 0
|
||||
if runner.process.poll() is not None:
|
||||
print(f"Process exited with code: {runner.process.returncode}", flush=True)
|
||||
return 1
|
||||
finally:
|
||||
runner.stop()
|
||||
print("Done.", flush=True)
|
||||
return 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit_code = test_voc_initialize()
|
||||
sys.exit(exit_code)
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test_scenario>
|
||||
<!-- The configuration for the test environment. -->
|
||||
<!-- Available configurations: SIMULATE, HIL -->
|
||||
<config>SIMULATE</config>
|
||||
|
||||
<test_case>
|
||||
<test_case_id>VOC_INIT_TEST</test_case_id>
|
||||
<!-- The main command that executes the test itself. -->
|
||||
<test_exec>python components/drivers/sensors/voc/test/voc_init_test.py</test_exec>
|
||||
</test_case>
|
||||
|
||||
|
||||
</test_scenario>
|
||||
Reference in New Issue
Block a user