Arquivo normal → Arquivo executável
+3
-3
@@ -36,12 +36,12 @@ class IPluginExtended(IPlugin):
|
||||
|
||||
# inherited from IPlugin
|
||||
def activate(self):
|
||||
print "Plugin %s activated." % (self.__class__.__name__)
|
||||
print("Plugin %s activated." % (self.__class__.__name__))
|
||||
|
||||
# inherited from IPlugin
|
||||
def deactivate(self):
|
||||
print "Plugin %s deactivated." % (self.__class__.__name__)
|
||||
print("Plugin %s deactivated." % (self.__class__.__name__))
|
||||
|
||||
# plugins that require arguments should implement this method
|
||||
def show_help(self):
|
||||
print "I, %s, do not need any parameter." % (self.__class__.__name__)
|
||||
print("I, %s, do not need any parameter." % (self.__class__.__name__))
|
||||
|
||||
Arquivo normal → Arquivo executável
+4
-4
@@ -23,22 +23,22 @@ class PluginCSVCollect(plugintypes.IPluginExtended):
|
||||
self.verbose = True
|
||||
|
||||
self.file_name = self.file_name + '.csv'
|
||||
print "Will export CSV to:", self.file_name
|
||||
print("Will export CSV to:" + self.file_name)
|
||||
#Open in append mode
|
||||
with open(self.file_name, 'a') as f:
|
||||
f.write('%'+self.time_stamp + '\n')
|
||||
|
||||
def deactivate(self):
|
||||
print "Closing, CSV saved to:", self.file_name
|
||||
print("Closing, CSV saved to:" + self.file_name)
|
||||
return
|
||||
|
||||
def show_help(self):
|
||||
print "Optional argument: [filename] (default: collect.csv)"
|
||||
print("Optional argument: [filename] (default: collect.csv)")
|
||||
|
||||
def __call__(self, sample):
|
||||
t = timeit.default_timer() - self.start_time
|
||||
|
||||
#print timeSinceStart|Sample Id
|
||||
#print(timeSinceStart|Sample Id)
|
||||
if self.verbose:
|
||||
print("CSV: %f | %d" %(t,sample.id))
|
||||
|
||||
|
||||
Arquivo normal → Arquivo executável
+2
-2
@@ -35,6 +35,6 @@ class PluginNoiseTest(plugintypes.IPluginExtended):
|
||||
|
||||
|
||||
def show_help(self):
|
||||
print "Optional argument: polling_interval -- in seconds, default: 10. \n \
|
||||
print ("Optional argument: polling_interval -- in seconds, default: 10. \n \
|
||||
Returns the power of the system noise.\n \
|
||||
NOTE: The reference and channel should have the same input signal."
|
||||
NOTE: The reference and channel should have the same input signal.")
|
||||
|
||||
Arquivo normal → Arquivo executável
+6
-6
@@ -2,7 +2,7 @@ import plugin_interface as plugintypes
|
||||
|
||||
class PluginPrint(plugintypes.IPluginExtended):
|
||||
def activate(self):
|
||||
print "Print activated"
|
||||
print("Print activated")
|
||||
|
||||
# called with each new sample
|
||||
def __call__(self, sample):
|
||||
@@ -12,15 +12,15 @@ class PluginPrint(plugintypes.IPluginExtended):
|
||||
sample_string = "ID: %f\n%s\n%s\n%s" %(sample.id, str(sample.channel_data)[1:-1], str(sample.aux_data)[1:-1], str(sample.imp_data)[1:-1])
|
||||
else:
|
||||
sample_string = "ID: %f\n%s\n%s" %(sample.id, str(sample.channel_data)[1:-1], str(sample.aux_data)[1:-1])
|
||||
print "---------------------------------"
|
||||
print sample_string
|
||||
print "---------------------------------"
|
||||
print("---------------------------------")
|
||||
print(sample_string)
|
||||
print("---------------------------------")
|
||||
|
||||
# DEBBUGING
|
||||
# try:
|
||||
# sample_string.decode('ascii')
|
||||
# except UnicodeDecodeError:
|
||||
# print "Not a ascii-encoded unicode string"
|
||||
# print("Not a ascii-encoded unicode string")
|
||||
# else:
|
||||
# print sample_string
|
||||
# print(sample_string)
|
||||
|
||||
|
||||
Arquivo normal → Arquivo executável
+5
-5
@@ -24,11 +24,11 @@ class Monitor(Thread):
|
||||
new_tick = timeit.default_timer()
|
||||
elapsed_time = new_tick - self.tick
|
||||
current_samples_out = nb_samples_out
|
||||
print "--- at t: ", (new_tick - self.start_tick), " ---"
|
||||
print "elapsed_time: ", elapsed_time
|
||||
print "nb_samples_out: ", current_samples_out - self.nb_samples_out
|
||||
print("--- at t: " + str(new_tick - self.start_tick) + " ---")
|
||||
print("elapsed_time: " + str(elapsed_time))
|
||||
print("nb_samples_out: " + str(current_samples_out - self.nb_samples_out))
|
||||
sampling_rate = (current_samples_out - self.nb_samples_out) / elapsed_time
|
||||
print "sampling rate: ", sampling_rate
|
||||
print("sampling rate: " + str(sampling_rate))
|
||||
self.tick = new_tick
|
||||
self.nb_samples_out = nb_samples_out
|
||||
time.sleep(self.polling_interval)
|
||||
@@ -49,4 +49,4 @@ class PluginSampleRate(plugintypes.IPluginExtended):
|
||||
monit.start()
|
||||
|
||||
def show_help(self):
|
||||
print "Optional argument: polling_interval -- in seconds, default: 10."
|
||||
print("Optional argument: polling_interval -- in seconds, default: 10.")
|
||||
|
||||
Arquivo normal → Arquivo executável
+8
-5
@@ -31,10 +31,12 @@ class StreamerLSL(plugintypes.IPluginExtended):
|
||||
imp_id = self.args[5]
|
||||
|
||||
# Create a new streams info, one for EEG values, one for AUX (eg, accelerometer) values
|
||||
print "Creating LSL stream for EEG. Name:", eeg_stream, "- ID:", eeg_id, "- data type: float32.", self.eeg_channels, "channels at", self.sample_rate, "Hz."
|
||||
print("Creating LSL stream for EEG. Name:" + eeg_stream + "- ID:" + eeg_id +
|
||||
"- data type: float32." + str(self.eeg_channels) + "channels at" + str(self.sample_rate) + "Hz.")
|
||||
info_eeg = StreamInfo(eeg_stream, 'EEG', self.eeg_channels,self.sample_rate,'float32',eeg_id);
|
||||
# NB: set float32 instead of int16 so as OpenViBE takes it into account
|
||||
print "Creating LSL stream for AUX. Name:", aux_stream, "- ID:", aux_id, "- data type: float32.", self.aux_channels, "channels at", self.sample_rate, "Hz."
|
||||
print("Creating LSL stream for AUX. Name:" + aux_stream + "- ID:" + aux_id +
|
||||
"- data type: float32." + str(self.aux_channels) + "channels at" + str(self.sample_rate) + "Hz.")
|
||||
info_aux = StreamInfo(aux_stream, 'AUX', self.aux_channels,self.sample_rate,'float32',aux_id);
|
||||
|
||||
# make outlets
|
||||
@@ -42,7 +44,8 @@ class StreamerLSL(plugintypes.IPluginExtended):
|
||||
self.outlet_aux = StreamOutlet(info_aux)
|
||||
|
||||
if self.imp_channels > 0:
|
||||
print "Creating LSL stream for Impedance. Name:", imp_stream, "- ID:", imp_id, "- data type: float32.", self.imp_channels, "channels at", self.sample_rate, "Hz."
|
||||
print("Creating LSL stream for Impedance. Name:" + imp_stream + "- ID:" + imp_id +
|
||||
"- data type: float32." + str(self.imp_channels) + "channels at" + str(self.sample_rate) + "Hz.")
|
||||
info_imp = StreamInfo(imp_stream, 'Impedance', self.imp_channels,self.sample_rate,'float32',imp_id);
|
||||
self.outlet_imp = StreamOutlet(info_imp)
|
||||
|
||||
@@ -54,5 +57,5 @@ class StreamerLSL(plugintypes.IPluginExtended):
|
||||
self.outlet_imp.push_sample(sample.imp_data)
|
||||
|
||||
def show_help(self):
|
||||
print """Optional arguments: [EEG_stream_name [EEG_stream_ID [AUX_stream_name [AUX_stream_ID [Impedance_steam_name [Impedance_stream_ID]]]]]]
|
||||
\t Defaults: "OpenBCI_EEG" / "openbci_eeg_id1" and "OpenBCI_AUX" / "openbci_aux_id1" / "OpenBCI_Impedance" / "openbci_imp_id1"."""
|
||||
print("""Optional arguments: [EEG_stream_name [EEG_stream_ID [AUX_stream_name [AUX_stream_ID [Impedance_steam_name [Impedance_stream_ID]]]]]]
|
||||
\t Defaults: "OpenBCI_EEG" / "openbci_eeg_id1" and "OpenBCI_AUX" / "openbci_aux_id1" / "OpenBCI_Impedance" / "openbci_imp_id1".""")
|
||||
|
||||
Arquivo normal → Arquivo executável
+11
-13
@@ -1,6 +1,7 @@
|
||||
|
||||
# requires pyosc
|
||||
from OSC import OSCClient, OSCMessage
|
||||
# requires python-osc
|
||||
from pythonosc import osc_message_builder
|
||||
from pythonosc import udp_client
|
||||
import plugin_interface as plugintypes
|
||||
|
||||
# Use OSC protocol to broadcast data (UDP layer), using "/openbci" stream. (NB. does not check numbers of channel as TCP server)
|
||||
@@ -31,26 +32,23 @@ class StreamerOSC(plugintypes.IPluginExtended):
|
||||
if len(self.args) > 2:
|
||||
self.address = self.args[2]
|
||||
# init network
|
||||
print "Selecting OSC streaming. IP: ", self.ip, ", port: ", self.port, ", address: ", self.address
|
||||
self.client = OSCClient()
|
||||
self.client.connect( (self.ip, self.port) )
|
||||
print("Selecting OSC streaming. IP: " + self.ip + ", port: " + str(self.port) + ", address: " + self.address)
|
||||
self.client = udp_client.SimpleUDPClient(self.ip, self.port)
|
||||
|
||||
# From IPlugin: close connections, send message to client
|
||||
def deactivate(self):
|
||||
self.client.send(OSCMessage("/quit") )
|
||||
self.client.send_message("/quit")
|
||||
|
||||
# send channels values
|
||||
def __call__(self, sample):
|
||||
mes = OSCMessage(self.address)
|
||||
mes.append(sample.channel_data)
|
||||
# silently pass if connection drops
|
||||
try:
|
||||
self.client.send(mes)
|
||||
self.client.send_message(self.address, sample.channel_data)
|
||||
except:
|
||||
return
|
||||
|
||||
def show_help(self):
|
||||
print """Optional arguments: [ip [port [address]]]
|
||||
\t ip: target IP address (default: 'localhost')
|
||||
\t port: target port (default: 12345)
|
||||
\t address: select target address (default: '/openbci')"""
|
||||
print("""Optional arguments: [ip [port [address]]]
|
||||
\t ip: target IP address (default: 'localhost')
|
||||
\t port: target port (default: 12345)
|
||||
\t address: select target address (default: '/openbci')""")
|
||||
|
||||
Arquivo normal → Arquivo executável
+8
-8
@@ -51,7 +51,7 @@ class StreamerTCPServer(plugintypes.IPluginExtended):
|
||||
self.port = int(self.args[1])
|
||||
|
||||
# init network
|
||||
print "Selecting raw TCP streaming. IP: ", self.ip, ", port: ", self.port
|
||||
print("Selecting raw TCP streaming. IP: " + self.ip + ", port: " + str(self.port))
|
||||
self.initialize()
|
||||
|
||||
# init the daemon that monitors connections
|
||||
@@ -69,7 +69,7 @@ class StreamerTCPServer(plugintypes.IPluginExtended):
|
||||
# create connection
|
||||
self.server_socket.bind((self.ip, self.port))
|
||||
self.server_socket.listen(1)
|
||||
print "Server started on port " + str(self.port)
|
||||
print("Server started on port " + str(self.port))
|
||||
|
||||
# From Streamer, to be called each time we're willing to accept new connections
|
||||
def check_connections(self):
|
||||
@@ -79,7 +79,7 @@ class StreamerTCPServer(plugintypes.IPluginExtended):
|
||||
# New connection
|
||||
sockfd, addr = self.server_socket.accept()
|
||||
self.CONNECTION_LIST.append(sockfd)
|
||||
print "Client (%s, %s) connected" % addr
|
||||
print("Client (%s, %s) connected" % addr)
|
||||
# and... don't bother with incoming messages
|
||||
|
||||
# From IPlugin: close sockets, send message to client
|
||||
@@ -117,16 +117,16 @@ class StreamerTCPServer(plugintypes.IPluginExtended):
|
||||
# TODO: should check if the correct number of bytes passed through
|
||||
except:
|
||||
# sometimes (always?) it's only during the second write to a close socket that an error is raised?
|
||||
print "Something bad happened, will close socket"
|
||||
print("Something bad happened, will close socket")
|
||||
outdated_list.append(sock)
|
||||
# now we are outside of the main list, it's time to remove outdated sockets, if any
|
||||
for bad_sock in outdated_list:
|
||||
print "Removing socket..."
|
||||
print("Removing socket...")
|
||||
self.CONNECTION_LIST.remove(bad_sock)
|
||||
# not very costly to be polite
|
||||
bad_sock.close()
|
||||
|
||||
def show_help(self):
|
||||
print """Optional arguments: [ip [port]]
|
||||
\t ip: target IP address (default: 'localhost')
|
||||
\t port: target port (default: 12345)"""
|
||||
print("""Optional arguments: [ip [port]]
|
||||
\t ip: target IP address (default: 'localhost')
|
||||
\t port: target port (default: 12345)""")
|
||||
|
||||
Arquivo normal → Arquivo executável
+14
-14
@@ -16,30 +16,30 @@ import plugin_interface as plugintypes
|
||||
# class PluginPrint(IPlugin):
|
||||
# # args: passed by command line
|
||||
# def activate(self, args):
|
||||
# print "Print activated"
|
||||
# print("Print activated")
|
||||
# # tell outside world that init went good
|
||||
# return True
|
||||
|
||||
# def deactivate(self):
|
||||
# print "Print Deactivated"
|
||||
# print("Print Deactivated")
|
||||
|
||||
# def show_help(self):
|
||||
# print "I do not need any parameter, just printing stuff."
|
||||
# print("I do not need any parameter, just printing stuff.")
|
||||
|
||||
# # called with each new sample
|
||||
# def __call__(self, sample):
|
||||
# sample_string = "ID: %f\n%s\n%s" %(sample.id, str(sample.channel_data)[1:-1], str(sample.aux_data)[1:-1])
|
||||
# print "---------------------------------"
|
||||
# print sample_string
|
||||
# print "---------------------------------"
|
||||
# print("---------------------------------")
|
||||
# print(sample_string)
|
||||
# print("---------------------------------")
|
||||
|
||||
# # DEBBUGING
|
||||
# # try:
|
||||
# # sample_string.decode('ascii')
|
||||
# # except UnicodeDecodeError:
|
||||
# # print "Not a ascii-encoded unicode string"
|
||||
# # print("Not a ascii-encoded unicode string")
|
||||
# # else:
|
||||
# # print sample_string
|
||||
# # print(sample_string)
|
||||
|
||||
|
||||
class UDPServer(plugintypes.IPluginExtended):
|
||||
@@ -49,8 +49,8 @@ class UDPServer(plugintypes.IPluginExtended):
|
||||
self.server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
|
||||
def activate(self):
|
||||
print "udp_server plugin"
|
||||
print self.args
|
||||
print("udp_server plugin")
|
||||
print(self.args)
|
||||
|
||||
if len(self.args) > 0:
|
||||
self.ip = self.args[0]
|
||||
@@ -58,11 +58,11 @@ class UDPServer(plugintypes.IPluginExtended):
|
||||
self.port = int(self.args[1])
|
||||
|
||||
# init network
|
||||
print "Selecting raw UDP streaming. IP: ", self.ip, ", port: ", str(self.port)
|
||||
print("Selecting raw UDP streaming. IP: " + self.ip + ", port: " + str(self.port))
|
||||
|
||||
self.server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
|
||||
print "Server started on port " + str(self.port)
|
||||
print("Server started on port " + str(self.port))
|
||||
|
||||
def __call__(self, sample):
|
||||
self.send_data(json.dumps(sample.channel_data))
|
||||
@@ -75,6 +75,6 @@ class UDPServer(plugintypes.IPluginExtended):
|
||||
self.server.close();
|
||||
|
||||
def show_help(self):
|
||||
print """Optional arguments: [ip [port]]
|
||||
print("""Optional arguments: [ip [port]]
|
||||
\t ip: target IP address (default: 'localhost')
|
||||
\t port: target port (default: 12345)"""
|
||||
\t port: target port (default: 12345)""")
|
||||
|
||||
Arquivo normal → Arquivo executável
+1
-1
@@ -1,6 +1,6 @@
|
||||
numpy==1.9.2
|
||||
pylsl==1.10.4
|
||||
pyOSC==0.3.5b-5294
|
||||
python-osc==1.6.3
|
||||
pyserial==2.7
|
||||
requests==2.7.0
|
||||
six==1.9.0
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário