本文整理匯總了Python中pylsl.StreamInlet.close_stream方法的典型用法代碼示例。如果您正苦於以下問題:Python StreamInlet.close_stream方法的具體用法?Python StreamInlet.close_stream怎麽用?Python StreamInlet.close_stream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pylsl.StreamInlet
的用法示例。
在下文中一共展示了StreamInlet.close_stream方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: MyOVBox
# 需要導入模塊: from pylsl import StreamInlet [as 別名]
# 或者: from pylsl.StreamInlet import close_stream [as 別名]
class MyOVBox(OVBox):
def __init__(self):
OVBox.__init__(self)
# the initialize method reads settings and outputs the first header
def initialize(self):
self.initLabel = 0
self.debug=self.setting['debug'] == "true"
print "Debug: ", self.debug
self.stream_type=self.setting['Stream type']
self.stream_name=self.setting['Stream name']
# total channels for all streams
self.channelCount = 0
#self.stream_name=self.setting['Stream name'] # in case !all_streams
print "Looking for streams of type: " + self.stream_type
streams = resolve_stream('type',self.stream_type)
print "Nb streams: " + str( len(streams))
self.nb_streams = len(streams)
if self.nb_streams == 0:
raise Exception("Error: no stream found.")
self.inlet = StreamInlet(streams[0], max_buflen=1)
self.info = self.inlet.info()
self.channelCount = self.info.channel_count()
print "Stream name: " + self.info.name()
stream_freq = self.info.nominal_srate()
if stream_freq != 0:
raise Exception("Error: no irregular stream found.")
# we append to the box output a stimulation header. This is just a header, dates are 0.
self.output[0].append(OVStimulationHeader(0., 0.))
self.init = False
# The process method will be called by openvibe on every clock tick
def process(self):
# A stimulation set is a chunk which starts at current time and end time is the time step between two calls
# init here and filled within triger()
self.stimSet = OVStimulationSet(self.getCurrentTime(), self.getCurrentTime()+1./self.getClock())
if self.init == False :
local_time = local_clock()
initSecond=int(local_time)
initMillis=int((local_time-initSecond)*1000)
self.stimSet.append(OVStimulation(self.initLabel, self.getCurrentTime(), 0.))
self.stimSet.append(OVStimulation(initSecond, self.getCurrentTime(), 0.))
self.stimSet.append(OVStimulation(initMillis, self.getCurrentTime(), 0.))
self.init=True
# read all available stream
samples=[]
sample,timestamp = self.inlet.pull_sample(0)
while sample != None:
samples += sample
sample,timestamp = self.inlet.pull_sample(0)
# every value will be converted to openvibe code and a stim will be create
for label in samples:
label = str(label)
if self.debug:
print "Got label: ", label
self.stimSet.append(OVStimulation(float(label), self.getCurrentTime(), 0.))
# even if it's empty we have to send stim list to keep the rest in sync
self.output[0].append(self.stimSet)
def uninitialize(self):
# we send a stream end.
end = self.getCurrentTime()
self.output[0].append(OVStimulationEnd(end, end))
self.inlet.close_stream()