// Copyright (C) 2015-2019 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef PAYLOADTESTCLIENT_HPP_ #define NPDUTESTCLIENT_HPP_ #include #include #include #include #include #include #include #include "../npdu_tests/npdu_test_globals.hpp" #include "../someip_test_globals.hpp" class npdu_test_client { public: npdu_test_client(bool _use_tcp, bool _call_service_sync, std::uint32_t _sliding_window_size, bool _wait_for_replies, std::array, 4> _applicative_debounce); ~npdu_test_client(); void init(); void start(); void stop(); void join_sender_thread(); void on_state(vsomeip::state_type_e _state); template void on_availability(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available); template void on_message( const std::shared_ptr &_response); template void send(); template void run(); private: template void send_messages_sync(); template std::thread start_send_thread_sync(); template void send_messages_async(); template std::thread start_send_thread_async(); template void send_messages_and_dont_wait_for_reply(); std::uint32_t get_max_allowed_payload(); template void register_availability_handler(); template void register_message_handler_for_all_service_methods(); template void register_message_handler(); template std::thread start_send_thread(); void wait_for_all_senders(); private: std::shared_ptr app_; std::shared_ptr request_; bool call_service_sync_; bool wait_for_replies_; std::uint32_t sliding_window_size_; std::array mutexes_; std::array conditions_; std::array blocked_; std::array is_available_; const std::uint32_t number_of_messages_to_send_; std::uint32_t number_of_sent_messages_[npdu_test::service_ids.size()]; std::array, npdu_test::service_ids.size()> number_of_acknowledged_messages_; std::array, npdu_test::service_ids.size()> number_of_acknowledged_messages_mutexes_; std::array current_payload_size_; std::array, npdu_test::service_ids.size()> all_msg_acknowledged_; std::array, npdu_test::service_ids.size()> all_msg_acknowledged_mutexes_; std::array, npdu_test::method_ids[0].size()>, npdu_test::service_ids.size()> all_msg_acknowledged_unique_locks_; std::array< std::array, npdu_test::service_ids.size()> all_msg_acknowledged_cvs_; std::array acknowledgements_; std::array, 4> applicative_debounce_; std::array< std::array, npdu_test::method_ids[0].size()>, npdu_test::service_ids.size()> payloads_; std::array< std::array, npdu_test::method_ids[0].size()>, npdu_test::service_ids.size()> payload_data_; std::array senders_; std::mutex finished_mutex_; std::array finished_; std::thread finished_waiter_; }; #endif /* NPDUTESTCLIENT_HPP_ */