updated utils and added README

This commit is contained in:
Chris Midkiff 2020-05-15 14:19:14 -04:00
parent 7ccb087ecd
commit 0356e58416
3 changed files with 26 additions and 9 deletions

14
utils/README.txt Normal file
View File

@ -0,0 +1,14 @@
This a collection of utilites to make running the Fitts Law Experiment software easier. These all require a python3 install.
trialGen.py
This generates trials based on a given number of trials and a number of dots per trial. You can edit your directions and distances in this file as well as what devices you are testing.
Please note that your number of trials times your number of dots per trial must be evenly divisble by the product of your distances and directions. The script will refuse to generate otherwise.
console.py
This communicates with the server and updates the participant ID for a given input device. I recommend running an instance of this for each input device during data collection.
server.py
This requires the python package flask (pip3 install flask).
This serves up the trial files generated by trialGen.py and is used by console.py to update the participant ID.
Simply run with python3 and it will begin running a server on port 5000
Note: The devices running both the software and the console.py script need to have a network connection to wherever this server is running.

View File

@ -1,45 +1,48 @@
from flask import Flask, jsonify, request from flask import Flask, jsonify, request
import json import json
import os
app = Flask(__name__) app = Flask(__name__)
base = os.getcwd()
@app.route('/cardboard') @app.route('/cardboard')
def card(): def card():
data = json.load(open('/home/chris/dev/thesis/cardTrials.json')) data = json.load(open(base + '/cardTrials.json'))
return jsonify(data) return jsonify(data)
@app.route('/cardboardPost', methods=['POST']) @app.route('/cardboardPost', methods=['POST'])
def cardPost(): def cardPost():
id = int(request.args.get('id', '')) id = int(request.args.get('id', ''))
data = json.load(open('/home/chris/dev/thesis/cardTrials.json')) data = json.load(open(base + '/cardTrials.json'))
data['participantId'] = id data['participantId'] = id
json.dump(data,open('/home/chris/dev/thesis/cardTrials.json','w')) json.dump(data,open(base + '/cardTrials.json','w'))
return 'ok ' + str(id) return 'ok ' + str(id)
@app.route('/oculus') @app.route('/oculus')
def oculus(): def oculus():
data = json.load(open('/home/chris/dev/thesis/oculusTrials.json')) data = json.load(open(base + '/oculusTrials.json'))
return jsonify(data) return jsonify(data)
@app.route('/oculusPost',methods=['POST']) @app.route('/oculusPost',methods=['POST'])
def oculusPost(): def oculusPost():
id = int(request.args.get('id', '')) id = int(request.args.get('id', ''))
data = json.load(open('/home/chris/dev/thesis/oculusTrials.json')) data = json.load(open(base + '/oculusTrials.json'))
data['participantId'] = id data['participantId'] = id
json.dump(data,open('/home/chris/dev/thesis/oculusTrials.json','w')) json.dump(data,open(base + '/oculusTrials.json','w'))
return 'ok ' + str(id) return 'ok ' + str(id)
@app.route('/mouse') @app.route('/mouse')
def mouse(): def mouse():
data = json.load(open('/home/chris/dev/thesis/mouseTrials.json')) data = json.load(open(base + '/mouseTrials.json'))
return jsonify(data) return jsonify(data)
@app.route('/mousePost',methods=['POST']) @app.route('/mousePost',methods=['POST'])
def mousePost(): def mousePost():
id = int(request.args.get('id', '')) id = int(request.args.get('id', ''))
data = json.load(open('/home/chris/dev/thesis/mouseTrials.json')) data = json.load(open(base + '/mouseTrials.json'))
data['participantId'] = id data['participantId'] = id
json.dump(data,open('/home/chris/dev/thesis/mouseTrials.json','w')) json.dump(data,open(base + '/mouseTrials.json','w'))
return 'ok ' + str(id) return 'ok ' + str(id)
if __name__ == '__main__': if __name__ == '__main__':