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