xscallback.h
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #ifndef XSCALLBACK_H
66 #define XSCALLBACK_H
67 
68 #include "xscallbackplainc.h"
69 
70 #ifdef __cplusplus
71 
87 class XsCallback : public XsCallbackPlainC
88 {
89 public:
91  XsCallback()
92  {
93  m_onDeviceStateChanged = sonDeviceStateChanged;
94  m_onLiveDataAvailable = sonLiveDataAvailable;
95  m_onMissedPackets = sonMissedPackets;
96  m_onWakeupReceived = sonWakeupReceived;
97  m_onProgressUpdated = sonProgressUpdated;
98  m_onWriteMessageToLogFile = sonWriteMessageToLogFile;
99  m_onBufferedDataAvailable = sonBufferedDataAvailable;
100  m_onConnectivityChanged = sonConnectivityChanged;
101  m_onInfoResponse = sonInfoResponse;
102  m_onError = sonError;
103  m_onNonDataMessage = sonNonDataMessage;
104  m_onMessageDetected = sonMessageDetected;
105  m_onMessageReceivedFromDevice = sonMessageReceivedFromDevice;
106  m_onMessageSentToDevice = sonMessageSentToDevice;
107  m_onAllLiveDataAvailable = sonAllLiveDataAvailable;
108  m_onAllBufferedDataAvailable = sonAllBufferedDataAvailable;
109  m_onDataUnavailable = sonDataUnavailable;
110  m_onDataAvailable = sonDataAvailable;
111  m_onAllDataAvailable = sonAllDataAvailable;
112  m_onRecordedDataAvailable = sonRecordedDataAvailable;
113  m_onAllRecordedDataAvailable = sonAllRecordedDataAvailable;
114  m_onTransmissionRequest = sonTransmissionRequest;
115  m_onRestoreCommunication = sonRestoreCommunication;
116  }
117 
121  virtual ~XsCallback() {}
122 
123  // Swig needs these functions to be protected, not private, otherwise they are ignored.
124 protected:
129  virtual void onDeviceStateChanged(XsDevice* dev, XsDeviceState newState, XsDeviceState oldState)
131  {
132  (void) dev;
133  (void) newState;
134  (void) oldState;
135  m_onDeviceStateChanged = 0;
136  }
138  virtual void onLiveDataAvailable(XsDevice* dev, const XsDataPacket* packet)
139  {
140  (void) dev;
141  (void) packet;
142  m_onLiveDataAvailable = 0;
143  }
145  virtual void onMissedPackets(XsDevice* dev, int count, int first, int last)
146  {
147  (void) dev;
148  (void)count;
149  (void) first;
150  (void) last;
151  m_onMissedPackets = 0;
152  }
154  virtual void onWakeupReceived(XsDevice* dev)
155  {
156  (void) dev;
157  m_onWakeupReceived = 0;
158  }
160  virtual void onProgressUpdated(XsDevice* dev, int current, int total, const XsString* identifier)
161  {
162  (void) dev;
163  (void) current;
164  (void) total;
165  (void)identifier;
166  m_onProgressUpdated = 0;
167  }
169  virtual int onWriteMessageToLogFile(XsDevice* dev, const XsMessage* message)
170  {
171  (void) dev;
172  (void) message;
173  m_onWriteMessageToLogFile = 0;
174  return 1;
175  }
177  virtual void onBufferedDataAvailable(XsDevice* dev, const XsDataPacket* packet)
178  {
179  (void)dev;
180  (void)packet;
181  m_onBufferedDataAvailable = 0;
182  }
184  virtual void onConnectivityChanged(XsDevice* dev, XsConnectivityState newState)
185  {
186  (void) dev;
187  (void) newState;
188  m_onConnectivityChanged = 0;
189  }
191  virtual void onInfoResponse(XsDevice* dev, XsInfoRequest request)
192  {
193  (void) dev;
194  (void) request;
195  m_onInfoResponse = 0;
196  }
198  virtual void onError(XsDevice* dev, XsResultValue error)
199  {
200  (void) dev;
201  (void) error;
202  m_onError = 0;
203  }
205  virtual void onNonDataMessage(XsDevice* dev, XsMessage const* message)
206  {
207  (void) dev;
208  (void) message;
209  m_onNonDataMessage = 0;
210  }
212  virtual void onMessageDetected(XsDevice* dev, XsProtocolType type, XsByteArray const* rawMessage)
213  {
214  (void)dev;
215  (void)type;
216  (void)rawMessage;
217  m_onMessageDetected = 0;
218  }
220  virtual void onMessageReceivedFromDevice(XsDevice* dev, XsMessage const* message)
221  {
222  (void) dev;
223  (void) message;
224  m_onMessageReceivedFromDevice = 0;
225  }
227  virtual void onMessageSentToDevice(XsDevice* dev, XsMessage const* message)
228  {
229  (void) dev;
230  (void) message;
231  m_onMessageSentToDevice = 0;
232  }
234  virtual void onAllLiveDataAvailable(XsDevicePtrArray* devs, const XsDataPacketPtrArray* packets)
235  {
236  (void) devs;
237  (void) packets;
238  m_onAllLiveDataAvailable = 0;
239  }
241  virtual void onAllBufferedDataAvailable(XsDevicePtrArray* devs, const XsDataPacketPtrArray* packets)
242  {
243  (void)devs;
244  (void)packets;
245  m_onAllBufferedDataAvailable = 0;
246  }
248  virtual void onDataUnavailable(XsDevice* dev, int64_t packetId)
249  {
250  (void) dev;
251  (void)packetId;
252  m_onMissedPackets = 0;
253  }
255  virtual void onDataAvailable(XsDevice* dev, const XsDataPacket* packet)
256  {
257  (void) dev;
258  (void) packet;
259  m_onDataAvailable = 0;
260  }
262  virtual void onAllDataAvailable(XsDevicePtrArray* devs, const XsDataPacketPtrArray* packets)
263  {
264  (void) devs;
265  (void) packets;
266  m_onAllDataAvailable = 0;
267  }
269  virtual void onRecordedDataAvailable(XsDevice* dev, const XsDataPacket* packet)
270  {
271  (void) dev;
272  (void) packet;
273  m_onRecordedDataAvailable = 0;
274  }
276  virtual void onAllRecordedDataAvailable(XsDevicePtrArray* devs, const XsDataPacketPtrArray* packets)
277  {
278  (void) devs;
279  (void) packets;
280  m_onAllRecordedDataAvailable = 0;
281  }
283  virtual void onTransmissionRequest(int channelId, const XsByteArray* data)
284  {
285  (void) channelId;
286  (void)data;
287  }
289  virtual void onRestoreCommunication(const XsString* portName, XsResultValue result)
290  {
291  (void)portName;
292  (void)result;
293  m_onRestoreCommunication = 0;
294  }
295 
297 
298 private:
300  static void sonDeviceStateChanged(XsCallbackPlainC* cb, XsDevice* dev, XsDeviceState newState, XsDeviceState oldState)
301  {
302  ((XsCallback*)cb)->onDeviceStateChanged(dev, newState, oldState);
303  }
304  static void sonLiveDataAvailable(XsCallbackPlainC* cb, XsDevice* dev, const XsDataPacket* packet)
305  {
306  ((XsCallback*)cb)->onLiveDataAvailable(dev, packet);
307  }
308  static void sonMissedPackets(XsCallbackPlainC* cb, XsDevice* dev, int count, int first, int last)
309  {
310  ((XsCallback*)cb)->onMissedPackets(dev, count, first, last);
311  }
312  static void sonWakeupReceived(XsCallbackPlainC* cb, XsDevice* dev)
313  {
314  ((XsCallback*)cb)->onWakeupReceived(dev);
315  }
316  static void sonProgressUpdated(XsCallbackPlainC* cb, XsDevice* dev, int current, int total, const XsString* identifier)
317  {
318  ((XsCallback*)cb)->onProgressUpdated(dev, current, total, identifier);
319  }
320  static int sonWriteMessageToLogFile(XsCallbackPlainC* cb, XsDevice* dev, const XsMessage* message)
321  {
322  return ((XsCallback*)cb)->onWriteMessageToLogFile(dev, message);
323  }
324  static void sonBufferedDataAvailable(XsCallbackPlainC* cb, XsDevice* dev, const XsDataPacket* packet)
325  {
326  ((XsCallback*)cb)->onBufferedDataAvailable(dev, packet);
327  }
328  static void sonConnectivityChanged(XsCallbackPlainC* cb, XsDevice* dev, XsConnectivityState newState)
329  {
330  ((XsCallback*)cb)->onConnectivityChanged(dev, newState);
331  }
332  static void sonInfoResponse(XsCallbackPlainC* cb, XsDevice* dev, XsInfoRequest request)
333  {
334  ((XsCallback*)cb)->onInfoResponse(dev, request);
335  }
336  static void sonError(XsCallbackPlainC* cb, XsDevice* dev, XsResultValue error)
337  {
338  ((XsCallback*)cb)->onError(dev, error);
339  }
340  static void sonNonDataMessage(XsCallbackPlainC* cb, XsDevice* dev, XsMessage const* message)
341  {
342  ((XsCallback*)cb)->onNonDataMessage(dev, message);
343  }
344  static void sonMessageDetected(XsCallbackPlainC* cb, XsDevice* dev, XsProtocolType type, XsByteArray const* rawMessage)
345  {
346  ((XsCallback*)cb)->onMessageDetected(dev, type, rawMessage);
347  }
348  static void sonMessageReceivedFromDevice(XsCallbackPlainC* cb, XsDevice* dev, XsMessage const* message)
349  {
350  ((XsCallback*)cb)->onMessageReceivedFromDevice(dev, message);
351  }
352  static void sonMessageSentToDevice(XsCallbackPlainC* cb, XsDevice* dev, XsMessage const* message)
353  {
354  ((XsCallback*)cb)->onMessageSentToDevice(dev, message);
355  }
356  static void sonAllLiveDataAvailable(XsCallbackPlainC* cb, XsDevicePtrArray* devs, const XsDataPacketPtrArray* packets)
357  {
358  ((XsCallback*)cb)->onAllLiveDataAvailable(devs, packets);
359  }
360  static void sonAllBufferedDataAvailable(XsCallbackPlainC* cb, XsDevicePtrArray* devs, const XsDataPacketPtrArray* packets)
361  {
362  ((XsCallback*)cb)->onAllBufferedDataAvailable(devs, packets);
363  }
364  static void sonDataUnavailable(XsCallbackPlainC* cb, XsDevice* dev, int64_t packetId)
365  {
366  ((XsCallback*)cb)->onDataUnavailable(dev, packetId);
367  }
368  static void sonDataAvailable(XsCallbackPlainC* cb, XsDevice* dev, const XsDataPacket* packet)
369  {
370  ((XsCallback*)cb)->onDataAvailable(dev, packet);
371  }
372  static void sonAllDataAvailable(XsCallbackPlainC* cb, XsDevicePtrArray* devs, const XsDataPacketPtrArray* packets)
373  {
374  ((XsCallback*)cb)->onAllDataAvailable(devs, packets);
375  }
376  static void sonRecordedDataAvailable(XsCallbackPlainC* cb, XsDevice* dev, const XsDataPacket* packet)
377  {
378  ((XsCallback*)cb)->onRecordedDataAvailable(dev, packet);
379  }
380  static void sonAllRecordedDataAvailable(XsCallbackPlainC* cb, XsDevicePtrArray* devs, const XsDataPacketPtrArray* packets)
381  {
382  ((XsCallback*)cb)->onAllRecordedDataAvailable(devs, packets);
383  }
384  static void sonTransmissionRequest(XsCallbackPlainC* cb, int channelId, const XsByteArray* data)
385  {
386  ((XsCallback*)cb)->onTransmissionRequest(channelId, data);
387  }
388  static void sonRestoreCommunication(XsCallbackPlainC* cb, const XsString* portName, XsResultValue result)
389  {
390  ((XsCallback*)cb)->onRestoreCommunication(portName, result);
391  }
392 };
393 #endif
394 
395 #endif
XsDataPacketPtrArray
A list of XsDataPacketPtr values.
XsByteArray
A list of uint8_t values.
XsCallbackPlainC
Structure that contains callback functions for the Xsens Device API.
Definition: xscallbackplainc.h:99
XsDataPacket
Contains an interpreted data message. The class provides easy access to the contained data through it...
Definition: xsdatapacket.h:301
XsResultValue
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:82
xscallbackplainc.h
XsInfoRequest
XsInfoRequest
Information request identifiers.
Definition: xsinforequest.h:77
XsMessage
Structure for storing a single message.
Definition: xsmessage.h:202
XsDevicePtrArray
A list of XsDevicePtr values.
XsConnectivityState
XsConnectivityState
XsDevice connectivity state identifiers.
Definition: xsconnectivitystate.h:78
XsProtocolType
XsProtocolType
Protocol types (XsDevice::enableProtocol())
Definition: xsprotocoltype.h:72
XsDeviceState
XsDeviceState
XsDevice state identifiers.
Definition: xsdevicestate.h:77
XsString
A 0-terminated managed string of characters.
XsDevice
Definition: xsdevice_def.h:164


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20