| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#pragma once |
| 22 |
|
| 23 |
#include <ctime> |
| 24 |
|
| 25 |
#include "Hardware/LocoCache.h" |
| 26 |
#include "Hardware/Protocols/MaerklinCANCommon.h" |
| 27 |
#include "Network/TcpConnection.h" |
| 28 |
#include "Utils/Utils.h" |
| 29 |
|
| 30 |
namespace Server { namespace CS2 |
| 31 |
{ |
| 32 |
class CS2Server; |
| 33 |
|
| 34 |
class CS2Client : protected Hardware::Protocols::MaerklinCANCommon |
| 35 |
{ |
| 36 |
public: |
| 37 |
CS2Client() = delete; |
| 38 |
CS2Client(const CS2Client&) = delete; |
| 39 |
CS2Client& operator=(const CS2Client&) = delete; |
| 40 |
|
| 41 |
inline CS2Client(const unsigned int id, |
| 42 |
Network::TcpConnection* connection, |
| 43 |
Manager& manager) |
| 44 |
: MaerklinCANCommon("affeaffe", |
| 45 |
ControlIdCS2Server, |
| 46 |
&manager, |
| 47 |
true, |
| 48 |
Logger::Logger::GetLogger("CS2Client # " + std::to_string(id))), |
| 49 |
id(id), |
| 50 |
connection(connection), |
| 51 |
terminated(false) |
| 52 |
{ |
| 53 |
Init(); |
| 54 |
} |
| 55 |
|
| 56 |
virtual ~CS2Client() |
| 57 |
{ |
| 58 |
} |
| 59 |
|
| 60 |
inline void Stop() |
| 61 |
{ |
| 62 |
run = false; |
| 63 |
} |
| 64 |
|
| 65 |
inline bool IsTerminated() |
| 66 |
{ |
| 67 |
return terminated; |
| 68 |
} |
| 69 |
|
| 70 |
protected: |
| 71 |
void Receiver() override; |
| 72 |
|
| 73 |
void Send(const unsigned char* buffer) override; |
| 74 |
|
| 75 |
private: |
| 76 |
void ReceiverImpl(); |
| 77 |
|
| 78 |
virtual void CacheSave(__attribute__((unused)) Hardware::LocoCacheEntry& entry) override |
| 79 |
{ |
| 80 |
} |
| 81 |
|
| 82 |
virtual void CacheSave(__attribute__((unused)) Hardware::LocoCacheEntry& entry, __attribute__((unused)) const std::string& oldMatchKey) override |
| 83 |
{ |
| 84 |
} |
| 85 |
|
| 86 |
virtual LocoID CacheDelete(__attribute__((unused)) const std::string& matchKey) override |
| 87 |
{ |
| 88 |
return LocoNone; |
| 89 |
} |
| 90 |
|
| 91 |
virtual void CacheUpdateSlaves() override |
| 92 |
{ |
| 93 |
} |
| 94 |
|
| 95 |
static const unsigned char CANCommandBufferLength = 13; |
| 96 |
|
| 97 |
unsigned int id; |
| 98 |
Network::TcpConnection* connection; |
| 99 |
bool terminated; |
| 100 |
}; |
| 101 |
}} |
| 102 |
|