FieldParameter.cpp
Go to the documentation of this file.
1 //
2 // FieldParameter.cpp
3 //
4 // Created on: 30.08.2011
5 // Author: wahnfla
6 //
7 
8 #include "FieldParameter.hpp"
9 #include "../tools/errorhandler.hpp" // for print...
10 //#include "StringToolbox.hpp"
11 
12 namespace datatypes
13 {
14 
16 {
18 
20  m_enableLayerFilter = false;
21  m_field = NULL;
22  m_fieldNumber = 0; // 0 = invalid
23  m_versionNumber = 1; // Default is v1
24 }
25 
27 {
28 }
29 
31 {
32  UINT32 length = sizeof(*this)+
33  m_fieldName.length() +
34  m_comment.length();
35  if (m_field != NULL)
36  {
37  length += m_field->getUsedMemory();
38  }
39  return length;
40 }
41 
42 //
43 // Returns true if the Field Number is not 0.
44 //
45 const bool FieldParameter::isValid() const
46 {
47  if ((m_fieldNumber == 0) || (m_field == NULL))
48  {
49  // Invalid
50  return false;
51  }
52 
53  return true;
54 }
55 
56 
58 {
59  return m_angleScaleFactor;
60 }
61 
63 {
64  return m_angleScaleOffset;
65 }
66 
68 {
69  return m_distScaleFactor;
70 }
71 
73 {
74  return m_distScaleOffset;
75 }
76 
78 {
79  return m_field;
80 }
81 
83 {
84  return m_fieldTypeIntern;
85 }
86 
87 //
88 // Returns the internal field type as a readable string.
89 //
91 {
92  switch (m_fieldTypeIntern)
93  {
95  return "Rectangle";
97  return "Segmented";
99  return "Radial (not supported)";
101  return "Dynamic (not supported)";
102  default:
103  return "(unknown)";
104  }
105 
106  return "(unknown)";
107 }
108 
109 
111 {
112  this->m_angleScaleFactor = angleScaleFactor;
113 }
114 
116 {
117  this->m_angleScaleOffset = angleScaleOffset;
118 }
119 
120 void FieldParameter::setDistScaleFactor(double distScaleFactor)
121 {
122  this->m_distScaleFactor = distScaleFactor;
123 }
124 
125 void FieldParameter::setDistScaleOffset(double distScaleOffset)
126 {
127  this->m_distScaleOffset = distScaleOffset;
128 }
129 
131 {
132  this->m_field = field;
133 }
134 
136 {
137  this->m_fieldNumber = fieldNumber;
138 }
139 
140 //
141 // Sets the internal field type for the LD-MRS
142 //
143 // Taken from SRTSys.h:
144 // #define FieldParam_t_FieldHdr_eType_FD_RADIAL 0
145 // #define FieldParam_t_FieldHdr_eType_FD_RECTANGLE 1
146 // #define FieldParam_t_FieldHdr_eType_FD_SEGMENTATED 2
147 // #define FieldParam_t_FieldHdr_eType_FD_DYNAMIC 3
148 //
150 {
151  this->m_fieldTypeIntern = fieldTypeIntern;
152 }
153 
154 //
155 // Sets the internal field type for the LD-MRS
156 //
157 // Taken from SRTSys.h:
158 // #define FieldParam_t_FieldHdr_eType_FD_RADIAL 0
159 // #define FieldParam_t_FieldHdr_eType_FD_RECTANGLE 1
160 // #define FieldParam_t_FieldHdr_eType_FD_SEGMENTATED 2
161 // #define FieldParam_t_FieldHdr_eType_FD_DYNAMIC 3
162 //
164 {
165  this->m_fieldTypeIntern = (FieldTypeIntern)fieldTypeIntern;
166 }
167 
168 
169 const std::string& FieldParameter::getComment() const
170 {
171  return m_comment;
172 }
173 
174 const std::string& FieldParameter::getFieldName() const
175 {
176  return m_fieldName;
177 }
178 
179 //
180 // Set an additional text comment. The comment can be up to 128 characters.
181 //
182 void FieldParameter::setComment(const std::string& comment)
183 {
184  m_comment = comment;
185  if (m_comment.length() > 128)
186  {
187  m_comment = m_comment.substr(0, 128);
188  }
189 }
190 
191 //
192 // Set the name of the field. The name can be up to 32 characters.
193 //
194 void FieldParameter::setFieldName(const std::string& fieldName)
195 {
196  this->m_fieldName = fieldName;
197  if (m_fieldName.length() > 32)
198  {
199  m_fieldName = m_fieldName.substr(0, 32);
200  }
201 
202 }
203 
205 {
206  return m_versionNumber;
207 }
208 
210 {
211  this->m_versionNumber = versionNumber;
212 }
213 
214 
216 {
218 }
219 
221 {
222  this->m_lastKnownInfringementState = m_lastKnownInfringementState;
223 }
224 
226 {
227  return m_layerFilterBitmap;
228 }
229 
231 {
232  return m_enableLayerFilter;
233 }
234 
236 {
237  this->m_enableLayerFilter = m_enableLayerFilter;
238 }
239 
241 {
242  this->m_layerFilterBitmap = m_layerFilterBitmap;
243 }
244 
245 //
246 // Returns the type of the field.
247 // The internal type and the added field should match!
248 //
250 {
251  if (m_field == NULL)
252  {
253  // There is no associated field data structure, so we do not have a field type.
255  }
256  else
257  {
258  // Check if the internal datatype and the field type match
261  {
263  }
266  {
268  }
269 
270  // No match!
271  printError("FieldParameter::getFieldType(): The internal field type and the associated field structure do no match, returning UNDEFINED!");
272  }
273 
275 }
276 
278 {
279  return m_fieldNumber;
280 }
281 
282 
283 } // namespace datatypes
double getDistScaleFactor() const
void printError(std::string message)
CaseResult getLastKnownInfringementState() const
void setLayerFilterBitmap(UINT8 layerFilterBitmap)
bool isLayerFilterEnabled() const
FieldDescription * m_field
const FieldDescription::FieldType getFieldType() const
uint16_t UINT16
virtual const UINT32 getUsedMemory() const =0
FieldType getFieldType() const
void setDistScaleFactor(double distScaleFactor)
void setAngleScaleFactor(UINT32 angleScaleFactor)
uint32_t UINT32
const UINT16 getFieldNumber() const
void setAngleScaleOffset(INT32 angleScaleOffset)
const std::string & getFieldName() const
void setField(FieldDescription *field)
virtual const UINT32 getUsedMemory() const
void setLastKnownInfringementState(CaseResult lastKnownInfringementState)
std::string getFieldTypeInternAsString() const
INT32 m_angleScaleOffset
internal parameter: sensor specific
FieldTypeIntern getFieldTypeIntern() const
void setDistScaleOffset(double distScaleOffset)
INT32 getAngleScaleOffset() const
UINT32 m_angleScaleFactor
internal parameter: sensor specific
int32_t INT32
const bool isValid() const
void setFieldTypeIntern(UINT8 fieldTypeIntern)
const std::string & getComment() const
double m_distScaleFactor
conversion factor
void setComment(const std::string &comment)
double getDistScaleOffset() const
UINT32 getAngleScaleFactor() const
FieldDescription * getField() const
FieldTypeIntern m_fieldTypeIntern
internal parameter: sensor specific
void setVersionNumber(UINT8 m_versionNumber)
UINT8 getLayerFilterBitmap() const
void setFieldNumber(UINT16 m_fieldNumber)
void setEnableLayerFilter(bool enableLayerFilter)
void setFieldName(const std::string &fieldName)
uint8_t UINT8


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Sat Jun 8 2019 17:57:33