def main(rtc_file_name, casu_number, worker_address): import domset_interspecies # open ZMQ server socket context = zmq.Context() socket = context.socket(zmq.REP) socket.bind(worker_address) # Initialize domset algorithm ctrl = domset_interspecies.DomsetController(rtc_file_name, log=True) ctrl.calibrate_ir_thresholds() ctrl.initialize_temperature() ctrl.initial_wait() # main thread loop go = True while go: message = zmq_sock_utils.recv(socket) if message[0] == START: ctrl.start() zmq_sock_utils.send(socket, [OK]) elif message[0] == TERMINATE: go = False ctrl.stop = True zmq_sock_utils.send(socket, [OK]) else: print('Unknown message {}'.format(message)) ctrl.join() print('End of worker for CASU {}'.format(casu_number))
def main(rtc_file_name, casu_number, worker_address): import zmq_sock_utils print('[I] Main function for CASU {}'.format(casu_number)) # open ZMQ server socket context = zmq.Context() socket = context.socket(zmq.REP) print('[I] Binding to {}'.format(worker_address)) socket.bind(worker_address) # Initialize domset algorithm a_casu = casu.Casu(rtc_file_name, log=True) # main thread loop go = True print('[I] Entering main loop for CASU {}'.format(casu_number)) while go: message = zmq_sock_utils.recv(socket) if message[0] == INITIALIZE: print('[I] Initialize message for CASU {}'.format(casu_number)) zmq_sock_utils.send(socket, [OK]) elif message[0] == START: print('[I] Start message for CASU {}'.format(casu_number)) infrared_hit( casu=a_casu, temperature_reference=message['temperature_reference'], experiment_duration=message['experiment_duration'], ) go = False zmq_sock_utils.send(socket, [OK]) else: print('Unknown message {}'.format(message)) a_casu.stop() print('[I] End of worker for CASU {}'.format(casu_number))
def main(rtc_file_name, casu_number, worker_address): import zmq_sock_utils print('[I] Main function for CASU {}'.format(casu_number)) # open ZMQ server socket context = zmq.Context() socket = context.socket(zmq.REP) print('[I] Binding to {}'.format(worker_address)) socket.bind(worker_address) # Initialize domset algorithm a_casu = casu.Casu(rtc_file_name, log=True) # main thread loop go = True print('[I] Entering main loop for CASU {}'.format(casu_number)) while go: message = zmq_sock_utils.recv(socket) if message[0] == INITIALIZE: print('[I] Initialize message for CASU {}'.format(casu_number)) zmq_sock_utils.send(socket, [OK]) elif message[0] == START_LEAF: print('[I] Start leaf message for CASU {}'.format(casu_number)) temperature_profile_leaf( casu=a_casu, initial_temperature=message['temperature_reference'], first_period_length=message['first_period_length'], rate_temperature_increase=message[ 'rate_temperature_increase_leaf'], target_temperature=message['target_temperature'], airflow_duration=message['airflow_duration'], third_period_length=message['third_period_length']) go = False zmq_sock_utils.send(socket, [OK]) elif message[0] == START_CORE: print('[I] Start core message for CASU {}'.format(casu_number)) temperature_profile_core( casu=a_casu, initial_temperature=message['temperature_reference'], first_period_length=message['first_period_length'], rate_temperature_increase=message[ 'rate_temperature_increase_core'], target_temperature=message['target_temperature'], airflow_duration=message['airflow_duration'], rate_temperature_decrease=message['rate_temperature_decrease'], third_period_length=message['third_period_length']) zmq_sock_utils.send(socket, [OK]) go = False else: print('Unknown message {}'.format(message)) a_casu.stop() print('[I] End of worker for CASU {}'.format(casu_number))
def main (rtc_file_name, casu_number, worker_address): import zmq_sock_utils print ('[I] Main function for CASU {}'.format (casu_number)) # open ZMQ server socket context = zmq.Context () socket = context.socket (zmq.REP) print ('[I] Binding to {}'.format (worker_address)) socket.bind (worker_address) # Initialize domset algorithm ctrl = DomsetController (rtc_file_name) ctrl.calibrate_ir_thresholds (500, 1) ctrl.initialize_temperature () # main thread loop go = True print ('[I] Entering main loop for CASU {}'.format (casu_number)) while go: message = zmq_sock_utils.recv (socket) if message [0] == INITIALIZE: print ('[I] Initialize message for CASU {}'.format (casu_number)) zmq_sock_utils.send (socket, [OK]) elif message [0] == START_LEAF: print ('[I] Start leaf message for CASU {}'.format (casu_number)) temperature_profile_leaf ( controller = ctrl, first_period_length = message ['first_period_length'], airflow_duration = message ['airflow_duration'], third_period_length = message ['third_period_length'], time_adjustment = message ['time_adjustment'], ) go = False zmq_sock_utils.send (socket, [OK]) elif message [0] == START_CORE: print ('[I] Start core message for CASU {}'.format (casu_number)) temperature_profile_core ( controller = ctrl, first_period_length = message ['first_period_length'], rate_temperature_increase = message ['rate_temperature_increase_core'], node_size = message ['core_node_size'], airflow_duration = message ['airflow_duration'], third_period_length = message ['third_period_length'] ) zmq_sock_utils.send (socket, [OK]) go = False else: print ('Unknown message {}'.format (message)) ctrl.casu.stop () print ('[I] End of worker for CASU {}'.format (casu_number))
def main (rtc_file_name, casu_number, worker_address): import video_sync import zmq_sock_utils print ('[I] Main function for CASU {}'.format (casu_number)) # open ZMQ server socket context = zmq.Context () socket = context.socket (zmq.REP) socket.bind (worker_address) # Initialize domset algorithm ctrl = DomsetController (rtc_file_name, log=True) # main thread loop go = True print ('[I] Entering main loop for CASU {}'.format (casu_number)) while go: message = zmq_sock_utils.recv (socket) if message [0] == INITIALIZE: print ('[I] Initialize message for CASU {}'.format (casu_number)) zmq_sock_utils.send (socket, [OK]) elif message [0] == IR_CALIBRATION: print ('[I] Infrared calibration message for CASU {}'.format (casu_number)) ctrl.calibrate_ir_thresholds (500, 1) ctrl.initialize_temperature () #ctrl.initial_wait (duration = 60) zmq_sock_utils.send (socket, [OK]) elif message [0] == START: print ('[I] Start message for CASU {}'.format (casu_number)) video_sync.flash_casu (ctrl.casu) ctrl.start () zmq_sock_utils.send (socket, [OK]) elif message [0] == TERMINATE: print ('[I] Terminate message for CASU {}'.format (casu_number)) go = False ctrl.stop = True zmq_sock_utils.send (socket, [OK]) else: print ('Unknown message {}'.format (message)) ctrl.join () ctrl.casu.stop () print ('[I] End of worker for CASU {}'.format (casu_number))