Esempio n. 1
0
        /// <summary>
        /// get collected data and remove it from ringbuffer
        /// </summary>
        /// <returns>all collected data</returns>
        public double[,] get_board_data(int num_datapoints)
        {
            int size = get_board_data_count();

            if (num_datapoints < 0)
            {
                throw new BrainFlowException((int)CustomExitCodes.INVALID_ARGUMENTS_ERROR);
            }
            size = Math.Min(size, num_datapoints);
            int num_rows = BoardShim.get_num_rows(master_board_id);

            double[] data_arr = new double[size * num_rows];
            int      ec       = BoardControllerLibrary.get_board_data(size, data_arr, board_id, input_json);

            if (ec != (int)CustomExitCodes.STATUS_OK)
            {
                throw new BrainFlowException(ec);
            }
            double[,] result = new double[num_rows, size];
            for (int i = 0; i < num_rows; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    result[i, j] = data_arr[i * size + j];
                }
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// get latest collected data, doesnt remove it from ringbuffer
        /// </summary>
        /// <param name="num_samples"></param>
        /// <returns>latest collected data, can be less than "num_samples"</returns>
        public double[,] get_current_board_data (int num_samples)
        {
            int num_rows = BoardShim.get_num_rows (master_board_id); 
            double[] data_arr = new double[num_samples * num_rows];
            int[] current_size = new int[1];
            int ec = BoardControllerLibrary.get_current_board_data (num_samples, data_arr, current_size, board_id, input_json);
		    if (ec != (int) CustomExitCodes.STATUS_OK) {
			    throw new BrainFlowException (ec);
            }
            double[,] result = new double[num_rows, current_size[0]];
            for (int i = 0; i < num_rows; i++)
            {
                for (int j = 0; j < current_size[0]; j++)
                {
                    result[i, j] = data_arr[i * current_size[0] + j];
                }
            }
            return result;
	    }