documentation, IP writing service
This commit is contained in:
parent
03daabaa37
commit
afe5e9c766
22 changed files with 502 additions and 12 deletions
10
server_v2/.idea/other.xml
generated
10
server_v2/.idea/other.xml
generated
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoUploadManager">
|
||||
<option name="hosts">
|
||||
<list>
|
||||
<option value="9c7ab821-1501-483e-beda-814d54656ca2" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -56,7 +56,9 @@ set(SRC_FILES
|
|||
src/communication/UnixSocketServer.cpp
|
||||
src/communication/TCPSocketServer.cpp
|
||||
src/GoToController.cpp
|
||||
src/HealthChecker.cpp)
|
||||
src/HealthChecker.cpp
|
||||
src/Display.cpp
|
||||
src/IPWritingService.cpp)
|
||||
|
||||
set(HDR_FILES
|
||||
include/spi.hpp
|
||||
|
@ -77,7 +79,9 @@ set(HDR_FILES
|
|||
include/communication/UnixSocketServer.hpp
|
||||
include/communication/TCPSocketServer.hpp
|
||||
include/GoToController.hpp
|
||||
include/HealthChecker.hpp)
|
||||
include/HealthChecker.hpp
|
||||
include/Display.hpp
|
||||
include/IPWritingService.hpp)
|
||||
|
||||
include_directories(third_party/asio)
|
||||
|
||||
|
|
16
server_v2/include/Display.hpp
Normal file
16
server_v2/include/Display.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef COMPLIB_SERVER_DISPLAY_HPP
|
||||
#define COMPLIB_SERVER_DISPLAY_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
class Display {
|
||||
public:
|
||||
static void write(uint8_t line, std::string text);
|
||||
|
||||
private:
|
||||
|
||||
Display() = default;
|
||||
};
|
||||
|
||||
#endif //COMPLIB_SERVER_DISPLAY_HPP
|
16
server_v2/include/IPWritingService.hpp
Normal file
16
server_v2/include/IPWritingService.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef COMPLIB_SERVER_IPWRITINGSERVICE_HPP
|
||||
#define COMPLIB_SERVER_IPWRITINGSERVICE_HPP
|
||||
|
||||
#include <thread>
|
||||
|
||||
class IPWritingService {
|
||||
public:
|
||||
IPWritingService();
|
||||
|
||||
private:
|
||||
[[noreturn]] void writing_loop();
|
||||
|
||||
std::thread writing_thread;
|
||||
};
|
||||
|
||||
#endif //COMPLIB_SERVER_IPWRITINGSERVICE_HPP
|
7
server_v2/src/Display.cpp
Normal file
7
server_v2/src/Display.cpp
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include "include/Display.hpp"
|
||||
#include "include/spi.hpp"
|
||||
|
||||
void Display::write(uint8_t line, std::string text) {
|
||||
text.resize(16);
|
||||
Spi::getInstance().write_array(Spi::DISPLAY_LINE_1_C0 + line * 16, 16, reinterpret_cast<const uint8_t *>(text.c_str()));
|
||||
}
|
17
server_v2/src/IPWritingService.cpp
Normal file
17
server_v2/src/IPWritingService.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include "include/IPWritingService.hpp"
|
||||
#include "include/networkUtils.hpp"
|
||||
#include "include/Display.hpp"
|
||||
|
||||
IPWritingService::IPWritingService() {
|
||||
writing_thread = std::thread(&IPWritingService::writing_loop, this);
|
||||
writing_thread.detach();
|
||||
}
|
||||
|
||||
void IPWritingService::writing_loop() {
|
||||
while (true) {
|
||||
auto host_and_ip = networkUtils::get_current_host_and_ip();
|
||||
Display::write(2, std::get<0>(host_and_ip));
|
||||
Display::write(3, std::get<1>(host_and_ip));
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
#include "include/GoToController.hpp"
|
||||
#include "include/Encoders.hpp"
|
||||
#include "include/networkUtils.hpp"
|
||||
#include "include/IPWritingService.hpp"
|
||||
|
||||
#ifdef IS_RASPI
|
||||
|
||||
|
@ -27,6 +28,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
UnixSocketServer unixSocketServer;
|
||||
TCPSocketServer tcpSocketServer;
|
||||
IPWritingService ipWritingService;
|
||||
HealthChecker::getInstance();
|
||||
|
||||
#ifdef IS_RASPI
|
||||
|
|
Reference in a new issue