From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../Masterarbeit/src/Xoraya_Stub/Xoraya_Stub.sln | 20 ++ .../Masterarbeit/src/Xoraya_Stub/Xoraya_Stub.suo | Bin 0 -> 48128 bytes .../src/Xoraya_Stub/Xoraya_Stub/ReadMe.txt | 36 +++ .../src/Xoraya_Stub/Xoraya_Stub/TcpConnection.cpp | 89 +++++++ .../src/Xoraya_Stub/Xoraya_Stub/TcpConnection.h | 33 +++ .../src/Xoraya_Stub/Xoraya_Stub/TcpServer.cpp | 47 ++++ .../src/Xoraya_Stub/Xoraya_Stub/TcpServer.h | 20 ++ .../Xoraya_Stub/Xoraya_Stub/XorayaConnector.cpp | 34 +++ .../src/Xoraya_Stub/Xoraya_Stub/XorayaConnector.h | 17 ++ .../src/Xoraya_Stub/Xoraya_Stub/XorayaExecutor.cpp | 37 +++ .../src/Xoraya_Stub/Xoraya_Stub/XorayaExecutor.h | 19 ++ .../src/Xoraya_Stub/Xoraya_Stub/Xoraya_Stub.cpp | 14 ++ .../src/Xoraya_Stub/Xoraya_Stub/Xoraya_Stub.vcproj | 259 +++++++++++++++++++++ ...raya_Stub.vcproj.SCHLEISSHEIMER.Eisenhauer.user | 65 ++++++ .../src/Xoraya_Stub/Xoraya_Stub/stdafx.cpp | 8 + .../src/Xoraya_Stub/Xoraya_Stub/stdafx.h | 17 ++ 16 files changed, 715 insertions(+) create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub.sln create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub.suo create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/ReadMe.txt create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpConnection.cpp create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpConnection.h create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpServer.cpp create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpServer.h create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaConnector.cpp create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaConnector.h create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaExecutor.cpp create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaExecutor.h create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/Xoraya_Stub.cpp create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/Xoraya_Stub.vcproj create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/Xoraya_Stub.vcproj.SCHLEISSHEIMER.Eisenhauer.user create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/stdafx.cpp create mode 100644 Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/stdafx.h (limited to 'Master/Masterarbeit/src/Xoraya_Stub') diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub.sln b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub.sln new file mode 100644 index 0000000..063337e --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Xoraya_Stub", "Xoraya_Stub\Xoraya_Stub.vcproj", "{AB15B858-E9A1-4EA8-B6BE-B002A4F61AB0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AB15B858-E9A1-4EA8-B6BE-B002A4F61AB0}.Debug|Win32.ActiveCfg = Debug|Win32 + {AB15B858-E9A1-4EA8-B6BE-B002A4F61AB0}.Debug|Win32.Build.0 = Debug|Win32 + {AB15B858-E9A1-4EA8-B6BE-B002A4F61AB0}.Release|Win32.ActiveCfg = Release|Win32 + {AB15B858-E9A1-4EA8-B6BE-B002A4F61AB0}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub.suo b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub.suo new file mode 100644 index 0000000..3b2ea80 Binary files /dev/null and b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub.suo differ diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/ReadMe.txt b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/ReadMe.txt new file mode 100644 index 0000000..5a0769a --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/ReadMe.txt @@ -0,0 +1,36 @@ +======================================================================== + KONSOLENANWENDUNG: Xoraya_Stub-Projektübersicht +======================================================================== + +Diese Xoraya_Stub-Anwendung wurde vom Anwendungs-Assistenten +für Sie erstellt. + +Diese Datei bietet eine Übersicht über den Inhalt der einzelnen Dateien, +aus denen Ihre Xoraya_Stub–Anwendung besteht. + + +Xoraya_Stub.vcproj + Dies ist die Hauptprojektdatei für VC++-Projekte, die mit dem Anwendungs- + Assistenten generiert werden. + Sie enthält Informationen über die Version von Visual C++, mit der die + Datei generiert wurde, sowie über die Plattformen, Konfigurationen und + Projektfeatures, die im Anwendungs-Assistenten ausgewählt wurden. + +Xoraya_Stub.cpp + Dies ist die Hauptquelldatei der Anwendung. + +///////////////////////////////////////////////////////////////////////////// +Weitere Standarddateien: + +StdAfx.h, StdAfx.cpp + Mit diesen Dateien werden eine vorkompilierte Header (PCH)-Datei + mit dem Namen "Xoraya_Stub.pch" und eine + vorkompilierte Typendatei mit dem Namen "StdAfx.obj" erstellt. + +///////////////////////////////////////////////////////////////////////////// +Weitere Hinweise: + +Der Anwendungs-Assistent weist Sie mit "TODO:"-Kommentaren auf Teile des +Quellcodes hin, die Sie ergänzen oder anpassen sollten. + +///////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpConnection.cpp b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpConnection.cpp new file mode 100644 index 0000000..88a57d9 --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpConnection.cpp @@ -0,0 +1,89 @@ +#include "StdAfx.h" +#include "TcpConnection.h" +#include +#include +#include "XorayaExecutor.h" +#include +#include + +CTcpConnection::CTcpConnection(boost::asio::io_service& io_service, boost::shared_ptr pxExecutor) +:m_xSocket(io_service),m_pxExecutor(pxExecutor) +{ +} + +CTcpConnection::~CTcpConnection(void) +{ +} + +CTcpConnection::tConnectionPtr CTcpConnection::pxCreate(boost::asio::io_service& xIoService, boost::shared_ptr pxExecutor) +{ + std::cout << __FUNCTION__ << " created new tcp connection " << std::endl; + return tConnectionPtr(new CTcpConnection(xIoService,pxExecutor)); +} + +boost::asio::ip::tcp::socket& CTcpConnection::xGetSocket() +{ + return m_xSocket; +} + +void CTcpConnection::vStart() +{ + boost::asio::async_read( + m_xSocket, + boost::asio::buffer(m_RxBuffer), + boost::asio::transfer_at_least(2), + boost::bind(&CTcpConnection::vReadHandler, shared_from_this(), + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred + ) + ); +} +void CTcpConnection::vWriteHandler(const boost::system::error_code& err, size_t bytesTransferred) +{ + if(!err) + { + std::cout << __FUNCTION__ << " transferred " << bytesTransferred << " bytes" << std::endl; + } + else + { + std::cout << __FUNCTION__ << " error: " << err.message() << std::endl; + } +} +void CTcpConnection::vReadHandler(const boost::system::error_code& err, size_t bytesTransferred) +{ + if(!err) + { + std::string sCmd(m_RxBuffer.data(),bytesTransferred); + std::cout << __FUNCTION__ << " received command " << sCmd << std::endl; + if( sCmd.compare("GETINTERFACES") == 0 ) + { + std::string sResponse; + m_pxExecutor->vGetInterfaces(sResponse); + sResponse = "INTERFACES\r\n" + sResponse; + boost::asio::async_write( + m_xSocket, + boost::asio::buffer(sResponse.c_str(),sResponse.length()), + boost::bind( + &CTcpConnection::vWriteHandler, + this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred + ) + ); + } + + boost::asio::async_read( + m_xSocket, + boost::asio::buffer(m_RxBuffer), + boost::asio::transfer_at_least(2), + boost::bind(&CTcpConnection::vReadHandler, shared_from_this(), + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred + ) + ); + } + else + { + std::cout << __FUNCTION__ << " error: " << err.message() << std::endl; + } +} \ No newline at end of file diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpConnection.h b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpConnection.h new file mode 100644 index 0000000..f2b14d0 --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpConnection.h @@ -0,0 +1,33 @@ +#pragma once + +#include +#include +#include +#include + +#define BUFF_SIZE 4096 + +class CXorayaExecutor; + +class CTcpConnection : public boost::enable_shared_from_this +{ +public: + typedef boost::shared_ptr tConnectionPtr; + + static tConnectionPtr pxCreate(boost::asio::io_service& xIoService, boost::shared_ptr pxExecutor); + + boost::asio::ip::tcp::socket& xGetSocket(); + void vStart(); + + CTcpConnection(void); + ~CTcpConnection(void); + +private: + boost::array m_RxBuffer; + boost::array m_TxBuffer; + boost::asio::ip::tcp::socket m_xSocket; + boost::shared_ptr m_pxExecutor; + CTcpConnection(boost::asio::io_service& io_service, boost::shared_ptr pxExecutor); + void vWriteHandler(const boost::system::error_code& err, size_t bytesTransferred); + void vReadHandler(const boost::system::error_code& err, size_t bytesTransferred); +}; diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpServer.cpp b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpServer.cpp new file mode 100644 index 0000000..a0509d5 --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpServer.cpp @@ -0,0 +1,47 @@ +#include "StdAfx.h" +#include "TcpServer.h" +#include +#include "XorayaExecutor.h" + +CTcpServer::CTcpServer(boost::shared_ptr pxExecutor + ,boost::asio::io_service& io_service + , int i32Port) +:m_xAcceptor( + io_service, + boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(),i32Port) + ) + ,m_pxExecutor(pxExecutor) + ,m_io_service(io_service) +{ + vStartAccept(); +} + +CTcpServer::~CTcpServer(void) +{ +} + +void CTcpServer::vStartAccept() +{ + CTcpConnection::tConnectionPtr pNewCon + = CTcpConnection::pxCreate(m_io_service,m_pxExecutor); + + std::cout << __FUNCTION__ << " new accept " << std::endl; + + m_xAcceptor.async_accept(pNewCon->xGetSocket(), + boost::bind( + &CTcpServer::vAcceptHandler, + this, + pNewCon, + boost::asio::placeholders::error + ) + ); +} + +void CTcpServer::vAcceptHandler(CTcpConnection::tConnectionPtr pNewCon, const boost::system::error_code& error) +{ + if(!error) + { + pNewCon->vStart(); + vStartAccept(); + } +} \ No newline at end of file diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpServer.h b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpServer.h new file mode 100644 index 0000000..e560cc0 --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/TcpServer.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include +#include "TcpConnection.h" + +class CXorayaExecutor; + +class CTcpServer +{ +public: + CTcpServer(boost::shared_ptrpxExecutor, boost::asio::io_service& io_service, int port); + ~CTcpServer(void); + void vAcceptHandler(CTcpConnection::tConnectionPtr pNewCon, const boost::system::error_code& error); +private: + boost::asio::ip::tcp::acceptor m_xAcceptor; + boost::shared_ptr m_pxExecutor; + void vStartAccept(); + boost::asio::io_service& m_io_service; +}; diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaConnector.cpp b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaConnector.cpp new file mode 100644 index 0000000..9a3b52b --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaConnector.cpp @@ -0,0 +1,34 @@ +#include "StdAfx.h" +#include "XorayaConnector.h" +#include "XorayaExecutor.h" +#include +#include +#include +#include +#include "TcpServer.h" + +CXorayaConnector::CXorayaConnector(boost::shared_ptr pxExecutor) +:m_pxExecutor(pxExecutor) +{ +} + +CXorayaConnector::~CXorayaConnector(void) +{ + std::cout << __FUNCTION__ << std::endl; +} + +void CXorayaConnector::operator()() +{ + try + { + boost::asio::io_service io_service; + CTcpServer tcpServer(m_pxExecutor,io_service,CONNECTOR_PORT); + io_service.run(); + std::cout << __FUNCTION__ << " io service returned " << std::endl; + } + catch(std::exception& e) + { + std::cerr << __FUNCTION__ << ": " << e.what() << std::endl; + } + return; +} \ No newline at end of file diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaConnector.h b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaConnector.h new file mode 100644 index 0000000..6823139 --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaConnector.h @@ -0,0 +1,17 @@ +#pragma once + +#include + +#define CONNECTOR_PORT 7010 + +class CXorayaExecutor; + +class CXorayaConnector +{ +public: + CXorayaConnector(boost::shared_ptr pxExecutor); + virtual ~CXorayaConnector(void); + void operator()(); +private: + boost::shared_ptr m_pxExecutor; +}; diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaExecutor.cpp b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaExecutor.cpp new file mode 100644 index 0000000..a2c67d2 --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaExecutor.cpp @@ -0,0 +1,37 @@ +#include "StdAfx.h" +#include "XorayaExecutor.h" +#include "XorayaConnector.h" +#include + +CXorayaExecutor::CXorayaExecutor(void) +{ + m_pxConnector.reset(new CXorayaConnector(boost::shared_ptr(this))); + m_pxConnectorThread.reset( + new boost::thread(*m_pxConnector) + ); +} + +CXorayaExecutor::~CXorayaExecutor(void) +{ + m_pxConnectorThread->interrupt(); + std::cout << __FUNCTION__ << std::endl; +} + +void CXorayaExecutor::vGetInterfaces(std::string& sInterfaces) +{ + sInterfaces += "CAN 1\r\n"; + sInterfaces += "CAN 2\r\n"; + sInterfaces += "CAN 3\r\n"; + sInterfaces += "CAN 4\r\n"; + sInterfaces += "CAN 5\r\n"; + sInterfaces += "CAN 6\r\n"; + sInterfaces += "CAN 7\r\n"; + sInterfaces += "CAN 8\r\n"; + return; +} + +void CXorayaExecutor::vRun() +{ + m_pxConnectorThread->join(); + std::cout << __FUNCTION__ << " connector thread returned " << std::endl; +} \ No newline at end of file diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaExecutor.h b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaExecutor.h new file mode 100644 index 0000000..3be37f6 --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/XorayaExecutor.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include +#include + +class CXorayaConnector; + +class CXorayaExecutor +{ +public: + CXorayaExecutor(void); + virtual ~CXorayaExecutor(void); + void vGetInterfaces(std::string&); + void vRun(); +private: + boost::shared_ptr m_pxConnector; + boost::scoped_ptr m_pxConnectorThread; +}; diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/Xoraya_Stub.cpp b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/Xoraya_Stub.cpp new file mode 100644 index 0000000..53f6eb7 --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/Xoraya_Stub.cpp @@ -0,0 +1,14 @@ +// Xoraya_Stub.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung. +// + +#include "stdafx.h" +#include "XorayaExecutor.h" + + +int _tmain(int argc, _TCHAR* argv[]) +{ + CXorayaExecutor cExecutor; + cExecutor.vRun(); + return 0; +} + diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/Xoraya_Stub.vcproj b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/Xoraya_Stub.vcproj new file mode 100644 index 0000000..99ad5a8 --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/Xoraya_Stub.vcproj @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/Xoraya_Stub.vcproj.SCHLEISSHEIMER.Eisenhauer.user b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/Xoraya_Stub.vcproj.SCHLEISSHEIMER.Eisenhauer.user new file mode 100644 index 0000000..c44b7fd --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/Xoraya_Stub.vcproj.SCHLEISSHEIMER.Eisenhauer.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/stdafx.cpp b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/stdafx.cpp new file mode 100644 index 0000000..4bb84b6 --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : Quelldatei, die nur die Standard-Includes einbindet. +// Xoraya_Stub.pch ist der vorkompilierte Header. +// stdafx.obj enthält die vorkompilierten Typinformationen. + +#include "stdafx.h" + +// TODO: Auf zusätzliche Header verweisen, die in STDAFX.H +// und nicht in dieser Datei erforderlich sind. diff --git a/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/stdafx.h b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/stdafx.h new file mode 100644 index 0000000..9d7f336 --- /dev/null +++ b/Master/Masterarbeit/src/Xoraya_Stub/Xoraya_Stub/stdafx.h @@ -0,0 +1,17 @@ +// stdafx.h : Includedatei für Standardsystem-Includedateien +// oder häufig verwendete projektspezifische Includedateien, +// die nur in unregelmäßigen Abständen geändert werden. +// + +#pragma once + +#ifndef _WIN32_WINNT // Lassen Sie die Verwendung spezifischer Features von Windows XP oder später zu. +#define _WIN32_WINNT 0x0501 // Ändern Sie dies in den geeigneten Wert für andere Versionen von Windows. +#endif + +#include +#include + + + +// TODO: Hier auf zusätzliche Header, die das Programm erfordert, verweisen. -- cgit v1.2.3