Bmag incl gps rettelse

Dependencies:   mbed WDT MODSERIAL BME280

Committer:
MAA
Date:
Mon May 15 12:46:50 2017 +0000
Revision:
22:9f5955f051f5
Parent:
21:325cb82f1838
Child:
23:2e914b705b99
Changes to display usage in main.cpp;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MAA 0:b3313c5ffca3 1 #include "SPS.h"
MAA 0:b3313c5ffca3 2
MAA 19:5d25cffef662 3 //! SPS, class default constructor
MAA 19:5d25cffef662 4 /*!
MAA 19:5d25cffef662 5 Initializing different class member values, creating a header string.
MAA 19:5d25cffef662 6 */
MAA 0:b3313c5ffca3 7 SPS::SPS(){
MAA 2:39c4a85dc2a4 8
MAA 6:6d1683c8b26b 9 fileNameString = "";
MAA 2:39c4a85dc2a4 10 currentString = "";
MAA 2:39c4a85dc2a4 11 currentErrString = "";
MAA 6:6d1683c8b26b 12 lastString = "";
MAA 22:9f5955f051f5 13 headerString = "/tag identifier_id group_id date time zzz | encoding source_id interpreter_id data_line_version encoding source_firmware_version interpreter_firmware_version | barcode latitude longitude gpsFixFlag batteryvoltage mag_time mag_nt mag_sq checksum";
MAA 5:11782a2008c2 14 crc_tab16_init = 0;
MAA 5:11782a2008c2 15 errStatus = true;
MAA 2:39c4a85dc2a4 16
MAA 2:39c4a85dc2a4 17 };
MAA 2:39c4a85dc2a4 18
MAA 19:5d25cffef662 19
MAA 19:5d25cffef662 20 //! UpdateCurrentString, sps string creation method, taking data and info as parameters.
MAA 19:5d25cffef662 21 /*!
MAA 19:5d25cffef662 22
MAA 19:5d25cffef662 23 Generates an sps string containing everything needed in a BMAG sps string including crc, brackets etc.
MAA 19:5d25cffef662 24
MAA 19:5d25cffef662 25 \param tag: string containing the tag for the sps logging unit eg. "BMAG"
MAA 19:5d25cffef662 26 \param identifier_id: string containing the identifier id of the unit.
MAA 19:5d25cffef662 27 \param group_id: string containing the group id of the unit.
MAA 19:5d25cffef662 28 \param date: string containing the date in the format "YYYY/MM/DD"
MAA 19:5d25cffef662 29 \param time: string containing the current time in format "HH:MM:SS.FFF"
MAA 19:5d25cffef662 30 \param ZZZ: string containing "ZZZ" :)
MAA 19:5d25cffef662 31 \param s1: string containing s1 as described in the *.sps documentation
MAA 19:5d25cffef662 32 \param source_id: string containing the source id of the unit eg. "0000"
MAA 19:5d25cffef662 33 \param interpreter_id: string containing the interpreter id of the unit eg. "00"
MAA 19:5d25cffef662 34 \param data_line_version: string containing data line version as described in the *.sps documentation, eg. "01"
MAA 19:5d25cffef662 35 \param source_firmware_version: string containing the firmware version of the unit eg. "1.2"
MAA 19:5d25cffef662 36 \param barcode: string containing the barcode of the unit, eg. "12345"
MAA 19:5d25cffef662 37 \param latitude: string containing the latitude of the unit in decimal degrees. For further info read the *.sps documentation.
MAA 19:5d25cffef662 38 \param longitude: string containing the longitude of the unit in decimal degrees. For further info read the *.sps documentation.
MAA 19:5d25cffef662 39 \param gpsFixFlag: bool containing the gps fix status, 1 if gps fix is present, else 0.
MAA 19:5d25cffef662 40 \param batteryvoltage: string containing the battery voltage of the units battery pack, eg. "14.2"
MAA 19:5d25cffef662 41 \param mag_time: string containing the last timestamp received from GSM-19 device eg. "000048.0"
MAA 19:5d25cffef662 42 \param mag_nt: string containing the last mag measurement in nT eg. "036418.77"
MAA 19:5d25cffef662 43 \param mag_sq: string containing info about the measurement quality of the last mag measurement eg. "99"
MAA 19:5d25cffef662 44
MAA 19:5d25cffef662 45 */
MAA 8:d6287c33b54a 46 void SPS::UpdateCurrentString(string tag, string identifier_id, string group_id, string date, string time, string ZZZ,string s1, string source_id, string interpreter_id, string data_line_version, string source_firmware_version, string interpreter_firmware_version, string barcode, string latitude, string longitude, bool gpsFixFlag, string batteryvoltage, string mag_time, string mag_nt, string mag_sq, Serial * dbg){
MAA 2:39c4a85dc2a4 47
MAA 21:325cb82f1838 48 this->currentString = "";
MAA 21:325cb82f1838 49 this->currentString.resize(256);
MAA 21:325cb82f1838 50
MAA 21:325cb82f1838 51 int strLength = 0;
MAA 5:11782a2008c2 52 char checkSum[5];
MAA 5:11782a2008c2 53 memset(checkSum,'\0',5);
MAA 5:11782a2008c2 54 unsigned short chkSum = 0;
MAA 0:b3313c5ffca3 55
MAA 5:11782a2008c2 56 addToCurrentString(LINESTART);
MAA 5:11782a2008c2 57 addToCurrentString(tag);
MAA 5:11782a2008c2 58 addToCurrentString(SPACE);
MAA 5:11782a2008c2 59 addToCurrentString(identifier_id);
MAA 5:11782a2008c2 60 addToCurrentString(SPACE);
MAA 5:11782a2008c2 61 addToCurrentString(group_id);
MAA 5:11782a2008c2 62 addToCurrentString(SPACE);
MAA 5:11782a2008c2 63 addToCurrentString(date);
MAA 5:11782a2008c2 64 addToCurrentString(SPACE);
MAA 5:11782a2008c2 65 addToCurrentString(time);
MAA 5:11782a2008c2 66 addToCurrentString(SPACE);
MAA 5:11782a2008c2 67 addToCurrentString("ZZZ");
MAA 5:11782a2008c2 68 addToCurrentString(SPACE);
MAA 5:11782a2008c2 69 addToCurrentString(HEADEREND);
MAA 5:11782a2008c2 70 addToCurrentString(SPACE);
MAA 5:11782a2008c2 71 addToCurrentString(s1);
MAA 5:11782a2008c2 72 addToCurrentString(SPACE);
MAA 5:11782a2008c2 73 addToCurrentString(source_id);
MAA 5:11782a2008c2 74 addToCurrentString(SPACE);
MAA 5:11782a2008c2 75 addToCurrentString(interpreter_id);
MAA 5:11782a2008c2 76 addToCurrentString(SPACE);
MAA 5:11782a2008c2 77 addToCurrentString(data_line_version);
MAA 5:11782a2008c2 78 addToCurrentString(SPACE);
MAA 5:11782a2008c2 79 addToCurrentString(source_firmware_version);
MAA 5:11782a2008c2 80 addToCurrentString(SPACE);
MAA 5:11782a2008c2 81 addToCurrentString(interpreter_firmware_version);
MAA 5:11782a2008c2 82 addToCurrentString(SPACE);
MAA 5:11782a2008c2 83 addToCurrentString(HEADEREND);
MAA 5:11782a2008c2 84 addToCurrentString(SPACE);
MAA 8:d6287c33b54a 85 addToCurrentString(barcode);
MAA 8:d6287c33b54a 86 addToCurrentString(SPACE);
MAA 5:11782a2008c2 87 addToCurrentString(latitude);
MAA 5:11782a2008c2 88 addToCurrentString(SPACE);
MAA 5:11782a2008c2 89 addToCurrentString(longitude);
MAA 5:11782a2008c2 90 addToCurrentString(SPACE);
MAA 5:11782a2008c2 91
MAA 5:11782a2008c2 92 if(gpsFixFlag){
MAA 5:11782a2008c2 93 addToCurrentString('1');
MAA 5:11782a2008c2 94 }
MAA 5:11782a2008c2 95 if(!gpsFixFlag){
MAA 5:11782a2008c2 96 addToCurrentString('0');
MAA 5:11782a2008c2 97 }
MAA 5:11782a2008c2 98
MAA 5:11782a2008c2 99 addToCurrentString(SPACE);
MAA 8:d6287c33b54a 100 addToCurrentString(batteryvoltage);
MAA 8:d6287c33b54a 101 addToCurrentString(SPACE);
MAA 5:11782a2008c2 102 addToCurrentString(mag_time);
MAA 5:11782a2008c2 103 addToCurrentString(SPACE);
MAA 5:11782a2008c2 104 addToCurrentString(mag_nt);
MAA 5:11782a2008c2 105 addToCurrentString(SPACE);
MAA 5:11782a2008c2 106 addToCurrentString(mag_sq);
MAA 5:11782a2008c2 107
MAA 21:325cb82f1838 108
MAA 21:325cb82f1838 109 strLength = strlen(this->currentString.c_str());
MAA 21:325cb82f1838 110
MAA 2:39c4a85dc2a4 111 //calculate checksum
MAA 21:325cb82f1838 112 for(int i = 0; i < strLength; i++){
MAA 21:325cb82f1838 113 if(this->currentString[i] != '>'){
MAA 5:11782a2008c2 114
MAA 21:325cb82f1838 115 chkSum = update_crc_16(chkSum, this->currentString[i]);
MAA 5:11782a2008c2 116
MAA 5:11782a2008c2 117 }
MAA 5:11782a2008c2 118 }
MAA 5:11782a2008c2 119
MAA 6:6d1683c8b26b 120 sprintf(checkSum, "%04X", chkSum);
MAA 21:325cb82f1838 121
MAA 2:39c4a85dc2a4 122 //append rest of string
MAA 5:11782a2008c2 123 addToCurrentString(SPACE);
MAA 5:11782a2008c2 124 addToCurrentString(checkSum);
MAA 8:d6287c33b54a 125 addToCurrentString(LINESTOP);
MAA 2:39c4a85dc2a4 126 };
MAA 2:39c4a85dc2a4 127
MAA 19:5d25cffef662 128
MAA 19:5d25cffef662 129
MAA 19:5d25cffef662 130 //! UpdateCurrentErrString, sps ERR string creation method, taking data and info as parameters.
MAA 19:5d25cffef662 131 /*!
MAA 19:5d25cffef662 132
MAA 19:5d25cffef662 133 Generates the current sps ERR string containing everything needed in a BMAG sps string including crc, brackets etc.
MAA 19:5d25cffef662 134
MAA 19:5d25cffef662 135 \param tag: string containing the tag for the sps logging unit eg. "BMAG"
MAA 19:5d25cffef662 136 \param identifier_id: string containing the identifier id of the unit.
MAA 19:5d25cffef662 137 \param group_id: string containing the group id of the unit.
MAA 19:5d25cffef662 138 \param date: string containing the date in the format "YYYY/MM/DD"
MAA 19:5d25cffef662 139 \param time: string containing the current time in format "HH:MM:SS.FFF"
MAA 19:5d25cffef662 140 \param ZZZ: string containing "ZZZ" :)
MAA 19:5d25cffef662 141 \param s1: string containing s1 as described in the *.sps documentation
MAA 19:5d25cffef662 142 \param source_id: string containing the source id of the unit eg. "0000"
MAA 19:5d25cffef662 143 \param interpreter_id: string containing the interpreter id of the unit eg. "00"
MAA 19:5d25cffef662 144 \param data_line_version: string containing data line version as described in the *.sps documentation, eg. "01"
MAA 19:5d25cffef662 145 \param source_firmware_version: string containing the firmware version of the unit eg. "1.2"
MAA 19:5d25cffef662 146 \param barcode: string containing the barcode of the unit, eg. "12345"
MAA 19:5d25cffef662 147 \param latitude: string containing the latitude of the unit in decimal degrees. For further info read the *.sps documentation.
MAA 19:5d25cffef662 148 \param longitude: string containing the longitude of the unit in decimal degrees. For further info read the *.sps documentation.
MAA 19:5d25cffef662 149 \param gpsFixFlag: bool containing the gps fix status, 1 if gps fix is present, else 0.
MAA 19:5d25cffef662 150 \param mag_time: string containing the last timestamp received from GSM-19 device eg. "000048.0"
MAA 19:5d25cffef662 151 \param mag_nt: string containing the last mag measurement in nT eg. "036418.77"
MAA 19:5d25cffef662 152 \param mag_sq: string containing info about the measurement quality of the last mag measurement eg. "99"
MAA 19:5d25cffef662 153
MAA 19:5d25cffef662 154 */
MAA 7:872984a67d5b 155 void SPS::UpdateCurrentErrString(string tag, string identifier_id, string group_id, string date, string time, string ZZZ,string s1, string source_id, string interpreter_id, string data_line_version, string source_firmware_version, string interpreter_firmware_version, string latitude, string longitude, bool gpsFixFlag, string mag_time, string mag_nt, string mag_sq, Serial * dbg){
MAA 7:872984a67d5b 156
MAA 21:325cb82f1838 157 this->currentErrString = "";
MAA 21:325cb82f1838 158 this->currentErrString.resize(256);
MAA 7:872984a67d5b 159 char checkSum[5];
MAA 7:872984a67d5b 160 memset(checkSum,'\0',5);
MAA 7:872984a67d5b 161 unsigned short chkSum = 0;
MAA 7:872984a67d5b 162
MAA 7:872984a67d5b 163 addToCurrentErrString(LINESTART);
MAA 7:872984a67d5b 164 addToCurrentErrString(tag);
MAA 7:872984a67d5b 165 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 166 addToCurrentErrString(identifier_id);
MAA 7:872984a67d5b 167 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 168 addToCurrentErrString(group_id);
MAA 7:872984a67d5b 169 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 170 addToCurrentErrString(date);
MAA 7:872984a67d5b 171 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 172 addToCurrentErrString(time);
MAA 7:872984a67d5b 173 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 174 addToCurrentErrString("ZZZ");
MAA 7:872984a67d5b 175 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 176 addToCurrentErrString(HEADEREND);
MAA 7:872984a67d5b 177 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 178 addToCurrentErrString(s1);
MAA 7:872984a67d5b 179 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 180 addToCurrentErrString(source_id);
MAA 7:872984a67d5b 181 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 182 addToCurrentErrString(interpreter_id);
MAA 7:872984a67d5b 183 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 184 addToCurrentErrString(data_line_version);
MAA 7:872984a67d5b 185 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 186 addToCurrentErrString(source_firmware_version);
MAA 7:872984a67d5b 187 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 188 addToCurrentErrString(interpreter_firmware_version);
MAA 7:872984a67d5b 189 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 190 addToCurrentErrString(HEADEREND);
MAA 7:872984a67d5b 191 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 192 addToCurrentErrString("BMAG");
MAA 7:872984a67d5b 193 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 194 addToCurrentErrString("C02");
MAA 7:872984a67d5b 195 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 196 addToCurrentErrString("C03");
MAA 7:872984a67d5b 197
MAA 7:872984a67d5b 198 //calculate checksum
MAA 21:325cb82f1838 199 for(int i = 0; i < strlen(this->currentString.c_str()); i++){
MAA 21:325cb82f1838 200 if(this->currentString[i] != '>' || this->currentString[i] != '<'){
MAA 7:872984a67d5b 201
MAA 21:325cb82f1838 202 chkSum = update_crc_16(chkSum, this->currentErrString[i]);
MAA 7:872984a67d5b 203
MAA 7:872984a67d5b 204 }
MAA 7:872984a67d5b 205 }
MAA 21:325cb82f1838 206
MAA 7:872984a67d5b 207 sprintf(checkSum, "%04X", chkSum);
MAA 7:872984a67d5b 208
MAA 7:872984a67d5b 209 //append rest of string
MAA 7:872984a67d5b 210 addToCurrentErrString(SPACE);
MAA 7:872984a67d5b 211 addToCurrentErrString(checkSum);
MAA 8:d6287c33b54a 212 addToCurrentErrString(LINESTOP);
MAA 7:872984a67d5b 213 };
MAA 7:872984a67d5b 214
MAA 19:5d25cffef662 215 //! init_crc16_tab, creates a crc tab.
MAA 19:5d25cffef662 216 /*!
MAA 19:5d25cffef662 217 Populates a crc array for later use
MAA 19:5d25cffef662 218 */
MAA 4:c70ef089a3fd 219 void SPS::init_crc16_tab()
MAA 4:c70ef089a3fd 220 {
MAA 4:c70ef089a3fd 221 int i, j;
MAA 4:c70ef089a3fd 222 unsigned short crc, c;
MAA 4:c70ef089a3fd 223
MAA 4:c70ef089a3fd 224 for (i = 0; i < 256; i++)
MAA 4:c70ef089a3fd 225 {
MAA 4:c70ef089a3fd 226 crc = 0;
MAA 4:c70ef089a3fd 227 c = (unsigned short) i;
MAA 4:c70ef089a3fd 228
MAA 4:c70ef089a3fd 229 for (j = 0; j < 8; j++)
MAA 4:c70ef089a3fd 230 {
MAA 4:c70ef089a3fd 231 if ((crc ^ c) & 0x0001)
MAA 4:c70ef089a3fd 232 crc = (crc >> 1) ^ P_16;
MAA 4:c70ef089a3fd 233 else
MAA 4:c70ef089a3fd 234 crc = crc >> 1;
MAA 4:c70ef089a3fd 235
MAA 4:c70ef089a3fd 236 c = c >> 1;
MAA 4:c70ef089a3fd 237 }
MAA 4:c70ef089a3fd 238 crc_tab16[i] = crc;
MAA 4:c70ef089a3fd 239 }
MAA 4:c70ef089a3fd 240 crc_tab16_init = 1;
MAA 4:c70ef089a3fd 241 };
MAA 4:c70ef089a3fd 242
MAA 4:c70ef089a3fd 243
MAA 19:5d25cffef662 244
MAA 19:5d25cffef662 245 //! update_crc_16, updates crc tab.
MAA 19:5d25cffef662 246 /*!
MAA 20:73fa202c73db 247 \param crc: the crc currently getting calculated
MAA 20:73fa202c73db 248 \param c: next character to be part of crc
MAA 19:5d25cffef662 249 \return returns crc value
MAA 19:5d25cffef662 250 */
MAA 4:c70ef089a3fd 251 unsigned short SPS::update_crc_16(unsigned short crc, char c)
MAA 4:c70ef089a3fd 252 {
MAA 4:c70ef089a3fd 253 unsigned short tmp, short_c;
MAA 4:c70ef089a3fd 254
MAA 4:c70ef089a3fd 255 short_c = 0x00ff & (unsigned short) c;
MAA 4:c70ef089a3fd 256
MAA 4:c70ef089a3fd 257 if (!crc_tab16_init)
MAA 4:c70ef089a3fd 258 init_crc16_tab();
MAA 21:325cb82f1838 259
MAA 4:c70ef089a3fd 260
MAA 4:c70ef089a3fd 261 tmp = crc ^ short_c;
MAA 4:c70ef089a3fd 262 crc = (crc >> 8) ^ crc_tab16[tmp & 0xff];
MAA 4:c70ef089a3fd 263
MAA 4:c70ef089a3fd 264 return crc;
MAA 4:c70ef089a3fd 265 };
MAA 5:11782a2008c2 266
MAA 5:11782a2008c2 267
MAA 20:73fa202c73db 268
MAA 20:73fa202c73db 269 //! getCurrentString, returns the current sps data string
MAA 20:73fa202c73db 270 /*!
MAA 20:73fa202c73db 271 \return returns current sps data string
MAA 20:73fa202c73db 272 */
MAA 5:11782a2008c2 273 string SPS::getCurrentString(void){
MAA 5:11782a2008c2 274 return this->currentString;
MAA 5:11782a2008c2 275 };
MAA 5:11782a2008c2 276
MAA 5:11782a2008c2 277
MAA 20:73fa202c73db 278 //! getErrStatus, returns the current error status flag
MAA 20:73fa202c73db 279 /*!
MAA 20:73fa202c73db 280 \return returns the current error status flag (bool)
MAA 20:73fa202c73db 281 */
MAA 5:11782a2008c2 282 bool SPS::getErrStatus(void){
MAA 5:11782a2008c2 283 return this->errStatus;
MAA 5:11782a2008c2 284 };
MAA 5:11782a2008c2 285
MAA 20:73fa202c73db 286 //! setErrStatus, sets error status flag
MAA 20:73fa202c73db 287 /*!
MAA 20:73fa202c73db 288 \param status: boolean value assigned to errorStatus
MAA 20:73fa202c73db 289 */
MAA 5:11782a2008c2 290 void SPS::setErrStatus(bool status){
MAA 5:11782a2008c2 291 this->errStatus = status;
MAA 5:11782a2008c2 292 };
MAA 5:11782a2008c2 293
MAA 20:73fa202c73db 294 //! getHeaderString, getter method, returning header string for *.sps file
MAA 20:73fa202c73db 295 /*!
MAA 20:73fa202c73db 296 \return returns the header string for the *.sps file
MAA 20:73fa202c73db 297 */
MAA 5:11782a2008c2 298 string SPS::getHeaderString(void){
MAA 5:11782a2008c2 299 return this->headerString;
MAA 5:11782a2008c2 300 };
MAA 5:11782a2008c2 301
MAA 5:11782a2008c2 302 //add data to current string
MAA 20:73fa202c73db 303 //! addToCurrentString, appends string of data to the sps string currently being manipulated.
MAA 20:73fa202c73db 304 /*!
MAA 20:73fa202c73db 305 \param data: string containing data
MAA 20:73fa202c73db 306 */
MAA 5:11782a2008c2 307 void SPS::addToCurrentString(string data){
MAA 21:325cb82f1838 308 int currentStartIndex = strlen(this->currentString.c_str());
MAA 5:11782a2008c2 309 char dataStrLen = 0;
MAA 8:d6287c33b54a 310 int index = 0;
MAA 8:d6287c33b54a 311
MAA 5:11782a2008c2 312 dataStrLen = strlen(data.c_str());
MAA 5:11782a2008c2 313
MAA 5:11782a2008c2 314 for(int i = 0; i < dataStrLen; i++){
MAA 8:d6287c33b54a 315
MAA 21:325cb82f1838 316 if((this->currentString[currentStartIndex+i] != '\r') || (this->currentString[currentStartIndex+i] != '\n')){
MAA 8:d6287c33b54a 317
MAA 21:325cb82f1838 318 this->currentString[currentStartIndex+i] = data[index];
MAA 8:d6287c33b54a 319 index += 1;
MAA 8:d6287c33b54a 320
MAA 8:d6287c33b54a 321 }
MAA 8:d6287c33b54a 322
MAA 5:11782a2008c2 323 }
MAA 5:11782a2008c2 324 }
MAA 5:11782a2008c2 325
MAA 20:73fa202c73db 326 //! addToCurrentString, appends char to the sps string currently being manipulated.
MAA 20:73fa202c73db 327 /*!
MAA 20:73fa202c73db 328 \param data: data character
MAA 20:73fa202c73db 329 */
MAA 5:11782a2008c2 330 void SPS::addToCurrentString(char data){
MAA 21:325cb82f1838 331 int currentStartIndex = strlen(this->currentString.c_str());
MAA 21:325cb82f1838 332 this->currentString[currentStartIndex] = data;
MAA 6:6d1683c8b26b 333 };
MAA 6:6d1683c8b26b 334
MAA 20:73fa202c73db 335 //! addToCurrentErrString, appends string to the sps err_string currently being manipulated.
MAA 20:73fa202c73db 336 /*!
MAA 20:73fa202c73db 337 \param data: data string
MAA 20:73fa202c73db 338 */
MAA 7:872984a67d5b 339 void SPS::addToCurrentErrString(string data){
MAA 21:325cb82f1838 340 int currentStartIndex = strlen(this->currentErrString.c_str());
MAA 7:872984a67d5b 341 char dataStrLen = 0;
MAA 7:872984a67d5b 342 dataStrLen = strlen(data.c_str());
MAA 7:872984a67d5b 343
MAA 7:872984a67d5b 344 for(int i = 0; i < dataStrLen; i++){
MAA 21:325cb82f1838 345 this->currentErrString[currentStartIndex+i] = data[i];
MAA 7:872984a67d5b 346 }
MAA 7:872984a67d5b 347
MAA 7:872984a67d5b 348 };
MAA 20:73fa202c73db 349
MAA 20:73fa202c73db 350 //! addToCurrentErrString, appends a character to the sps err_string currently being manipulated.
MAA 20:73fa202c73db 351 /*!
MAA 20:73fa202c73db 352 \param data: data char
MAA 20:73fa202c73db 353 */
MAA 7:872984a67d5b 354 void SPS::addToCurrentErrString(char data){
MAA 7:872984a67d5b 355 int currentStartIndex = strlen(currentErrString.c_str());
MAA 7:872984a67d5b 356 currentErrString[currentStartIndex] = data;
MAA 7:872984a67d5b 357
MAA 7:872984a67d5b 358 };
MAA 7:872984a67d5b 359
MAA 20:73fa202c73db 360 //! generateSpsFilename, generates a sps file name, including file postfix, using the current date as input.
MAA 20:73fa202c73db 361 /*!
MAA 20:73fa202c73db 362 \param formattedDate: Date string using a formatted date witht he format: "YYYY/MM/DD"
MAA 20:73fa202c73db 363 */
MAA 6:6d1683c8b26b 364 void SPS::generateSpsFilename(string formattedDate){
MAA 6:6d1683c8b26b 365
MAA 7:872984a67d5b 366 fileNameString.resize(25);
MAA 6:6d1683c8b26b 367
MAA 7:872984a67d5b 368 fileNameString.replace(0, 10, "/usb/BMAG_");
MAA 6:6d1683c8b26b 369
MAA 7:872984a67d5b 370 fileNameString[10] = formattedDate[0];
MAA 7:872984a67d5b 371 fileNameString[11] = formattedDate[1];
MAA 7:872984a67d5b 372 fileNameString[12] = formattedDate[2];
MAA 7:872984a67d5b 373 fileNameString[13] = formattedDate[3];
MAA 7:872984a67d5b 374 fileNameString[14] = '-';
MAA 7:872984a67d5b 375 fileNameString[15] = formattedDate[5];
MAA 7:872984a67d5b 376 fileNameString[16] = formattedDate[6];
MAA 7:872984a67d5b 377 fileNameString[17] = '-';
MAA 7:872984a67d5b 378 fileNameString[18] = formattedDate[8];
MAA 7:872984a67d5b 379 fileNameString[19] = formattedDate[9];
MAA 6:6d1683c8b26b 380
MAA 7:872984a67d5b 381 fileNameString[20] = '.';
MAA 7:872984a67d5b 382 fileNameString[21] = 's';
MAA 7:872984a67d5b 383 fileNameString[22] = 'p';
MAA 7:872984a67d5b 384 fileNameString[23] = 's';
MAA 6:6d1683c8b26b 385
MAA 6:6d1683c8b26b 386 };
MAA 6:6d1683c8b26b 387
MAA 20:73fa202c73db 388 //! getSpsFileName, getter method, returning a *.sps filename based on the formatted date generated using generateSpsFilename(string formattedDate) method.
MAA 20:73fa202c73db 389 /*!
MAA 20:73fa202c73db 390 \return fileNameString returns file name including postfix.
MAA 20:73fa202c73db 391 */
MAA 6:6d1683c8b26b 392 string SPS::getSpsFileName(void){
MAA 6:6d1683c8b26b 393
MAA 6:6d1683c8b26b 394 return this->fileNameString;
MAA 6:6d1683c8b26b 395
MAA 7:872984a67d5b 396 };
MAA 7:872984a67d5b 397
MAA 20:73fa202c73db 398 //! getCurrentErrString, getter method returning current sps error string
MAA 20:73fa202c73db 399 /*!
MAA 20:73fa202c73db 400 \return currentErrString: returns the current sps error string.
MAA 20:73fa202c73db 401 */
MAA 7:872984a67d5b 402 string SPS::getCurrentErrString(void){
MAA 7:872984a67d5b 403 return this->currentErrString;
MAA 5:11782a2008c2 404 };