source: rtems/c/src/librtems++/include/rtems++/rtemsEvent.h @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2  ------------------------------------------------------------------------
3
4  COPYRIGHT (c) 1997
5  Objective Design Systems Ltd Pty (ODS)
6  All rights reserved (R) Objective Design Systems Ltd Pty
7
8  The license and distribution terms for this file may be found in the
9  file LICENSE in this distribution or at
10  http://www.rtems.org/license/LICENSE.
11
12  ------------------------------------------------------------------------
13
14  rtemsEvent class.
15
16  This class allows the user to send and receive RTEMS events to a task.
17
18  ------------------------------------------------------------------------ */
19
20#if !defined(_rtemsEvent_h_)
21#define _rtemsEvent_h_
22
23#include <rtems++/rtemsStatusCode.h>
24#include <rtems++/rtemsTask.h>
25
26/* ----
27    rtemsEvent
28*/
29
30class rtemsEvent
31  : public rtemsStatusCode
32{
33public:
34  // attribute a task can have
35
36  enum WaitMode { wait = RTEMS_WAIT,
37                  no_wait = RTEMS_NO_WAIT};
38  enum Condition { any = RTEMS_EVENT_ANY,
39                   all = RTEMS_EVENT_ALL};
40
41  // only the first 4 characters of the name are taken
42
43  // connect to a task
44  rtemsEvent(const char* name, uint32_t node = RTEMS_SEARCH_ALL_NODES);
45
46  // copy and default constructors
47  rtemsEvent(const rtemsEvent& event);
48  rtemsEvent();
49
50  virtual ~rtemsEvent();
51
52  // connect to an existing task object, will not be the owner
53  const rtemsEvent& operator=(const rtemsEvent& event);
54  virtual const rtems_status_code connect(const char *name,
55                                          const uint32_t node = RTEMS_SEARCH_ALL_NODES);
56
57  // send an event
58  inline const rtems_status_code send(const rtems_id task,
59                                      const rtems_event_set events);
60  inline const rtems_status_code send(const rtemsTask& task,
61                                      const rtems_event_set events) ;
62  inline const rtems_status_code send(const rtems_event_set events);
63
64  // receive an event, can block a task if no events waiting
65  inline const rtems_status_code receive(const rtems_event_set event_in,
66                                         rtems_event_set& event_out,
67                                         const rtems_interval micro_secs = 0,
68                                         const WaitMode wait = wait,
69                                         const Condition condition = any);
70
71  // object id, and name
72  const rtems_id task_id_is() const { return id; }
73  const rtems_name task_name_is() const { return name; }
74
75private:
76  // task name
77  rtems_name name;
78
79  // the rtems task id, object handle
80  rtems_id id;
81
82};
83
84const rtems_status_code rtemsEvent::send(const rtems_id task,
85                                         const rtems_event_set events)
86{
87  set_status_code(rtems_event_send(task, events));
88  return last_status_code();
89}
90
91const rtems_status_code rtemsEvent::send(const rtemsTask& task,
92                                         const rtems_event_set events)
93{
94  set_status_code(rtems_event_send(task.id_is(), events));
95  return last_status_code();
96}
97
98const rtems_status_code rtemsEvent::send(const rtems_event_set events)
99{
100  set_status_code(rtems_event_send(id, events));
101  return last_status_code();
102}
103
104const rtems_status_code rtemsEvent::receive(const rtems_event_set event_in,
105                                            rtems_event_set& event_out,
106                                            const rtems_interval micro_secs,
107                                            const WaitMode wait,
108                                            const Condition condition)
109{
110  rtems_interval usecs = micro_secs &&
111    (micro_secs < rtems_configuration_get_microseconds_per_tick()) ?
112    rtems_configuration_get_microseconds_per_tick() : micro_secs;
113  set_status_code(rtems_event_receive(event_in,
114                                      wait | condition,
115                                      RTEMS_MICROSECONDS_TO_TICKS(usecs),
116                                      &event_out));
117  return last_status_code();
118}
119
120#endif  // _rtemsEvent_h_
Note: See TracBrowser for help on using the repository browser.