ifw-ccf 6.0.0
 
Loading...
Searching...
No Matches
testThreadHelper.cpp
Go to the documentation of this file.
1
6
8
9
11public:
12 TestThread1(const std::string& thread_name,
13 ifw::ccf::mptk::MessageBus& message_bus,
14 const double period = 0.1):
15 ifw::ccf::mptk::Thread(thread_name, message_bus, period) {
16 m_msg_count = 0;
17 };
18
20
21 void UserLogic() {
22 bool timed_out;
24 if (MsgBus().ReceiveMessage(GetName(), 1, timed_out, message)) {
26 response(message, "OK", fmt::format("{} received msg# {}. Data: {}",
27 GetName().c_str(), ++m_msg_count,
28 message.Data().c_str()));
29 MsgBus().SendResponse(response);
30 }
31 };
32
33private:
34 int8_t m_msg_count;
35};
TestThread1(const std::string &thread_name, ifw::ccf::mptk::MessageBus &message_bus, const double period=0.1)
Definition testThreadHelper.cpp:12
~TestThread1()
Definition testThreadHelper.cpp:19
void UserLogic()
User provided business logic. The UserLogic method need not execute an internal loop....
Definition testThreadHelper.cpp:21
IFW CTD Multiprocessing Toolkit Message Bus.
Definition messageBus.hpp:92
void SendResponse(Response &response)
Send a response to a message received on the Message Bus.
Definition messageBus.cpp:150
IFW CTD Multiprocessing Toolkit Message class.
Definition message.hpp:25
const std::string & Data() const
Return data (payload) of message.
Definition message.cpp:90
IFW CTD Multiprocessing Toolkit Response class.
Definition response.hpp:21
IFW CTD Multiprocessing Toolkit Thread base class.
Definition thread.hpp:31
MessageBus & MsgBus()
Get acces to the MessageBus associated with this thread object.
Definition thread.cpp:236
std::string GetName() const
Return the thread Name.
Definition thread.cpp:73
Thread(const std::string &thread_name, MessageBus &message_bus, const double period=0.1)
Constructor method, setting up the internal members.
Definition thread.cpp:42
Definition appBase.cpp:10