• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
2 // This Source Code Form is subject to the terms of the Mozilla Public
3 // License, v. 2.0. If a copy of the MPL was not distributed with this
4 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 
6 #ifndef BIGPAYLOADTESTCLIENT_HPP_
7 #define BIGPAYLOADTESTCLIENT_HPP_
8 
9 #include <gtest/gtest.h>
10 
11 #include <vsomeip/vsomeip.hpp>
12 
13 #include <thread>
14 #include <mutex>
15 #include <condition_variable>
16 #include <functional>
17 #include <atomic>
18 
19 #include "big_payload_test_globals.hpp"
20 #include <vsomeip/internal/logger.hpp>
21 
22 class big_payload_test_client
23 {
24 public:
25     big_payload_test_client(bool _use_tcp, big_payload_test::test_mode _random_mode);
26     bool init();
27     void start();
28     void stop();
29     void join_sender_thread();
30     void on_state(vsomeip::state_type_e _state);
31     void on_availability(vsomeip::service_t _service,
32             vsomeip::instance_t _instance, bool _is_available);
33     void on_message(const std::shared_ptr<vsomeip::message> &_response);
34     void send();
35     void run();
36 
37 private:
38     std::shared_ptr<vsomeip::application> app_;
39     std::shared_ptr<vsomeip::message> request_;
40     std::mutex mutex_;
41     std::condition_variable condition_;
42     bool blocked_;
43     bool is_available_;
44     big_payload_test::test_mode test_mode_;
45     std::uint32_t number_of_messages_to_send_;
46     std::uint32_t number_of_sent_messages_;
47     std::atomic<std::uint32_t> number_of_acknowledged_messages_;
48     std::thread sender_;
49     vsomeip::service_t service_id_;
50 };
51 
52 #endif /* BIGPAYLOADTESTCLIENT_HPP_ */
53