FieldParameter.cpp
Go to the documentation of this file.
00001 //
00002 // FieldParameter.cpp
00003 //
00004 //  Created on: 30.08.2011
00005 //      Author: wahnfla
00006 //
00007 
00008 #include "FieldParameter.hpp"
00009 #include "../tools/errorhandler.hpp"    // for print...
00010 //#include "StringToolbox.hpp"
00011 
00012 namespace datatypes
00013 {
00014 
00015 FieldParameter::FieldParameter()
00016 {
00017         m_datatype = Datatype_FieldParameter;
00018         
00019         m_layerFilterBitmap = 0;
00020         m_enableLayerFilter = false;
00021         m_field = NULL;
00022         m_fieldNumber = 0;              // 0 = invalid
00023         m_versionNumber = 1;    // Default is v1
00024 }
00025 
00026 FieldParameter::~FieldParameter()
00027 {
00028 }
00029 
00030 const UINT32 FieldParameter::getUsedMemory() const
00031 {
00032         UINT32 length = sizeof(*this)+
00033                                         m_fieldName.length() +
00034                                         m_comment.length();
00035         if (m_field != NULL)
00036         {
00037                 length += m_field->getUsedMemory();
00038         }
00039         return length;
00040 }
00041 
00042 //
00043 // Returns true if the Field Number is not 0. 
00044 //
00045 const bool FieldParameter::isValid() const
00046 {
00047         if ((m_fieldNumber == 0) || (m_field == NULL))
00048         {
00049                 // Invalid
00050                 return false;
00051         }
00052         
00053         return true;
00054 }
00055 
00056 
00057 UINT32 FieldParameter::getAngleScaleFactor() const
00058 {
00059         return m_angleScaleFactor;
00060 }
00061 
00062 INT32 FieldParameter::getAngleScaleOffset() const
00063 {
00064         return m_angleScaleOffset;
00065 }
00066 
00067 double FieldParameter::getDistScaleFactor() const
00068 {
00069         return m_distScaleFactor;
00070 }
00071 
00072 double FieldParameter::getDistScaleOffset() const
00073 {
00074         return m_distScaleOffset;
00075 }
00076 
00077 FieldDescription* FieldParameter::getField() const
00078 {
00079         return m_field;
00080 }
00081 
00082 FieldParameter::FieldTypeIntern FieldParameter::getFieldTypeIntern() const
00083 {
00084         return m_fieldTypeIntern;
00085 }
00086 
00087 //
00088 // Returns the internal field type as a readable string.
00089 //
00090 std::string FieldParameter::getFieldTypeInternAsString() const
00091 {
00092         switch (m_fieldTypeIntern)
00093         {
00094                 case FieldTypeIntern_RECTANGLE:
00095                         return "Rectangle";
00096                 case FieldTypeIntern_SEGMENTED:
00097                         return "Segmented";
00098                 case FieldTypeIntern_RADIAL:
00099                         return "Radial (not supported)";
00100                 case FieldTypeintern_DYNAMIC:
00101                         return "Dynamic (not supported)";
00102                 default:
00103                         return "(unknown)";
00104         }
00105         
00106         return "(unknown)";
00107 }
00108 
00109 
00110 void FieldParameter::setAngleScaleFactor(UINT32 angleScaleFactor)
00111 {
00112         this->m_angleScaleFactor = angleScaleFactor;
00113 }
00114 
00115 void FieldParameter::setAngleScaleOffset(INT32 angleScaleOffset)
00116 {
00117         this->m_angleScaleOffset = angleScaleOffset;
00118 }
00119 
00120 void FieldParameter::setDistScaleFactor(double distScaleFactor)
00121 {
00122         this->m_distScaleFactor = distScaleFactor;
00123 }
00124 
00125 void FieldParameter::setDistScaleOffset(double distScaleOffset)
00126 {
00127         this->m_distScaleOffset = distScaleOffset;
00128 }
00129 
00130 void FieldParameter::setField(FieldDescription* field)
00131 {
00132         this->m_field = field;
00133 }
00134 
00135 void FieldParameter::setFieldNumber(UINT16 fieldNumber)
00136 {
00137         this->m_fieldNumber = fieldNumber;
00138 }
00139 
00140 //
00141 // Sets the internal field type for the LD-MRS
00142 //
00143 // Taken from SRTSys.h:
00144 // #define FieldParam_t_FieldHdr_eType_FD_RADIAL       0     
00145 // #define FieldParam_t_FieldHdr_eType_FD_RECTANGLE    1     
00146 // #define FieldParam_t_FieldHdr_eType_FD_SEGMENTATED  2     
00147 // #define FieldParam_t_FieldHdr_eType_FD_DYNAMIC      3
00148 //
00149 void FieldParameter::setFieldTypeIntern(FieldTypeIntern fieldTypeIntern)
00150 {
00151         this->m_fieldTypeIntern = fieldTypeIntern;
00152 }
00153 
00154 //
00155 // Sets the internal field type for the LD-MRS
00156 //
00157 // Taken from SRTSys.h:
00158 // #define FieldParam_t_FieldHdr_eType_FD_RADIAL       0     
00159 // #define FieldParam_t_FieldHdr_eType_FD_RECTANGLE    1     
00160 // #define FieldParam_t_FieldHdr_eType_FD_SEGMENTATED  2     
00161 // #define FieldParam_t_FieldHdr_eType_FD_DYNAMIC      3
00162 //
00163 void FieldParameter::setFieldTypeIntern(UINT8 fieldTypeIntern)
00164 {
00165         this->m_fieldTypeIntern = (FieldTypeIntern)fieldTypeIntern;
00166 }
00167 
00168 
00169 const std::string& FieldParameter::getComment() const
00170 {
00171         return m_comment;
00172 }
00173 
00174 const std::string& FieldParameter::getFieldName() const
00175 {
00176         return m_fieldName;
00177 }
00178 
00179 //
00180 // Set an additional text comment. The comment can be up to 128 characters.
00181 //
00182 void FieldParameter::setComment(const std::string& comment)
00183 {
00184         m_comment = comment;
00185         if (m_comment.length() > 128)
00186         {
00187                 m_comment = m_comment.substr(0, 128);
00188         }
00189 }
00190 
00191 //
00192 // Set the name of the field. The name can be up to 32 characters.
00193 //
00194 void FieldParameter::setFieldName(const std::string& fieldName)
00195 {
00196         this->m_fieldName = fieldName;
00197         if (m_fieldName.length() > 32)
00198         {
00199                 m_fieldName = m_fieldName.substr(0, 32);
00200         }
00201 
00202 }
00203 
00204 UINT8 FieldParameter::getVersionNumber() const
00205 {
00206         return m_versionNumber;
00207 }
00208 
00209 void FieldParameter::setVersionNumber(UINT8 versionNumber)
00210 {
00211         this->m_versionNumber = versionNumber;
00212 }
00213 
00214 
00215 FieldParameter::CaseResult FieldParameter::getLastKnownInfringementState() const
00216 {
00217         return m_lastKnownInfringementState;
00218 }
00219 
00220 void FieldParameter::setLastKnownInfringementState(FieldParameter::CaseResult m_lastKnownInfringementState)
00221 {
00222         this->m_lastKnownInfringementState = m_lastKnownInfringementState;
00223 }
00224 
00225 UINT8 FieldParameter::getLayerFilterBitmap() const
00226 {
00227         return m_layerFilterBitmap;
00228 }
00229 
00230 bool FieldParameter::isLayerFilterEnabled() const
00231 {
00232         return m_enableLayerFilter;
00233 }
00234 
00235 void FieldParameter::setEnableLayerFilter(bool m_enableLayerFilter)
00236 {
00237         this->m_enableLayerFilter = m_enableLayerFilter;
00238 }
00239 
00240 void FieldParameter::setLayerFilterBitmap(UINT8 m_layerFilterBitmap)
00241 {
00242         this->m_layerFilterBitmap = m_layerFilterBitmap;
00243 }
00244 
00245 //
00246 // Returns the type of the field.
00247 // The internal type and the added field should match!
00248 //
00249 const FieldDescription::FieldType FieldParameter::getFieldType() const
00250 {
00251         if (m_field == NULL)
00252         {
00253                 // There is no associated field data structure, so we do not have a field type.
00254                 return FieldDescription::Undefined;
00255         }
00256         else
00257         {
00258                 // Check if the internal datatype and the field type match
00259                 if ((m_field->getFieldType() == datatypes::FieldDescription::Rectangle) &&
00260                         (getFieldTypeIntern() == FieldTypeIntern_RECTANGLE))
00261                 {
00262                         return FieldDescription::Rectangle;
00263                 }
00264                 if ((m_field->getFieldType() == datatypes::FieldDescription::Segmented) &&
00265                         (getFieldTypeIntern() == FieldTypeIntern_SEGMENTED))
00266                 {
00267                         return FieldDescription::Segmented;
00268                 }
00269                 
00270                 // No match!
00271                 printError("FieldParameter::getFieldType(): The internal field type and the associated field structure do no match, returning UNDEFINED!");
00272         }
00273         
00274         return FieldDescription::Undefined;
00275 }
00276 
00277 const UINT16 FieldParameter::getFieldNumber() const
00278 {
00279         return m_fieldNumber;
00280 }
00281 
00282 
00283 } // namespace datatypes


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Wed Jun 14 2017 04:04:50