|
11 | 11 | #include <unistd.h> |
12 | 12 | #endif |
13 | 13 |
|
| 14 | +#include <sstream> |
| 15 | +#include <iterator> |
| 16 | + |
14 | 17 | #include <algorithm> |
15 | 18 | #include <chrono> |
16 | 19 |
|
@@ -347,6 +350,14 @@ int AntNeuroBoard::config_board (std::string config, std::string &response) |
347 | 350 | std::string bv_prefix = "bipolar_range:"; |
348 | 351 | std::string mode_prefix = "impedance_mode:"; |
349 | 352 |
|
| 353 | + std::string get_type = "get_type"; |
| 354 | + std::string get_firmware_version = "get_firmware_version"; |
| 355 | + std::string get_serial_number = "get_serial_number"; |
| 356 | + std::string get_sampling_rates_available = "get_sampling_rates_available"; |
| 357 | + std::string get_reference_ranges_available = "get_reference_ranges_available"; |
| 358 | + std::string get_bipolar_ranges_available = "get_bipolar_ranges_available"; |
| 359 | + std::string get_power_state = "get_power_state"; |
| 360 | + |
350 | 361 | if (config.find (prefix) != std::string::npos) |
351 | 362 | { |
352 | 363 | int new_sampling_rate = 0; |
@@ -471,6 +482,70 @@ int AntNeuroBoard::config_board (std::string config, std::string &response) |
471 | 482 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
472 | 483 | } |
473 | 484 | } |
| 485 | + // get info from ANT SDK |
| 486 | + else if (config == get_type) |
| 487 | + { |
| 488 | + response = amp->getType (); |
| 489 | + return (int)BrainFlowExitCodes::STATUS_OK; |
| 490 | + } |
| 491 | + else if (config == get_firmware_version) |
| 492 | + { |
| 493 | + int version = amp->getFirmwareVersion(); |
| 494 | + response = std::to_string(version); |
| 495 | + return (int)BrainFlowExitCodes::STATUS_OK; |
| 496 | + } |
| 497 | + else if (config == get_serial_number) |
| 498 | + { |
| 499 | + response = amp->getSerialNumber (); |
| 500 | + return (int)BrainFlowExitCodes::STATUS_OK; |
| 501 | + } |
| 502 | + else if (config == get_sampling_rates_available) |
| 503 | + { |
| 504 | + std::vector<int> sampling_rates = amp->getSamplingRatesAvailable(); |
| 505 | + std::ostringstream result; |
| 506 | + if (!sampling_rates.empty()) |
| 507 | + { |
| 508 | + std::copy(sampling_rates.begin(), sampling_rates.end() - 1, std::ostream_iterator<int>(result, ",")); |
| 509 | + result << sampling_rates.back(); // no trailing comma |
| 510 | + } |
| 511 | + response = result.str(); |
| 512 | + return (int)BrainFlowExitCodes::STATUS_OK; |
| 513 | + } |
| 514 | + else if (config == get_reference_ranges_available) |
| 515 | + { |
| 516 | + std::vector<double> reference_ranges = amp->getReferenceRangesAvailable(); |
| 517 | + std::ostringstream result; |
| 518 | + if (!reference_ranges.empty()) |
| 519 | + { |
| 520 | + std::copy(reference_ranges.begin(), reference_ranges.end() - 1, std::ostream_iterator<double>(result, ",")); |
| 521 | + result << reference_ranges.back(); // no trailing comma |
| 522 | + } |
| 523 | + response = result.str(); |
| 524 | + return (int)BrainFlowExitCodes::STATUS_OK; |
| 525 | + } |
| 526 | + else if (config == get_bipolar_ranges_available) |
| 527 | + { |
| 528 | + std::vector<double> bipolar_ranges = amp->getBipolarRangesAvailable(); |
| 529 | + std::ostringstream result; |
| 530 | + if (!bipolar_ranges.empty()) |
| 531 | + { |
| 532 | + std::copy(bipolar_ranges.begin(), bipolar_ranges.end() - 1, std::ostream_iterator<int>(result, ",")); |
| 533 | + result << bipolar_ranges.back(); // no trailing comma |
| 534 | + } |
| 535 | + response = result.str(); |
| 536 | + return (int)BrainFlowExitCodes::STATUS_OK; |
| 537 | + } |
| 538 | + else if (config == get_power_state) |
| 539 | + { |
| 540 | + amplifier::power_state power_state = amp->getPowerState (); |
| 541 | + std::ostringstream oss; |
| 542 | + oss << "is_powered: " << power_state.is_powered |
| 543 | + << ", is_charging: " << power_state.is_charging |
| 544 | + << ", charging_level: " << power_state.charging_level; |
| 545 | + response = oss.str(); |
| 546 | + |
| 547 | + return (int)BrainFlowExitCodes::STATUS_OK; |
| 548 | + } |
474 | 549 |
|
475 | 550 | safe_logger (spdlog::level::err, "format is '{}value'", prefix.c_str ()); |
476 | 551 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
|
0 commit comments