def monitor(self): experiment_folder = '.' # open connections context = zmq.Context() for a in self.atm_config['arenas']: socket = context.socket(zmq.REQ) socket.connect(self.worker_address_client_side(a['core'])) a['socket_core'] = socket socket = context.socket(zmq.REQ) socket.connect(self.worker_address_client_side(a['leaf'])) a['socket_leaf'] = socket # wait for all them to initialize for a in self.atm_config['arenas']: for sn in ['socket_core', 'socket_leaf']: zmq_sock_utils.send_recv(a[sn], [airflow_test_1_worker.INITIALIZE]) # tell the user to put bees print('Put bees in the arena and press ENTER') raw_input('> ') # record video number_frames = self.atm_config['video']['frames_per_second'] * ( self.atm_config['parameters']['first_period_length'] + self.atm_config['parameters']['airflow_duration'] + self.atm_config['parameters']['third_period_length']) process_recording = domset_binary.manager.util.record_video_gstreamer( os.path.join(experiment_folder, 'video.avi'), number_frames, self.atm_config['video']['frames_per_second'], self.atm_config['video']['crop_left'], self.atm_config['video']['crop_right'], self.atm_config['video']['crop_top'], self.atm_config['video']['crop_bottom']) # tell each arena to do the temperature profile for a in self.atm_config['arenas']: print( 'Starting temperature profile for arena with CASUs {} and {}'. format(a['core'], a['leaf'])) self.atm_config['parameters'][0] = airflow_test_1_worker.START_CORE zmq_sock_utils.send(a['socket_core'], self.atm_config['parameters']) self.atm_config['parameters'][0] = airflow_test_1_worker.START_LEAF zmq_sock_utils.send(a['socket_leaf'], self.atm_config['parameters']) for a in self.atm_config['arenas']: print( 'Waiting for temperature profile in arena with CASUs {} and {} to finish' .format(a['core'], a['leaf'])) zmq_sock_utils.recv(a['socket_core']) zmq_sock_utils.recv(a['socket_leaf']) # finish process_recording.wait() print('Close the window titled "{} deploy"'.format(self.project))
def terminate_session(self): """ Terminate the session with the worker, which causes the worker process to finish. """ print( "Sending terminate command to worker responsible for casu #%d..." % (self.casu_number)) answer = zmq_sock_utils.send_recv(self.socket, [worker.TERMINATE]) print("Worker responded with: %s" % (str(answer)))
def monitor(self): experiment_folder = '.' fdw = open('infrared-test-manager.log', 'w') # open connections context = zmq.Context() for a in self.atm_config['arenas']: for k in ['A', 'B']: socket = context.socket(zmq.REQ) socket.connect(self.worker_address_client_side(a[k])) a['s' + k] = socket # wait for all them to initialize for a in self.atm_config['arenas']: for sn in ['sA', 'sB']: zmq_sock_utils.send_recv(a[sn], [infrared_test_worker.INITIALIZE]) fdw.write('{} all workers are ready\n'.format(time.time())) # record background video print('Press ENTER to record a background video') raw_input('> ') number_frames = self.atm_config['video'][ 'frames_per_second'] * BACKGROUND_VIDEO_LENGTH fdw.write('{} launching background video recording\n'.format( time.time())) util.video.record_video_gstreamer( os.path.join(experiment_folder, 'background.avi'), number_frames, self.atm_config['video']['frames_per_second'], self.atm_config['video']['crop_left'], self.atm_config['video']['crop_right'], self.atm_config['video']['crop_top'], self.atm_config['video']['crop_bottom']) # tell the user to put bees print('Put bees in the arena and press ENTER') raw_input('> ') # record video number_frames = self.atm_config['video'][ 'frames_per_second'] * self.atm_config['parameters'][ 'experiment_duration'] * 60 fdw.write('{} launching experiment video recording\n'.format( time.time())) process_recording = util.video.record_video_gstreamer( os.path.join(experiment_folder, 'video.avi'), number_frames, self.atm_config['video']['frames_per_second'], self.atm_config['video']['crop_left'], self.atm_config['video']['crop_right'], self.atm_config['video']['crop_top'], self.atm_config['video']['crop_bottom'], async=True) # tell each arena to do the temperature profile self.atm_config['parameters'][0] = infrared_test_worker.START for a in self.atm_config['arenas']: print('Starting infrared hit test for arena with CASUs {} and {}'. format(a['A'], a['B'])) for sn in ['sA', 'sB']: fdw.write('{} send START command to CASU {}\n'.format( time.time(), a[sn[1]])) zmq_sock_utils.send(a[sn], self.atm_config['parameters']) for a in self.atm_config['arenas']: print( 'Waiting for infrared hit test in arena with CASUs {} and {} to finish\n' .format(a['A'], a['B'])) zmq_sock_utils.recv(a['sA']) fdw.write('{} receive START response from CASU {}\n'.format( time.time(), a['A'])) zmq_sock_utils.recv(a['sB']) fdw.write('{} receive START response from CASU {}\n'.format( time.time(), a['B'])) # finish process_recording.wait() fdw.write('{} experiment video recording finished\n'.format( time.time())) print('Close the window titled "{} deploy"'.format(self.project)) fdw.close()
def initialize(self): print( "Sending initialize DOMSET command to worker responsible for casu #%d..." % (self.casu_number)) answer = zmq_sock_utils.send_recv(self.socket, [worker.INITIALIZE]) print("Worker responded with: %s" % (str(answer)))