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
2 changes: 2 additions & 0 deletions built_in_tasks/target_tracking_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ def _while_tracking_in(self):
# Check if the trial is over and there are no more target frames to display
if self.frame_index+self.lookahead >= np.shape(self.targs)[0]:
self.trial_timed_out = True


def _start_tracking_out(self):
super()._start_tracking_out()
Expand All @@ -685,6 +686,7 @@ def _while_tracking_out(self):

# Check if the trial is over and there are no more target frames to display
if self.frame_index+self.lookahead >= np.shape(self.targs)[0]:
cursor_pos = [5., 5., -8.]
self.trial_timed_out = True

def _start_timeout_penalty(self):
Expand Down
2 changes: 1 addition & 1 deletion db/html/static/resources/js/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Report.prototype.activate = function() {
//var on_windows = window.navigator.userAgent.indexOf("Windows") > 0;
if (!this.ws) { // && !on_windows) { some websocket issues on windows..
// Create a new JS WebSocket object
this.ws = new WebSocket("ws://"+hostname.split(":")[0]+":8001/connect");
this.ws = new WebSocket("ws://"+hostname.split(":")[0]+":8001/connect"); // hostname.split(":")[1] + 1 (end of hostname should be either 8000 or 8002)

this.ws.onmessage = function(evt) {
debug(evt.data);
Expand Down
12 changes: 9 additions & 3 deletions db/runserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ elif [ "$HOST" = "pagaiisland-surface" ]; then
export DISPLAY=localhost:0
export LIBGL_ALWAYS_INDIRECT=0
echo "success"
elif [ "$HOST" = "booted-server" ]; then # this is Churro computer
# set DISPLAY var based on BMI3D_PORT var
export DISPLAY=':1'
Xvnc :1 -securityTypes None -geometry 1920x1080 -nocursor & # replace :1 with DISPLAY
eval "$(conda shell.bash hook)"
conda activate bmi3d # may not work? remove?
fi

# Find the BMI3D directory
Expand Down Expand Up @@ -88,16 +94,14 @@ git --git-dir=$BMI3D/.git --work-tree=$BMI3D status >> $BMI3D/log/runserver_log
# Activate the relevant environment
if test -f "$BMI3D/env/bin/activate"; then
source $BMI3D/env/bin/activate
else
echo "No environment found."
fi

trap "exit" INT TERM ERR
trap "kill 0" EXIT

# Start python processes
cd $BMI3D
python manage.py runserver 0.0.0.0:8000 --noreload &
python manage.py runserver 0.0.0.0:8000 --noreload & # if BMI3D_PORT exists, use it instead
if [ "$HOST" = "pagaiisland2" ]; then
celery -A db.tracker worker -l INFO &
fi
Expand All @@ -111,3 +115,5 @@ if [ "$HOST" = "pagaiisland2" ]; then
fi

wait

sleep 10
8 changes: 7 additions & 1 deletion db/tracker/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,13 @@ def desc(self):
params = json_param.Parameters(self.params)

if self.report is not None and len(self.report) > 0:
report_data = json.loads(self.report)
try:
report_data = json.loads(self.report)
except:
print(self.id)
print("THIS TE IS BROKEN <--")
report_data = None

else:
report_data = None
try:
Expand Down
6 changes: 5 additions & 1 deletion db/tracker/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ def run(self):

import asyncio
asyncio.set_event_loop(asyncio.new_event_loop())

if os.environ.get('BMI3D_PORT') is not None: # set BMI3D_PORT to 8000 or 8002 in two separate shortcut scripts, one per tablet
application.listen(int(os.environ.get('BMI3D_PORT')) + 1)
else:
application.listen(8001)

application.listen(8001)
self.ioloop = tornado.ioloop.IOLoop.current()
self.ioloop.add_handler(self._pipe, self._send, self.ioloop.READ)
self.ioloop.add_handler(self._outp, self._stdout, self.ioloop.READ)
Expand Down
4 changes: 3 additions & 1 deletion features/reward_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ class PelletReward(RewardSystem):
'''

'''
# rewards_per_trial = traits.Int(1, desc='Number of reward pellets per successful trial')
# tablet_name = traits.Float(1, desc='Number of successful trials before solenoid is opened') # dropdown menu with booted-1 and booted-2 as options

def __init__(self, *args, **kwargs):
from riglib.tablet_reward import RemoteReward
super(RewardSystem, self).__init__(*args, **kwargs)
self.reward = RemoteReward()
self.reward = RemoteReward(self.tablet_name)
self.reportstats['Reward #'] = 0

def _start_reward(self):
Expand Down
8 changes: 6 additions & 2 deletions riglib/tablet_reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ def open():
import requests
class RemoteReward():

def __init__(self):
def __init__(self, tablet_name):

if tablet_name == 'booted-1':
self.hostName = "192.168.0.200"
elif tablet_name == 'booted-2':
# set self.hostName according to little tablet 2 address on router, maybe need to ask Leo/Drew to set?

self.hostName = "192.168.0.200"
self.serverPort = 8080

def trigger(self):
Expand Down