xssyncsetting.c
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 #include "xssyncsetting.h"
66 #include <string.h>
67 
75 {
76  switch (thisPtr->m_line)
77  {
78  case XSL_In1:
79  case XSL_In2:
80  case XSL_Bi1In:
81  case XSL_ClockIn:
82  case XSL_CtsIn:
83  return 1;
84 
85  default:
86  return 0;
87  }
88 }
89 
93 {
94  switch (thisPtr->m_line)
95  {
96  case XSL_Out1:
97  case XSL_Out2:
98  case XSL_Bi1Out:
99  case XSL_RtsOut:
100  return 1;
101 
102  default:
103  return 0;
104  }
105 }
106 
110 {
111  XsSyncSetting tmp;
112  memcpy(&tmp, a, sizeof(XsSyncSetting));
113  memcpy(a, b, sizeof(XsSyncSetting));
114  memcpy(b, &tmp, sizeof(XsSyncSetting));
115 }
116 
122 int XsSyncSetting_compare(const struct XsSyncSetting* a, const struct XsSyncSetting* b)
123 {
124  assert(a && b);
125 
126  if (a->m_line < b->m_line)
127  return -1;
128  if (b->m_line < a->m_line)
129  return 1;
130  if (a->m_function < b->m_function)
131  return -1;
132  if (b->m_function < a->m_function)
133  return 1;
134  if (a->m_polarity < b->m_polarity)
135  return -1;
136  if (b->m_polarity < a->m_polarity)
137  return 1;
138  if (XsSyncSetting_isOutput(a))
139  {
140  // only relevant for output triggers, ignored for inputs since inputs always trigger on an edge
141  if (a->m_pulseWidth < b->m_pulseWidth)
142  return -1;
143  if (b->m_pulseWidth < a->m_pulseWidth)
144  return 1;
145  }
146  if (a->m_offset < b->m_offset)
147  return -1;
148  if (b->m_offset < a->m_offset)
149  return 1;
150  if (a->m_skipFirst < b->m_skipFirst)
151  return -1;
152  if (b->m_skipFirst < a->m_skipFirst)
153  return 1;
154  if (a->m_skipFactor < b->m_skipFactor)
155  return -1;
156  if (b->m_skipFactor < a->m_skipFactor)
157  return 1;
159  {
160  if (a->m_clockPeriod < b->m_clockPeriod)
161  return -1;
162  if (b->m_clockPeriod < a->m_clockPeriod)
163  return 1;
164  }
165  if (a->m_triggerOnce < b->m_triggerOnce)
166  return -1;
167  if (b->m_triggerOnce < a->m_triggerOnce)
168  return 1;
169 
170  return 0;
171 }
172 
XsSyncSetting::m_skipFirst
uint16_t m_skipFirst
Definition: xssyncsetting.h:102
XSL_In2
@ XSL_In2
Sync In 2.
Definition: xssyncline.h:78
XSL_In1
@ XSL_In1
Sync In 1.
Definition: xssyncline.h:77
XsSyncSetting::m_function
XsSyncFunction m_function
Definition: xssyncsetting.h:98
XSF_ClockBiasEstimation
@ XSF_ClockBiasEstimation
Do a clock bias estimation on trigger.
Definition: xssyncfunction.h:87
XsSyncSetting::m_polarity
XsSyncPolarity m_polarity
Definition: xssyncsetting.h:99
XsSyncSetting::m_pulseWidth
uint32_t m_pulseWidth
Definition: xssyncsetting.h:100
XsSyncSetting_swap
void XsSyncSetting_swap(XsSyncSetting *a, XsSyncSetting *b)
Swap the contents of a with b.
Definition: xssyncsetting.c:109
XSL_CtsIn
@ XSL_CtsIn
RS232 CTS sync in.
Definition: xssyncline.h:82
XsSyncSetting_compare
int XsSyncSetting_compare(const struct XsSyncSetting *a, const struct XsSyncSetting *b)
Compares a with b.
Definition: xssyncsetting.c:122
XSL_Bi1Out
@ XSL_Bi1Out
Bidirectional Sync 1 Out.
Definition: xssyncline.h:91
XsSyncSetting
A structure for storing all xsens sync settings.
Definition: xssyncsetting.h:95
XsSyncSetting::m_triggerOnce
uint8_t m_triggerOnce
Definition: xssyncsetting.h:105
XsSyncSetting::m_line
XsSyncLine m_line
Definition: xssyncsetting.h:97
XSL_Bi1In
@ XSL_Bi1In
Bidirectional Sync 1 In.
Definition: xssyncline.h:80
XSL_ClockIn
@ XSL_ClockIn
Clock synchronisation input.
Definition: xssyncline.h:81
XSL_RtsOut
@ XSL_RtsOut
RS232 RTS sync out.
Definition: xssyncline.h:92
XsSyncSetting_isInput
int XsSyncSetting_isInput(const XsSyncSetting *thisPtr)
Returns whether the selected line is configured as an input line.
Definition: xssyncsetting.c:74
XsSyncSetting_isOutput
int XsSyncSetting_isOutput(const XsSyncSetting *thisPtr)
Returns whether the selected line is configured as an output line.
Definition: xssyncsetting.c:92
XSL_Out2
@ XSL_Out2
Sync Out 2.
Definition: xssyncline.h:90
XsSyncSetting::m_offset
int32_t m_offset
Definition: xssyncsetting.h:101
xssyncsetting.h
XSL_Out1
@ XSL_Out1
Sync Out 1.
Definition: xssyncline.h:89
XsSyncSetting::m_skipFactor
uint16_t m_skipFactor
Definition: xssyncsetting.h:103
XsSyncSetting::m_clockPeriod
uint16_t m_clockPeriod
Definition: xssyncsetting.h:104


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