Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Software Marker Widget #1174

Merged
merged 19 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
4303a75
Add W_Marker widget and a few base methods
retiutut Aug 2, 2023
13de3f7
Add insertMarker and getMarkerChannel methods to all relevant boards
retiutut Aug 3, 2023
482195f
Add time series to Marker Widget
retiutut Aug 4, 2023
0de3b4d
Fix non final variable due to scope in Marker widget
retiutut Aug 4, 2023
2c034cd
Add ability to playback marker data in Marker Widget
retiutut Aug 4, 2023
9e96344
Add more Marker keyboard shortcuts and remove s, b, and d shortcuts
retiutut Aug 4, 2023
bc8e2c9
Add Marker data type to networking output
retiutut Aug 4, 2023
08e9ef5
Update marker widget button positions using Grid class
retiutut Aug 10, 2023
f42f970
Add test for receiving Markers over UDP
retiutut Aug 14, 2023
690c0d8
Remove sampling rate check in sendMarkerData in Networking
retiutut Aug 14, 2023
05371a9
Add Marker Widget to Session settings and account for UI overlapping
retiutut Aug 14, 2023
3deb1a3
Add udp marker receiver to Marker widget
retiutut Aug 14, 2023
9eaf884
Update Marker Widget UI to improve UDP receiver textfield appearance
retiutut Aug 15, 2023
ac27e49
Update Marker Widget Vert Scale UI and show all 8 buttons always
retiutut Aug 15, 2023
254a705
Fix non-final variable in local scope in Marker Widget createTextfield
retiutut Aug 15, 2023
78eff9d
Update version to v6.0.0-alpha.1 and update changelog
retiutut Aug 15, 2023
d9b1221
Update line endings for certain files
retiutut Aug 16, 2023
2e7492e
Remove unnecessary comments left in from debugging
retiutut Aug 16, 2023
7987509
Add autoscale option to marker widget
retiutut Aug 27, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Improvements
- Update repository to Processing 4.2 #1111
- Add Software Marker Widget #1091

# v5.2.1

Expand Down
4 changes: 3 additions & 1 deletion Networking-Test-Kit/LSL/lslStreamTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ def testLSLSamplingRate():
# print( len(chunk) )
totalNumSamples += len(chunk)
# print(chunk)
i = 0
for sample in chunk:
print(sample)
print(sample, timestamp[i])
validSamples += 1
i += 1

print( "Number of Chunks and Samples == {} , {}".format(numChunks, totalNumSamples) )
print( "Valid Samples and Duration == {} / {}".format(validSamples, duration) )
Expand Down
109 changes: 109 additions & 0 deletions Networking-Test-Kit/UDP/udp_receive_marker.py
retiutut marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import socket
import sys
import time
import argparse
import signal
import struct
import os
import json

numSamples = 0

# Print received message to console
def print_message(*args):
try:
#print(args[0]) #added to see raw data
obj = json.loads(args[0].decode())
print(obj.get('data'))
num_samples_packet = len(obj.get('data'))
global numSamples
print("NumSamplesInPacket_Marker == " + str(num_samples_packet))
numSamples += num_samples_packet
if obj:
return True
else:
return False
except BaseException as e:
print(e)
return False
# print("(%s) RECEIVED MESSAGE: " % time.time() +
# ''.join(str(struct.unpack('>%df' % int(length), args[0]))))

# Clean exit from print mode
def exit_print(signal, frame):
print("Closing listener")
sys.exit(0)

# Record received message in text file
def record_to_file(*args):
textfile.write(str(time.time()) + ",")
#textfile.write(args[0])
obj = json.loads(args[0].decode())
#print(obj.get('data'))
textfile.write(json.dumps(obj))
textfile.write("\n")

# Save recording, clean exit from record mode
def close_file(*args):
print("\nFILE SAVED")
textfile.close()
sys.exit(0)

if __name__ == "__main__":
# Collect command line arguments
parser = argparse.ArgumentParser()
parser.add_argument("--ip",
default="127.0.0.1", help="The ip to listen on")
parser.add_argument("--port",
type=int, default=12345, help="The port to listen on")
parser.add_argument("--address",default="/openbci", help="address to listen to")
parser.add_argument("--option",default="print",help="Debugger option")
parser.add_argument("--len",default=9,help="Debugger option")
args = parser.parse_args()

# Set up necessary parameters from command line
length = int(args.len)
if args.option=="print":
signal.signal(signal.SIGINT, exit_print)
elif args.option=="record":
i = 0
while os.path.exists("udp_test%s.txt" % i):
i += 1
filename = "udp_test%i.txt" % i
textfile = open(filename, "w")
textfile.write("time,address,messages\n")
textfile.write("-------------------------\n")
print("Recording to %s" % filename)
signal.signal(signal.SIGINT, close_file)

# Connect to socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_address = (args.ip, args.port)
sock.bind(server_address)

# Display socket attributes
print('--------------------')
print("-- UDP LISTENER -- ")
print('--------------------')
print("IP:", args.ip)
print("PORT:", args.port)
print('--------------------')
print("%s option selected" % args.option)

# Receive messages
print("Listening...")
start = time.time()

duration = 10
while time.time() <= start + duration:
data, addr = sock.recvfrom(20000) # buffer size is 20000 bytes
if args.option=="print":
print_message(data)
elif args.option=="record":
record_to_file(data)
numSamples += 1

print( "Samples == {}".format(numSamples) )
print( "Duration == {}".format(duration) )
print( "Avg Sampling Rate == {}".format(numSamples / duration) )
42 changes: 42 additions & 0 deletions Networking-Test-Kit/UDP/udp_send_marker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import socket
import random
import struct
import time
import argparse

if __name__ == "__main__":

test_duration = 10

# Collect command line arguments
parser = argparse.ArgumentParser()
parser.add_argument("--ip", default="127.0.0.1",
help="The ip of the OSC server")
parser.add_argument("--port", type=int, default=12350,
help="The port the OSC server is sending to")
args = parser.parse_args()
retiutut marked this conversation as resolved.
Show resolved Hide resolved

# Establish UDP socket
UDP_IP = args.ip
UDP_PORT = args.port
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP

# Display socket attributes
print('---------------------')
print("-- UDP MARKER SEND -- ")
print('---------------------')
print("IP:", args.ip)
print("PORT:", args.port)
print('--------------------=')

# Send test data
start = time.time()
while time.time() <= start + test_duration:
# generate random float
marker = random.uniform(0, 4)
# package as byte array
msg = struct.pack('!d', marker)
# send through socket
sock.sendto(msg, (UDP_IP, UDP_PORT))
time.sleep(.25)
Loading