ED247 Library  VA2.3.0
Implementation of ED247-A standard
ed247_context.h
1 /* -*- mode: c++; c-basic-offset: 2 -*- */
2 /******************************************************************************
3  * The MIT Licence
4  *
5  * Copyright (c) 2021 Airbus Operations S.A.S
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23  * OTHER DEALINGS IN THE SOFTWARE.
24  *****************************************************************************/
25 #ifndef _ED247_CONTEXT_H_
26 #define _ED247_CONTEXT_H_
27 #include "ed247_xml.h"
28 #include "ed247_channel.h"
29 
30 // base structures for C API
32 
33 namespace ed247
34 {
35 
37  {
38  public:
39  static Context* create_from_filepath(std::string ecic_filepath);
40  static Context* create_from_content(std::string ecic_content);
41 
42  Context(const Context &) = delete;
43  Context(Context &&) = delete;
44  Context& operator=(const Context &) = delete;
45  Context& operator=(Context &&) = delete;
46 
47  // configuration accessors
48  const std::string& get_file_producer_identifier() { return _configuration->_file_producer_identifier; }
49  const std::string& get_file_producer_comment() { return _configuration->_file_producer_comment; }
50  const std::string& get_version() { return _configuration->_version; }
51  ed247_component_type_t get_component_type() { return _configuration->_component_type; }
52  const std::string& get_name() { return _configuration->_name; }
53  const std::string& get_comment() { return _configuration->_comment; }
54  ed247_uid_t get_identifier() { return _configuration->_identifier; }
55  ed247_standard_t get_standard_revision() { return _configuration->_standard_revision; }
56 
57 
58  // Handle user-data
59  void set_user_data(void *user_data) { _user_data = user_data; }
60  void get_user_data(void **user_data) { *user_data = _user_data; }
61 
62 
63  // Content access
64  udp::ReceiverSet& get_receiver_set() { return _receiver_set; }
65  SignalSet& get_signal_set() { return _signal_set; }
66  StreamSet& get_stream_set() { return _stream_set; }
67  ChannelSet& get_channel_set() { return _channel_set; }
68 
69  // Client lists (ed247.h interface)
70  ed247_internal_stream_list_t* get_client_streams() { return _client_streams.get(); }
71  ed247_internal_stream_list_t* get_client_streams_with_data() { return _client_streams_with_data.get(); }
72  ed247_internal_channel_list_t* get_client_channels() { return _client_channels.get(); }
73 
74  // Push all stream assistants whose signals have been written since last push_sample()
75  // This function will only call StreamAssistant::push_if_was_written() for all output stream assistants
76  // Return false only for fatal error (see stream::push_sample() for details)
77  bool stream_assistants_written_push_samples(const ed247_timestamp_t* data_timestamp);
78 
79  // Pop all samples of all input signal based streams.
80  // After this call, all stream assistants will provide the last received signals value throught the read() method.
81  // If a singal has never been received, its value will be 0.
82  // This function is equivalent to call pop() on all stream assistants until all fifos are empties.
83  // Return false only for fatal error (see stream::push_sample() for details)
85 
86  // Send all pushed streams in their respective channels/CommInterface
87  void send_pushed_samples();
88 
89  // Receive frames and fill associated streams
90  ed247_status_t wait_frame(int32_t timeout_us);
91  ed247_status_t wait_during(int32_t duration_us);
92 
93  private:
94  Context(std::unique_ptr<xml::Component>&& configuration);
95 
96  std::unique_ptr<xml::Component> _configuration;
97  void* _user_data;
98 
99  udp::ReceiverSet _receiver_set;
100  SignalSet _signal_set;
101  StreamSet _stream_set;
102  ChannelSet _channel_set;
103 
104  std::unique_ptr<ed247_internal_stream_list_t> _client_streams;
105  std::unique_ptr<ed247_internal_stream_list_t> _client_streams_with_data;
106  std::unique_ptr<ed247_internal_channel_list_t> _client_channels;
107 
108  ED247_FRIEND_TEST();
109  };
110 
111 }
112 
113 #endif
Definition: ed247_cominterface.h:131
Definition: ed247_signal.h:89
Definition: ed247_channel.h:93
ed247_standard_t
ED247 Standard revisions.
Definition: ed247.h:104
Definition: ed247_stream.h:168
ed247_component_type_t
Component types.
Definition: ed247.h:121
Timestamp structure, seconds from EPOCH (January 1st 1970) and nanoseconds offset with reference to p...
Definition: ed247.h:209
uint16_t ed247_uid_t
Unique identifier type.
Definition: ed247.h:115
Definition: ed247_stream.h:34
Definition: ed247_context.h:36
ed247_status_t
Status codes.
Definition: ed247.h:67
Definition: ed247_channel.cpp:37
Definition: ed247_channel.h:35
ed247_status_t stream_assistants_pop_samples(ed247_context_t context)
Pop all samples of all input stream assistants. aka &#39;update all signals&#39;.
Definition: ed247.cpp:2024
Definition: ed247_context.h:31