MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / prepare_for_acquisition

Method prepare_for_acquisition

src/board_controller/board.cpp:74–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74int Board::prepare_for_acquisition (int buffer_size, const char *streamer_params)
75{
76 if (buffer_size <= 0 || buffer_size > MAX_CAPTURE_SAMPLES)
77 {
78 safe_logger (spdlog::level::err, "invalid array size");
79 return (int)BrainFlowExitCodes::INVALID_BUFFER_SIZE_ERROR;
80 }
81
82 for (auto it = dbs.begin (), next_it = it; it != dbs.end (); it = next_it)
83 {
84 ++next_it;
85 delete it->second;
86 dbs.erase (it);
87 }
88 for (auto it = marker_queues.begin (), next_it = it; it != marker_queues.end (); it = next_it)
89 {
90 ++next_it;
91 it->second.clear ();
92 marker_queues.erase (it);
93 }
94 int res = (int)BrainFlowExitCodes::STATUS_OK;
95
96 std::vector<std::string> required_fields {
97 "num_rows", "timestamp_channel", "name", "marker_channel"};
98 std::vector<std::string> supported_presets {"ancillary", "auxiliary", "default"};
99 for (std::string field : required_fields)
100 {
101 for (auto &el : board_descr.items ())
102 {
103 json board_preset = el.value ();
104 std::string key = el.key ();
105 if (std::find (supported_presets.begin (), supported_presets.end (), key) ==
106 supported_presets.end ())
107 {
108 safe_logger (spdlog::level::err, "Preset {} is not supported", key);
109 return (int)BrainFlowExitCodes::GENERAL_ERROR;
110 }
111
112 if (board_preset.find (field) == board_preset.end ())
113 {
114 safe_logger (spdlog::level::err,
115 "Field {} is not found in brainflow_boards.h for id {}", field, board_id);
116 return (int)BrainFlowExitCodes::GENERAL_ERROR;
117 }
118 }
119 }
120
121 if ((streamer_params != NULL) && (streamer_params[0] != '\0'))
122 {
123 res = add_streamer (streamer_params, (int)BrainFlowPresets::DEFAULT_PRESET);
124 }
125
126 if (res == (int)BrainFlowExitCodes::STATUS_OK)
127 {
128 for (auto &el : board_descr.items ())
129 {
130 json board_preset = el.value ();
131 DataBuffer *db = new DataBuffer ((int)board_preset["num_rows"], buffer_size);

Callers

nothing calls this directly

Calls 2

add_streamerFunction · 0.85
is_readyMethod · 0.80

Tested by

no test coverage detected