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: 4 additions & 0 deletions liesl/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ def mock(args):
from liesl.streams.mock import MarkerMock

m = MarkerMock()
elif "gaze" in args.type.lower():
from liesl.streams.mock import GazeMock

m = GazeMock()
else:
from liesl.streams.mock import Mock

Expand Down
41 changes: 41 additions & 0 deletions liesl/streams/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pylsl import StreamInfo, StreamOutlet, local_clock
import threading
from math import sin, pi
from numpy.random import normal

# %%
class DescriptionlessMock(threading.Thread):
Expand Down Expand Up @@ -158,3 +159,43 @@ def run(self):
outlet.push_sample(sample, tstamp)
time.sleep(rand())

class GazeMock(Mock):
def __init__(
self,
name="Liesl-Mock-Gaze",
type="Gaze",
channel_count=2,
nominal_srate=60,
channel_format="double64",
source_id=None,
verbose=True,
):

threading.Thread.__init__(self)

if source_id == None:
source_id = str(hash(self))

self.info = StreamInfo(
name, type, channel_count, nominal_srate, channel_format, source_id
)
self.channel_count = channel_count
self.verbose = verbose
self.fs = nominal_srate

def genarate_gaze(self):
while True:
yield [normal(500,10), normal(780,20)]

def run(self):
self.is_running = True
print("now sending data...")
outlet = StreamOutlet(self.info)
gazes = self.genarate_gaze()
while self.is_running:
sample = next(gazes)
tstamp = local_clock()
if self.verbose:
print(f"Pushed {sample} at {tstamp}")
outlet.push_sample(sample, tstamp)
time.sleep(rand()/self.fs)