| 457 | } |
| 458 | |
| 459 | int Board::get_board_data (int data_count, int preset, double *data_buf) |
| 460 | { |
| 461 | std::string preset_str = preset_to_string (preset); |
| 462 | if (board_descr.find (preset_str) == board_descr.end ()) |
| 463 | { |
| 464 | safe_logger (spdlog::level::err, "invalid preset"); |
| 465 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
| 466 | } |
| 467 | if (dbs.find (preset) == dbs.end ()) |
| 468 | { |
| 469 | safe_logger (spdlog::level::err, |
| 470 | "stream is not started or no preset: {} found for this board", preset); |
| 471 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
| 472 | } |
| 473 | if (!dbs[preset]) |
| 474 | { |
| 475 | return (int)BrainFlowExitCodes::EMPTY_BUFFER_ERROR; |
| 476 | } |
| 477 | if (!data_buf) |
| 478 | { |
| 479 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
| 480 | } |
| 481 | int num_rows = (int)board_descr[preset_str]["num_rows"]; |
| 482 | double *buf = new double[data_count * num_rows]; |
| 483 | int num_data_points = (int)dbs[preset]->get_data (data_count, buf); |
| 484 | reshape_data (num_data_points, preset, buf, data_buf); |
| 485 | delete[] buf; |
| 486 | return (int)BrainFlowExitCodes::STATUS_OK; |
| 487 | } |
| 488 | |
| 489 | void Board::reshape_data (int data_count, int preset, const double *buf, double *output_buf) |
| 490 | { |