diff --git a/built_in_tasks/target_tracking_task.py b/built_in_tasks/target_tracking_task.py index 0d608265..3876d0b4 100644 --- a/built_in_tasks/target_tracking_task.py +++ b/built_in_tasks/target_tracking_task.py @@ -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() @@ -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): diff --git a/db/html/static/resources/js/report.js b/db/html/static/resources/js/report.js index 3344091e..427ef3c4 100644 --- a/db/html/static/resources/js/report.js +++ b/db/html/static/resources/js/report.js @@ -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); diff --git a/db/runserver.sh b/db/runserver.sh index f866c1f0..5c8a4959 100755 --- a/db/runserver.sh +++ b/db/runserver.sh @@ -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 @@ -88,8 +94,6 @@ 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 @@ -97,7 +101,7 @@ 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 @@ -111,3 +115,5 @@ if [ "$HOST" = "pagaiisland2" ]; then fi wait + +sleep 10 \ No newline at end of file diff --git a/db/tracker/models.py b/db/tracker/models.py index 957c5b6c..27527d16 100644 --- a/db/tracker/models.py +++ b/db/tracker/models.py @@ -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: diff --git a/db/tracker/websocket.py b/db/tracker/websocket.py index ab3c91cc..9c7d3f5b 100644 --- a/db/tracker/websocket.py +++ b/db/tracker/websocket.py @@ -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) diff --git a/features/reward_features.py b/features/reward_features.py index 47e882f7..a5a056de 100644 --- a/features/reward_features.py +++ b/features/reward_features.py @@ -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): diff --git a/riglib/tablet_reward.py b/riglib/tablet_reward.py index df2d0d5a..65ef641a 100644 --- a/riglib/tablet_reward.py +++ b/riglib/tablet_reward.py @@ -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):