1
|
/**
|
2
|
*
|
3
|
* Base I/O device filter implementation.
|
4
|
*
|
5
|
* @file
|
6
|
* Copyright © Audi Electronics Venture GmbH. All rights reserved.
|
7
|
*
|
8
|
* $Author: wartand $
|
9
|
* $Date: 2014-03-12 09:00:13 +0100 (Mit, 12 Mär 2014) $
|
10
|
* $Revision: 45069 $
|
11
|
*
|
12
|
* @remarks
|
13
|
*
|
14
|
*/
|
15
|
#ifndef _ADTF_BASE_IO_DEVICE_FILTER_HEADER_
|
16
|
#define _ADTF_BASE_IO_DEVICE_FILTER_HEADER_
|
17
|
|
18
|
namespace adtf
|
19
|
{
|
20
|
|
21
|
/**
|
22
|
*
|
23
|
* I/O device trigger.
|
24
|
*
|
25
|
*/
|
26
|
class DOEXPORT IDeviceTrigger
|
27
|
{
|
28
|
public:
|
29
|
/**
|
30
|
*
|
31
|
* Cyclic device trigger. The OnDeviceTrigger method is periodically called by the device
|
32
|
* control thread depending on the device operation flags.
|
33
|
*
|
34
|
* @param pvUserData [in,out] Currently not used.
|
35
|
* @return Returns a standard result code.
|
36
|
*
|
37
|
*/
|
38
|
virtual tResult OnDeviceTrigger(tVoid* pvUserData) = 0;
|
39
|
};
|
40
|
|
41
|
/**
|
42
|
* Base generic I/O device filters.
|
43
|
*
|
44
|
* It defines the basic implementation that is needed to use a @ref cBaseIODevice.
|
45
|
*
|
46
|
* \n For implementing the cMyDevice shown in this example use the @ref adtf::cBaseIODevice.
|
47
|
*
|
48
|
*
|
49
|
* \n To use this default filter declare:
|
50
|
* \code
|
51
|
* cMyDeviceFilter : public adtf::cBaseIODeviceFilter
|
52
|
* {
|
53
|
* ADTF_FILTER("adtf.io.my_dev_filter", "My Device Filter", OBJCAT_SensorDevice);
|
54
|
* private:
|
55
|
* cMyDeviceFilter m_oMyDevice;
|
56
|
* public:
|
57
|
* cMyDeviceFilter(const tChar*);
|
58
|
* virtual ~cMyDeviceFilter();
|
59
|
* };
|
60
|
* \endcode
|
61
|
*
|
62
|
* \n The implementation is very easy like:
|
63
|
* \code
|
64
|
* ADTF_FILTER_PLUGIN("My Device Filter Plugin", "adtf.io.my_dev_filter", cMyDeviceFilter)
|
65
|
*
|
66
|
* cMyDeviceFilter::cMyDeviceFilter(const tChar* __info)
|
67
|
* : adtf::cBaseIODeviceFilter(__info)
|
68
|
* {
|
69
|
* m_pDevice = &m_oMyDevice;
|
70
|
* }
|
71
|
*
|
72
|
* cMyDeviceFilter::~cMyDeviceFilter()
|
73
|
* {
|
74
|
* }
|
75
|
* \endcode
|
76
|
* @see adtf::cBaseIODevice, iodevice.cpp, iodevicefilter.cpp.
|
77
|
* @see The examples added within the SDK will show the using of this (empty_can) and the implementation of the base classes are added.
|
78
|
*
|
79
|
*/
|
80
|
class DOEXPORT cBaseIODeviceFilter : public adtf::cFilter,
|
81
|
public IDeviceTrigger,
|
82
|
public IDeviceEventHandler
|
83
|
{
|
84
|
ADTF_D(cBaseIODeviceFilter)
|
85
|
|
86
|
protected:
|
87
|
static const tChar* m_strDefaultDeviceName; //!< @todo
|
88
|
|
89
|
protected:
|
90
|
adtf_util::cStatistics* m_pStatistics; //!< @todo
|
91
|
ucom::IDevice* m_pDevice; //!< @todo
|
92
|
tHandle m_hStorageHandle; //!< @todo
|
93
|
tTimeStamp m_nLastDataTime; //!< @todo
|
94
|
cKernelThread* m_pTriggerThread; //!< @todo
|
95
|
tFloat32 m_f32UpdateRate;
|
96
|
//!< specifies the update rate in Hz
|
97
|
tTimeStamp m_nMinDelay; //!< @todo
|
98
|
tBool m_bSyncEnable; //!< @todo
|
99
|
|
100
|
public:
|
101
|
/**
|
102
|
* Constructor
|
103
|
*/
|
104
|
cBaseIODeviceFilter(const tChar*);
|
105
|
virtual ~cBaseIODeviceFilter();
|
106
|
|
107
|
public: // overrides cFilter
|
108
|
/**
|
109
|
* @copydoc cFilter::Init
|
110
|
* @remarks overrides @ref cFilter::Init
|
111
|
*/
|
112
|
tResult Init(cFilter::tInitStage eStage, ucom::IException** __exception_ptr=NULL);
|
113
|
|
114
|
/**
|
115
|
* @copydoc cFilter::Start
|
116
|
* @remarks overrides @ref cFilter::Start
|
117
|
*/
|
118
|
tResult Start(ucom::IException** __exception_ptr=NULL);
|
119
|
|
120
|
/**
|
121
|
* @copydoc cFilter::Stop
|
122
|
* @remarks overrides @ref cFilter::Stop
|
123
|
*/
|
124
|
tResult Stop(ucom::IException** __exception_ptr=NULL);
|
125
|
|
126
|
/**
|
127
|
* @copydoc cFilter::Shutdown
|
128
|
* @remarks overrides @ref cFilter::Shutdown
|
129
|
*/
|
130
|
tResult Shutdown(cFilter::tInitStage eStage, ucom::IException** __exception_ptr=NULL);
|
131
|
|
132
|
public: // implements IDeviceTrigger
|
133
|
/**
|
134
|
* @copydoc IDeviceTrigger::OnDeviceTrigger
|
135
|
* @remarks overrides @ref IDeviceTrigger::OnDeviceTrigger
|
136
|
*/
|
137
|
tResult OnDeviceTrigger(tVoid* pvUserData);
|
138
|
|
139
|
public: // implements IDeviceEventHandler
|
140
|
/**
|
141
|
* @copydoc IDeviceEventHandler::OnDeviceEvent
|
142
|
* @remarks overrides @ref IDeviceEventHandler::OnDeviceEvent
|
143
|
*/
|
144
|
tResult OnDeviceEvent(tInt nEventId, tInt nParam1, tInt nParam2, tVoid* pvData, tInt nDataSize);
|
145
|
|
146
|
protected: // base methods
|
147
|
/**
|
148
|
*
|
149
|
* Reads and transmits data. This methods reads data from the device, allocs a media sample
|
150
|
* and finally transmits all data.
|
151
|
*
|
152
|
* @retval ERR_NOERROR Transmission is success or no new data available
|
153
|
* @retval ERR_DEVICE_NOT_READY Device is not ready
|
154
|
* @retval ERR_DEVICE_IO cannot read from device
|
155
|
* @return other return codes results in problems with media samples
|
156
|
*
|
157
|
*/
|
158
|
virtual tResult ReadAndTransmitData();
|
159
|
|
160
|
/**
|
161
|
*
|
162
|
* Create and initialize all pin instances. This methods is responsible for creating and
|
163
|
* initializing all pin instances. For that purpose, the method might also declare the
|
164
|
* input/output media type descriptors.
|
165
|
*
|
166
|
* @return Returns a standard result code.
|
167
|
*
|
168
|
*/
|
169
|
virtual tResult OnCreatePins();
|
170
|
|
171
|
/**
|
172
|
*
|
173
|
* Transmit data. Overwrite this method to map output data to the corresponding output pins
|
174
|
* and to actually transmit a sample.
|
175
|
*
|
176
|
* @param [in] pSample sample to be transmitted
|
177
|
* @return Returns a standard result code.
|
178
|
*
|
179
|
*/
|
180
|
virtual tResult OnTransmitData(IMediaSample* pSample);
|
181
|
|
182
|
/**
|
183
|
*
|
184
|
* Retrieve type information. Overwrite this method to offer type info to the caller.
|
185
|
* A standard implementation might forward the call to the output pin's GetMediaType()
|
186
|
* method.
|
187
|
*
|
188
|
* @param [in] ppMediaType pointer to a media type instance
|
189
|
* @return Returns a standard result code.
|
190
|
*
|
191
|
*/
|
192
|
virtual tResult OnGetMediaType(IMediaType** ppMediaType);
|
193
|
|
194
|
/**
|
195
|
*
|
196
|
* Check update rate limit. Overwrite this method to do manual update rate control.
|
197
|
*
|
198
|
* @return Returns no error if update is needed and error-cancelled for update rate
|
199
|
* limitation.
|
200
|
*
|
201
|
*/
|
202
|
virtual tResult CheckUpdateRate();
|
203
|
|
204
|
};
|
205
|
|
206
|
} // namespace adtf
|
207
|
|
208
|
//*************************************************************************************************
|
209
|
#endif // _ADTF_BASE_IO_DEVICE_FILTER_HEADER_
|