void BatchLogger::writeToMRDPLOT2(std::string prefix) { if (!_inited || _nPoints == 0) { std::cout << "writeToMRDPLOT2 not init or no data!" << std::endl; return; } _saving = true; std::string file_name = generate_file_name(prefix); std::cout << file_name << " SAVING DATA ....." << std::endl; std::vector<std::string> names; std::vector<std::string> units; float *data = _data; names.resize(_nChannels); units.resize(_nChannels); for (int i = 0; i < _nChannels; i++) { names[i] = _datapoints[i].names; units[i] = _datapoints[i].units; } write_mrdplot_file( file_name, _nChannels*_nPoints, _nChannels, _nPoints, _frequency, data, names, units); std::cout << file_name << " SAVED DATA." << std::endl; _saving = false; }
void BatchLogger::writeToMRDPLOT(const char *prefix) { if (!_inited || _nPoints == 0) return; // mtx.lock(); _saving = true; MRDPLOT_DATA *d; d = malloc_mrdplot_data( 0, 0 ); d->filename = generate_file_name(prefix); d->n_channels = _nChannels; d->n_points = _nPoints; d->total_n_numbers = d->n_channels*d->n_points; d->frequency = _frequency; d->data = _data; // mtx.unlock(); _saving = false; fprintf(stdout, "%s SAVING DATA ..... \n", d->filename); d->names = new char*[d->n_channels]; d->units = new char*[d->n_channels]; for (int i = 0; i < d->n_channels; i++) { d->names[i] = new char[LOGGER_MAX_CHARS]; d->units[i] = new char[LOGGER_MAX_CHARS]; strcpy(d->names[i], _datapoints[i].names); strcpy(d->units[i], _datapoints[i].units); } write_mrdplot_file( d ); for (int i = 0; i < d->n_channels; i++) { delete []d->names[i]; delete []d->units[i]; } delete []d->names; delete []d->units; fprintf(stdout, "%s SAVED DATA\n", d->filename); free(d); }
void BatchLogger::writeToMRDPLOT() { if (!_inited) return; recorded = true; fprintf(stderr, "LOGGER SAVING DATA ..... \n"); MRDPLOT_DATA *d; d = malloc_mrdplot_data( 0, 0 ); d->filename = generate_file_name(); d->n_channels = n_channels; d->n_points = n_points; d->total_n_numbers = d->n_channels*d->n_points; d->frequency = frequency; d->data = data; d->names = new char*[n_channels]; d->units = new char*[n_channels]; for (int i = 0; i < n_channels; i++) { d->names[i] = new char[LOGGER_MAX_CHARS]; d->units[i] = new char[LOGGER_MAX_CHARS]; strcpy(d->names[i], datapoints[i].names); strcpy(d->units[i], datapoints[i].units); } write_mrdplot_file( d ); for (int i = 0; i < n_channels; i++) { delete []d->names[i]; delete []d->units[i]; } delete []d->names; delete []d->units; fprintf(stderr, "LOGGER SAVED DATA\n"); free(d); }