Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ Note: type `/start` to launch the selected plugins.
Add new functionalities to user.py by creating new scripts inside the `plugins` folder. You class must inherit from yapsy.IPlugin, see below a minimal example with `print` plugin:

```python
import plugin_interface as plugintypes
from .plugin_interface import IPluginExtended

class PluginPrint(plugintypes.IPluginExtended):
class PluginPrint(IPluginExtended):
def activate(self):
print("Print activated")

Expand Down
4 changes: 2 additions & 2 deletions openbci/plugins/csv_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import timeit
import datetime

import plugin_interface as plugintypes
from .plugin_interface import IPluginExtended


class PluginCSVCollect(plugintypes.IPluginExtended):
class PluginCSVCollect(IPluginExtended):
def __init__(self, file_name="collect.csv", delim=",", verbose=False):
now = datetime.datetime.now()
self.time_stamp = '%d-%d-%d_%d-%d-%d' \
Expand Down
4 changes: 2 additions & 2 deletions openbci/plugins/noise_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import print_function
import timeit
import numpy as np
import plugin_interface as plugintypes
from .plugin_interface import IPluginExtended


class PluginNoiseTest(plugintypes.IPluginExtended):
class PluginNoiseTest(IPluginExtended):
# update counters value
def __call__(self, sample):
# keep tract of absolute value of
Expand Down
8 changes: 2 additions & 6 deletions plugin_interface.py → openbci/plugins/plugin_interface.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
"""
Extends Yapsy IPlugin interface to pass information about the board to plugins.

Fields of interest for plugins:
args: list of arguments passed to the plugins
sample_rate: actual sample rate of the board
eeg_channels: number of EEG
aux_channels: number of AUX channels

If needed, plugins that need to report an error can set self.is_activated to False during activate() call.

NB: because of how yapsy discovery system works, plugins must use the following syntax to inherit to use polymorphism (see http://yapsy.sourceforge.net/Advices.html):

import plugin_interface as plugintypes

class PluginExample(plugintypes.IPluginExtended):
from .plugin_interface import IPluginExtended
class PluginExample(IPluginExtended):
...
"""

Expand Down
4 changes: 2 additions & 2 deletions openbci/plugins/print.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import print_function
import plugin_interface as plugintypes
from .plugin_interface import IPluginExtended


class PluginPrint(plugintypes.IPluginExtended):
class PluginPrint(IPluginExtended):
def activate(self):
print("Print activated")

Expand Down
4 changes: 2 additions & 2 deletions openbci/plugins/sample_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import timeit
from threading import Thread

import plugin_interface as plugintypes
from .plugin_interface import IPluginExtended

# counter for sampling rate
nb_samples_out = -1
Expand Down Expand Up @@ -36,7 +36,7 @@ def run(self):
time.sleep(self.polling_interval)


class PluginSampleRate(plugintypes.IPluginExtended):
class PluginSampleRate(IPluginExtended):
# update counters value
def __call__(self, sample):
global nb_samples_out
Expand Down
4 changes: 2 additions & 2 deletions openbci/plugins/streamer_lsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Eg: ftp://sccn.ucsd.edu/pub/software/LSL/SDK/liblsl-Python-1.10.2.zip
# put in "lib" folder (same level as user.py)
from __future__ import print_function
import plugin_interface as plugintypes
from .plugin_interface import IPluginExtended
from pylsl import StreamInfo, StreamOutlet
import sys

Expand All @@ -13,7 +13,7 @@
# Use LSL protocol to broadcast data using one stream for EEG,
# one stream for AUX, one last for impedance testing
# (on supported board, if enabled)
class StreamerLSL(plugintypes.IPluginExtended):
class StreamerLSL(IPluginExtended):
# From IPlugin
def activate(self):
eeg_stream = "OpenBCI_EEG"
Expand Down
4 changes: 2 additions & 2 deletions openbci/plugins/streamer_osc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# requires python-osc
from pythonosc import osc_message_builder
from pythonosc import udp_client
import plugin_interface as plugintypes
from .plugin_interface import IPluginExtended


# Use OSC protocol to broadcast data (UDP layer), using "/openbci" stream.
# (NB. does not check numbers of channel as TCP server)

class StreamerOSC(plugintypes.IPluginExtended):
class StreamerOSC(IPluginExtended):
"""
Relay OpenBCI values to OSC clients

Expand Down
4 changes: 2 additions & 2 deletions openbci/plugins/streamer_tcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import select
import struct
import time
import plugin_interface as plugintypes
from .plugin_interface import IPluginExtended


# Simple TCP server to "broadcast" data to clients, handling deconnections.
Expand Down Expand Up @@ -34,7 +34,7 @@ def run(self):
time.sleep(1)


class StreamerTCPServer(plugintypes.IPluginExtended):
class StreamerTCPServer(IPluginExtended):
"""

Relay OpenBCI values to TCP clients
Expand Down
4 changes: 2 additions & 2 deletions openbci/plugins/udp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import json
import socket

import plugin_interface as plugintypes
from .plugin_interface import IPluginExtended


# class PluginPrint(IPlugin):
Expand Down Expand Up @@ -48,7 +48,7 @@
# # print(sample_string)


class UDPServer(plugintypes.IPluginExtended):
class UDPServer(IPluginExtended):
def __init__(self, ip='localhost', port=8888):
self.ip = ip
self.port = port
Expand Down