Skip to content

Commit

Permalink
Merge remote-tracking branch 'openbci/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey1994 committed Sep 4, 2019
2 parents e8d96f7 + dd91065 commit 2ba02a8
Show file tree
Hide file tree
Showing 31 changed files with 392 additions and 245 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ script:
- LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TRAVIS_BUILD_DIR/installed/lib python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/cyton_linux.py $TRAVIS_BUILD_DIR/tests/cpp/build/test_get_data 0
# tests for synthetic board
- python3 $TRAVIS_BUILD_DIR/tests/python/brainflow_get_data.py --log --board -1 --port "smth"
- python3 $TRAVIS_BUILD_DIR/tests/python/brainflow_multiboard_get_data.py --log --first-board -1 --first-port "smth1" --second-board -1 --second-port "smth2"
- $TRAVIS_BUILD_DIR/tests/cpp/build/test_get_data -1 "smth"
# tests for cyton daisy
- sudo -H python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/cyton_linux.py python3 $TRAVIS_BUILD_DIR/tests/python/brainflow_get_data.py --log --board 2 --port
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ test_script:
- echo "stub text to dont start command with special character" && %APPVEYOR_BUILD_FOLDER%\tests\cpp\build\Release\test_get_data.exe 1 e6:73:73:18:09:b1
# tests for synthetic
- python %APPVEYOR_BUILD_FOLDER%\tests\python\brainflow_get_data.py --log --board -1 --port "smth"
- python %APPVEYOR_BUILD_FOLDER%\tests\python\brainflow_multiboard_get_data.py --log --first-board -1 --first-port "smth1" --second-board -1 --second-port "smth2"
- echo "stub text to dont start command with special character" && %APPVEYOR_BUILD_FOLDER%\tests\cpp\build\Release\test_get_data.exe -1 "smth"
# tests for cyton daisy
- python %APPVEYOR_BUILD_FOLDER%\emulator\brainflow_emulator\cyton_windows.py python %APPVEYOR_BUILD_FOLDER%\tests\python\brainflow_get_data.py --log --board 2 --port
Expand Down
17 changes: 9 additions & 8 deletions cpp-package/src/board_shim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void BoardShim::prepare_session ()

void BoardShim::start_stream (int buffer_size)
{
int res = ::start_stream (buffer_size);
int res = ::start_stream (buffer_size, board_id, port_name);
if (res != STATUS_OK)
{
throw BrainFlowException ("failed to start stream", res);
Expand All @@ -31,7 +31,7 @@ void BoardShim::start_stream (int buffer_size)

void BoardShim::stop_stream ()
{
int res = ::stop_stream ();
int res = ::stop_stream (board_id, port_name);
if (res != STATUS_OK)
{
throw BrainFlowException ("failed to stop stream", res);
Expand All @@ -40,7 +40,7 @@ void BoardShim::stop_stream ()

void BoardShim::release_session ()
{
int res = ::release_session ();
int res = ::release_session (board_id, port_name);
if (res != STATUS_OK)
{
throw BrainFlowException ("failed to release session", res);
Expand All @@ -49,7 +49,7 @@ void BoardShim::release_session ()

void BoardShim::get_board_data_count (int *result)
{
int res = ::get_board_data_count (result);
int res = ::get_board_data_count (result, board_id, port_name);
if (res != STATUS_OK)
{
throw BrainFlowException ("failed to get board data count", res);
Expand All @@ -61,7 +61,7 @@ void BoardShim::get_board_data (int data_count, double **data_buf)
float *buf = new float[data_count * num_data_channels];
double *ts_buf = new double[data_count];

int res = ::get_board_data (data_count, buf, ts_buf);
int res = ::get_board_data (data_count, buf, ts_buf, board_id, port_name);
if (res != STATUS_OK)
{
delete[] buf;
Expand All @@ -78,7 +78,8 @@ void BoardShim::get_current_board_data (int num_samples, double **data_buf, int
float *buf = new float[num_samples * num_data_channels];
double *ts_buf = new double[num_samples];

int res = ::get_current_board_data (num_samples, buf, ts_buf, returned_samples);
int res =
::get_current_board_data (num_samples, buf, ts_buf, returned_samples, board_id, port_name);
if (res != STATUS_OK)
{
delete[] buf;
Expand All @@ -92,7 +93,7 @@ void BoardShim::get_current_board_data (int num_samples, double **data_buf, int

void BoardShim::config_board (char *config)
{
int res = ::config_board (config);
int res = ::config_board (config, board_id, port_name);
if (res != STATUS_OK)
{
throw BrainFlowException ("failed to config board", res);
Expand All @@ -109,4 +110,4 @@ void BoardShim::reshape_data (int data_count, float *data_buf, double *ts_buf, d
}
output_buf[i][num_data_channels] = ts_buf[i]; // add timestamp
}
}
}
14 changes: 7 additions & 7 deletions csharp-package/brainflow/brainflow/board_shim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void prepare_session ()

public void config_board (string config)
{
int res = Library.config_board (config);
int res = Library.config_board (config, board_id, port_name);
if (res != (int)CustomExitCodes.STATUS_OK)
{
throw new BrainFlowExceptioin (res);
Expand All @@ -69,7 +69,7 @@ public void config_board (string config)

public void start_stream (int num_samples = 3600 * 250)
{
int res = Library.start_stream(num_samples);
int res = Library.start_stream (num_samples, board_id, port_name);
if (res != (int) CustomExitCodes.STATUS_OK)
{
throw new BrainFlowExceptioin (res);
Expand All @@ -78,7 +78,7 @@ public void start_stream (int num_samples = 3600 * 250)

public void stop_stream ()
{
int res = Library.stop_stream ();
int res = Library.stop_stream (board_id, port_name);
if (res != (int) CustomExitCodes.STATUS_OK)
{
throw new BrainFlowExceptioin (res);
Expand All @@ -87,7 +87,7 @@ public void stop_stream ()

public void release_session ()
{
int res = Library.release_session ();
int res = Library.release_session (board_id, port_name);
if (res != (int) CustomExitCodes.STATUS_OK)
{
throw new BrainFlowExceptioin (res);
Expand All @@ -97,7 +97,7 @@ public void release_session ()
public int get_board_data_count ()
{
int[] res = new int[1];
int ec = Library.get_board_data_count (res);
int ec = Library.get_board_data_count (res, board_id, port_name);
if (ec != (int) CustomExitCodes.STATUS_OK)
{
throw new BrainFlowExceptioin (ec);
Expand All @@ -110,7 +110,7 @@ public int get_board_data_count ()
float[] data_arr = new float[num_samples * package_length];
double[] ts_arr = new double[num_samples];
int[] current_size = new int[1];
int ec = Library.get_current_board_data (num_samples, data_arr, ts_arr, current_size);
int ec = Library.get_current_board_data (num_samples, data_arr, ts_arr, current_size, board_id, port_name);
if (ec != (int) CustomExitCodes.STATUS_OK) {
throw new BrainFlowExceptioin (ec);
}
Expand All @@ -129,7 +129,7 @@ public int get_board_data_count ()
int size = get_board_data_count ();
float[] data_arr = new float[size * package_length];
double[] ts_arr = new double[size];
int ec = Library.get_board_data (size, data_arr, ts_arr);
int ec = Library.get_board_data (size, data_arr, ts_arr, board_id, port_name);
if (ec != (int) CustomExitCodes.STATUS_OK) {
throw new BrainFlowExceptioin (ec);
}
Expand Down
70 changes: 35 additions & 35 deletions csharp-package/brainflow/brainflow/library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,43 +43,43 @@ public static class Library64
[DllImport ("BoardController.dll", SetLastError = true)]
public static extern int prepare_session (int board_id, string port_name);
[DllImport ("BoardController.dll", SetLastError = true)]
public static extern int start_stream (int buffer_size);
public static extern int start_stream (int buffer_size, int board_id, string port_name);
[DllImport ("BoardController.dll", SetLastError = true)]
public static extern int stop_stream ();
public static extern int stop_stream (int board_id, string port_name);
[DllImport ("BoardController.dll", SetLastError = true)]
public static extern int release_session ();
public static extern int release_session (int board_id, string port_name);
[DllImport ("BoardController.dll", SetLastError = true)]
public static extern int get_current_board_data (int num_samples, float[] data_buf, double[] ts_buf, int[] returned_samples);
public static extern int get_current_board_data (int num_samples, float[] data_buf, double[] ts_buf, int[] returned_samples, int board_id, string port_name);
[DllImport ("BoardController.dll", SetLastError = true)]
public static extern int get_board_data_count(int[] result);
public static extern int get_board_data_count(int[] result, int board_id, string port_name);
[DllImport ("BoardController.dll", SetLastError = true)]
public static extern int get_board_data (int data_count, float[] data_buf, double[] ts_buf);
public static extern int get_board_data (int data_count, float[] data_buf, double[] ts_buf, int board_id, string port_name);
[DllImport ("BoardController.dll", SetLastError = true)]
public static extern int set_log_level (int log_level);
[DllImport ("BoardController.dll", SetLastError = true)]
public static extern int config_board (string config);
public static extern int config_board (string config, int board_id, string port_name);
}

public static class Library32
{
[DllImport ("BoardController32.dll", SetLastError = true)]
public static extern int prepare_session (int board_id, string port_name);
[DllImport ("BoardController32.dll", SetLastError = true)]
public static extern int start_stream (int buffer_size);
public static extern int start_stream (int buffer_size, int board_id, string port_name);
[DllImport ("BoardController32.dll", SetLastError = true)]
public static extern int stop_stream ();
public static extern int stop_stream (int board_id, string port_name);
[DllImport ("BoardController32.dll", SetLastError = true)]
public static extern int release_session ();
public static extern int release_session (int board_id, string port_name);
[DllImport ("BoardController32.dll", SetLastError = true)]
public static extern int get_current_board_data (int num_samples, float[] data_buf, double[] ts_buf, int[] returned_samples);
public static extern int get_current_board_data (int num_samples, float[] data_buf, double[] ts_buf, int[] returned_samples, int board_id, string port_name);
[DllImport ("BoardController32.dll", SetLastError = true)]
public static extern int get_board_data_count (int[] result);
public static extern int get_board_data_count (int[] result, int board_id, string port_name);
[DllImport ("BoardController32.dll", SetLastError = true)]
public static extern int get_board_data (int data_count, float[] data_buf, double[] ts_buf);
public static extern int get_board_data (int data_count, float[] data_buf, double[] ts_buf, int board_id, string port_name);
[DllImport ("BoardController32.dll", SetLastError = true)]
public static extern int set_log_level (int log_level);
[DllImport ("BoardController32.dll", SetLastError = true)]
public static extern int config_board (string config);
public static extern int config_board (string config, int board_id, string port_name);
}

public static class Library
Expand All @@ -92,52 +92,52 @@ public static int prepare_session (int board_id, string port_name)
return Library32.prepare_session (board_id, port_name);
}

public static int start_stream (int buffer_size)
public static int start_stream (int buffer_size, int board_id, string port_name)
{
if (System.Environment.Is64BitProcess)
return Library64.start_stream (buffer_size);
return Library64.start_stream (buffer_size, board_id, port_name);
else
return Library32.start_stream (buffer_size);
return Library32.start_stream (buffer_size, board_id, port_name);
}

public static int stop_stream ()
public static int stop_stream (int board_id, string port_name)
{
if (System.Environment.Is64BitProcess)
return Library64.stop_stream ();
return Library64.stop_stream (board_id, port_name);
else
return Library32.stop_stream ();
return Library32.stop_stream (board_id, port_name);
}

public static int release_session ()
public static int release_session (int board_id, string port_name)
{
if (System.Environment.Is64BitProcess)
return Library64.release_session ();
return Library64.release_session (board_id, port_name);
else
return Library32.release_session ();
return Library32.release_session (board_id, port_name);
}

public static int get_current_board_data (int num_samples, float[] data_buf, double[] ts_buf, int[] returned_samples)
public static int get_current_board_data (int num_samples, float[] data_buf, double[] ts_buf, int[] returned_samples, int board_id, string port_name)
{
if (System.Environment.Is64BitProcess)
return Library64.get_current_board_data (num_samples, data_buf, ts_buf, returned_samples);
return Library64.get_current_board_data (num_samples, data_buf, ts_buf, returned_samples, board_id, port_name);
else
return Library32.get_current_board_data (num_samples, data_buf, ts_buf, returned_samples);
return Library32.get_current_board_data (num_samples, data_buf, ts_buf, returned_samples, board_id, port_name);
}

public static int get_board_data_count (int[] result)
public static int get_board_data_count (int[] result, int board_id, string port_name)
{
if (System.Environment.Is64BitProcess)
return Library64.get_board_data_count (result);
return Library64.get_board_data_count (result, board_id, port_name);
else
return Library32.get_board_data_count (result);
return Library32.get_board_data_count (result, board_id, port_name);
}

public static int get_board_data (int data_count, float[] data_buf, double[] ts_buf)
public static int get_board_data (int data_count, float[] data_buf, double[] ts_buf, int board_id, string port_name)
{
if (System.Environment.Is64BitProcess)
return Library64.get_board_data (data_count, data_buf, ts_buf);
return Library64.get_board_data (data_count, data_buf, ts_buf, board_id, port_name);
else
return Library32.get_board_data (data_count, data_buf, ts_buf);
return Library32.get_board_data (data_count, data_buf, ts_buf, board_id, port_name);
}

public static int set_log_level (int log_level)
Expand All @@ -148,12 +148,12 @@ public static int set_log_level (int log_level)
return Library32.set_log_level (log_level);
}

public static int config_board (string config)
public static int config_board (string config, int board_id, string port_name)
{
if (System.Environment.Is64BitProcess)
return Library64.config_board (config);
return Library64.config_board (config, board_id, port_name);
else
return Library32.config_board (config);
return Library32.config_board (config, board_id, port_name);
}
}
}

0 comments on commit 2ba02a8

Please sign in to comment.