xsdeviceconfiguration.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 XSDEVICECONFIGURATION_H
66 #define XSDEVICECONFIGURATION_H
67 
68 #include "xscontrollerconfig.h"
69 #include <xstypes/pstdint.h>
70 #include <xstypes/xsbusid.h>
71 #include <xstypes/xstypedefs.h>
72 #ifdef __cplusplus
73  #include <xstypes/xsexception.h>
74 #endif
75 
76 struct MtwInfo;
78 struct XsMessage;
79 struct XsDeviceId;
80 
81 #ifdef __cplusplus
82 extern "C" {
83 #else
84 #define XSDEVICEINFO_INITIALIZER { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
85 #define XSDEVICECONFIGURATION_INITIALIZER { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
86 #endif
87 
89 XDA_DLL_API void XsDeviceConfiguration_assign(struct XsDeviceConfiguration* thisPtr, XsSize numberOfDevices, const struct XsDeviceConfiguration* src);
95 XDA_DLL_API XsSize XsDeviceConfiguration_findDevice(const struct XsDeviceConfiguration* thisPtr, const struct XsDeviceId* deviceId);
96 
97 #ifdef __cplusplus
98 } // extern "C"
99 #endif
100 
103 {
104  uint64_t m_deviceId;
105  uint8_t m_reserved[8];
106  uint16_t m_filterProfile;
107  uint8_t m_fwRevMajor;
108  uint8_t m_fwRevMinor;
109  uint8_t m_fwRevRevision;
111  uint8_t m_filterMajor;
112  uint8_t m_filterMinor;
113 };
114 
116 
119 {
120  uint64_t m_masterDeviceId;
121  uint16_t m_samplingPeriod;
123  uint8_t m_reserved1[8];
124  uint8_t m_date[8];
125  uint8_t m_time[8];
126  uint8_t m_productCode[20];
127  uint8_t m_reserved2[44];
128 };
130 
131 #ifdef __cplusplus
132 
135 class XsDeviceConfigurationException : public XsException
136 {
137 public:
138  XsDeviceConfigurationException() : XsException("Invalid device configuration") {}
139 };
140 #endif
141 
144 {
145 #ifdef __cplusplus
146 
152  explicit XsDeviceConfiguration(uint16_t numberOfDevs = 0)
153  : m_numberOfDevices(0)
154  , m_deviceInfo(0)
155  {
156  memset(this, 0, sizeof(XsDeviceConfiguration));
157  if (numberOfDevs)
158  XsDeviceConfiguration_assign(this, numberOfDevs, 0);
159  }
160 
166  : m_numberOfDevices(0)
167  , m_deviceInfo(0)
168  {
169  memset(this, 0, sizeof(XsDeviceConfiguration));
170  XsDeviceConfiguration_copy(this, &other);
171  }
172 
180  inline const XsDeviceConfiguration& operator = (const XsDeviceConfiguration& other)
181  {
182  XsDeviceConfiguration_copy(this, &other);
183  return *this;
184  }
185 
187  inline ~XsDeviceConfiguration()
188  {
190  }
191 
193  inline void clear()
194  {
196  }
197 
201  inline bool empty() const
202  {
203  return m_numberOfDevices == 0;
204  }
205 
212  inline void readFromMessage(const XsMessage& msg)
213  {
215  }
216 
223  inline void writeToMessage(XsMessage& msg) const
224  {
226  }
227 
233  inline bool containsDevice(const XsDeviceId& deviceId) const
234  {
235  return XsDeviceConfiguration_findDevice(this, &deviceId) != 0;
236  }
237 
242  inline XsMtDeviceConfiguration const& deviceInfo(const XsDeviceId& deviceId) const
243  {
244  XsSize busId = XsDeviceConfiguration_findDevice(this, &deviceId);
245  if (busId == 0)
246  throw XsDeviceConfigurationException();
247 
248  return deviceInfo(busId);
249  }
250 
255  inline XsMtDeviceConfiguration& deviceInfo(const XsDeviceId& deviceId)
256  {
257  XsSize busId = XsDeviceConfiguration_findDevice(this, &deviceId);
258  if (busId == 0)
259  throw XsDeviceConfigurationException();
260 
261  return deviceInfo(busId);
262  }
263 
270  inline XsMtDeviceConfiguration& deviceInfo(XsSize busId)
271  {
272  if (!m_numberOfDevices)
273  throw XsDeviceConfigurationException();
274 
275  if (busId == XS_BID_MASTER)
276  return m_deviceInfo[0];
277 
278  if (busId > m_numberOfDevices)
279  throw XsDeviceConfigurationException();
280 
281  return m_deviceInfo[busId - 1];
282  }
283 
290  inline const XsMtDeviceConfiguration& deviceInfo(XsSize busId) const
291  {
292  if (!m_numberOfDevices)
293  throw XsDeviceConfigurationException();
294 
295  if (busId == XS_BID_MASTER)
296  return m_deviceInfo[0];
297 
298  if (busId > m_numberOfDevices)
299  throw XsDeviceConfigurationException();
300 
301  return m_deviceInfo[busId - 1];
302  }
303 
304 
309  inline XsMasterDeviceConfiguration& masterInfo()
310  {
311  return m_masterInfo;
312  }
313 
318  inline const XsMasterDeviceConfiguration& masterInfo() const
319  {
320  return m_masterInfo;
321  }
322 
326  inline void setNumberOfDevices(XsSize count)
327  {
328  XsDeviceConfiguration_assign(this, count, 0);
329  }
330 
334  inline XsSize numberOfDevices() const
335  {
336  return (XsSize) m_numberOfDevices;
337  }
338 
342  inline XsSize deviceCount() const
343  {
344  return numberOfDevices();
345  }
346 
347 private:
349 #endif
351  const uint16_t m_numberOfDevices;
353 };
354 
356 
357 #endif
XS_BID_MASTER
#define XS_BID_MASTER
The bus identifier of the master device.
Definition: xsbusid.h:73
XsMtDeviceConfiguration::m_filterType
char m_filterType
The filter type.
Definition: xsdeviceconfiguration.h:110
XsMtDeviceConfiguration::m_fwRevRevision
uint8_t m_fwRevRevision
The revision version of the firmware.
Definition: xsdeviceconfiguration.h:109
xsexception.h
XsDeviceConfiguration::XsDeviceConfiguration_assign
void XsDeviceConfiguration_assign(XsDeviceConfiguration *thisPtr, XsSize numberOfDevices, const XsDeviceConfiguration *src)
Reinitializes the XsDeviceConfiguration with space for numberOfDevices devices and copies them from s...
Definition: xsdeviceconfiguration.c:96
XsMtDeviceConfiguration::m_filterProfile
uint16_t m_filterProfile
The currently chosen filter profile.
Definition: xsdeviceconfiguration.h:106
msg
msg
XsDeviceConfiguration::XsDeviceConfiguration_destruct
void XsDeviceConfiguration_destruct(XsDeviceConfiguration *thisPtr)
Clears and frees data in the XsDeviceConfiguration.
Definition: xsdeviceconfiguration.c:122
XsDeviceConfiguration
Structure containing a full device configuration as returned by the ReqConfig message.
Definition: xsdeviceconfiguration.h:143
XsMtDeviceConfiguration::m_deviceId
uint64_t m_deviceId
This device ID.
Definition: xsdeviceconfiguration.h:104
xstypedefs.h
XsDeviceConfiguration::XsDeviceConfiguration_empty
int XsDeviceConfiguration_empty(const XsDeviceConfiguration *thisPtr)
Returns true if the XsDeviceConfiguration is empty.
Definition: xsdeviceconfiguration.c:148
XsDeviceConfiguration::XsDeviceConfiguration_writeToMessage
void XsDeviceConfiguration_writeToMessage(const XsDeviceConfiguration *thisPtr, XsMessage *msg)
Creates a message msg that represents the XsDeviceConfiguration.
Definition: xsdeviceconfiguration.c:218
XsMtDeviceConfiguration::m_reserved
uint8_t m_reserved[8]
Reserved space.
Definition: xsdeviceconfiguration.h:105
XsMasterDeviceConfiguration::m_reserved1
uint8_t m_reserved1[8]
Reserved space.
Definition: xsdeviceconfiguration.h:123
XsDeviceConfiguration::XsDeviceConfiguration_copy
void XsDeviceConfiguration_copy(XsDeviceConfiguration *copy, XsDeviceConfiguration const *src)
Copy the XsDeviceConfiguration to copy.
Definition: xsdeviceconfiguration.c:137
XDA_DLL_API
#define XDA_DLL_API
Definition: xscontrollerconfig.h:161
XsDeviceConfiguration::XsDeviceConfiguration_construct
void XsDeviceConfiguration_construct(XsDeviceConfiguration *thisPtr)
Initializes the XsDeviceConfiguration object.
Definition: xsdeviceconfiguration.c:82
XsMasterDeviceConfiguration
Device information for the main device in an XsDeviceConfiguration.
Definition: xsdeviceconfiguration.h:118
XsMtDeviceConfiguration::m_filterMinor
uint8_t m_filterMinor
The filter minor version.
Definition: xsdeviceconfiguration.h:112
XsMasterDeviceConfiguration::m_time
uint8_t m_time[8]
The time.
Definition: xsdeviceconfiguration.h:125
xsbusid.h
XsMtDeviceConfiguration::m_filterMajor
uint8_t m_filterMajor
The filter major version.
Definition: xsdeviceconfiguration.h:111
XsMasterDeviceConfiguration::m_masterDeviceId
uint64_t m_masterDeviceId
The master device ID.
Definition: xsdeviceconfiguration.h:120
XsSize
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:74
XsMessage
Structure for storing a single message.
Definition: xsmessage.h:202
XsMtDeviceConfiguration::m_fwRevMajor
uint8_t m_fwRevMajor
The major version of the firmware.
Definition: xsdeviceconfiguration.h:107
XsDeviceConfiguration::m_masterInfo
XsMasterDeviceConfiguration m_masterInfo
The master info.
Definition: xsdeviceconfiguration.h:350
XsDeviceId
Contains an Xsens device ID and provides operations for determining the type of device.
Definition: xsdeviceid.h:192
pstdint.h
XsDeviceConfiguration::m_deviceInfo
XsMtDeviceConfiguration *const m_deviceInfo
The list of device infos.
Definition: xsdeviceconfiguration.h:352
XsMtDeviceConfiguration
Device information for MT devices in an XsDeviceConfiguration.
Definition: xsdeviceconfiguration.h:102
XsDeviceConfiguration::XsDeviceConfiguration_findDevice
XsSize XsDeviceConfiguration_findDevice(const XsDeviceConfiguration *thisPtr, const XsDeviceId *deviceId)
Returns a (naive) bus ID if deviceId is available in this configuration, 0 otherwise.
Definition: xsdeviceconfiguration.c:283
XsMasterDeviceConfiguration::m_reserved2
uint8_t m_reserved2[44]
Reserved space.
Definition: xsdeviceconfiguration.h:127
XsMasterDeviceConfiguration::m_outputSkipFactor
uint16_t m_outputSkipFactor
The output skip factor.
Definition: xsdeviceconfiguration.h:122
XsMasterDeviceConfiguration::m_date
uint8_t m_date[8]
The date.
Definition: xsdeviceconfiguration.h:124
XsDeviceConfiguration::m_numberOfDevices
const uint16_t m_numberOfDevices
The currently allocated number of devices.
Definition: xsdeviceconfiguration.h:351
XsMtDeviceConfiguration::m_fwRevMinor
uint8_t m_fwRevMinor
The minor version of the firmware.
Definition: xsdeviceconfiguration.h:108
XsDeviceConfiguration::XsDeviceConfiguration_readFromMessage
void XsDeviceConfiguration_readFromMessage(XsDeviceConfiguration *thisPtr, const XsMessage *msg)
Sets up a XsDeviceConfiguration based upon msg.
Definition: xsdeviceconfiguration.c:158
XsMasterDeviceConfiguration::m_productCode
uint8_t m_productCode[20]
The master product code.
Definition: xsdeviceconfiguration.h:126
XsDeviceConfiguration
struct XsDeviceConfiguration XsDeviceConfiguration
Definition: xsdeviceconfiguration.h:355
XsMasterDeviceConfiguration::m_samplingPeriod
uint16_t m_samplingPeriod
The sampling period.
Definition: xsdeviceconfiguration.h:121
xscontrollerconfig.h


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