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

Class BoardShim

python_package/brainflow/board_shim.py:595–1490  ·  view source on GitHub ↗

BoardShim class is a primary interface to all boards :param board_id: Id of your board :type board_id: int :param input_params: board specific structure to pass required arguments :type input_params: BrainFlowInputParams

Source from the content-addressed store, hash-verified

593
594
595class BoardShim(object):
596 """BoardShim class is a primary interface to all boards
597
598 :param board_id: Id of your board
599 :type board_id: int
600 :param input_params: board specific structure to pass required arguments
601 :type input_params: BrainFlowInputParams
602 """
603
604 def __init__(self, board_id: int, input_params: BrainFlowInputParams) -> None:
605 try:
606 self.input_json = input_params.to_json().encode()
607 except BaseException:
608 self.input_json = input_params.to_json()
609 self.board_id = board_id
610 # we need it for streaming board
611 if board_id == BoardIds.STREAMING_BOARD.value or board_id == BoardIds.PLAYBACK_FILE_BOARD.value:
612 if input_params.master_board != BoardIds.NO_BOARD:
613 self._master_board_id = input_params.master_board
614 else:
615 raise BrainFlowError('you need set master board id in BrainFlowInputParams',
616 BrainFlowExitCodes.INVALID_ARGUMENTS_ERROR.value)
617 else:
618 self._master_board_id = self.board_id
619
620 def __del__(self) -> None:
621 if self.is_prepared():
622 self.release_session()
623
624 @classmethod
625 def set_log_level(cls, log_level: int) -> None:
626 """set BrainFlow log level, use it only if you want to write your own messages to BrainFlow logger,
627 otherwise use enable_board_logger, enable_dev_board_logger or disable_board_logger
628
629 :param log_level: log level, to specify it you should use values from LogLevels enum
630 :type log_level: int
631 """
632 res = BoardControllerDLL.get_instance().set_log_level_board_controller(log_level)
633 if res != BrainFlowExitCodes.STATUS_OK.value:
634 raise BrainFlowError('unable to enable logger', res)
635
636 @classmethod
637 def enable_board_logger(cls) -> None:
638 """enable BrainFlow Logger with level INFO, uses stderr for log messages by default"""
639 cls.set_log_level(LogLevels.LEVEL_INFO.value)
640
641 @classmethod
642 def disable_board_logger(cls) -> None:
643 """disable BrainFlow Logger"""
644 cls.set_log_level(LogLevels.LEVEL_OFF.value)
645
646 @classmethod
647 def enable_dev_board_logger(cls) -> None:
648 """enable BrainFlow Logger with level TRACE, uses stderr for log messages by default"""
649 cls.set_log_level(LogLevels.LEVEL_TRACE.value)
650
651 @classmethod
652 def log_message(cls, log_level: int, message: str) -> None:

Callers 15

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by 3

mainFunction · 0.72
mainFunction · 0.72
mainFunction · 0.72