def set_values(self): value1 = int(self.inj_entries[0].get()) value2 = int(self.inj_entries[1].get()) value3 = int(self.inj_entries[2].get()) value4 = int(self.inj_entries[3].get()) packet1 = [ u.COMMAND_SCAN, SCAN_SET_DATA, 1, value1, 0, "Set SCN Data Value", "Y" ] err_flag, reply1 = u.send_command(u.Crate_INJ, packet1) if err_flag == u.SOCK_OK: print("Writing new SCAN set point " + str(value1) + " to data 1") else: print(" check_status: ERROR, Could not access socket.") return packet2 = [ u.COMMAND_SCAN, SCAN_SET_DATA, 2, value2, 0, "Set SCN Data Value", "Y" ] err_flag, reply2 = u.send_command(u.Crate_INJ, packet2) if err_flag == u.SOCK_OK: print("Writing new SCAN set point " + str(value2) + " to data 2") else: print(" check_status: ERROR, Could not access socket.") return packet3 = [ u.COMMAND_SCAN, SCAN_SET_DATA, 3, value3, 0, "Set SCN Data Value", "Y" ] err_flag, reply3 = u.send_command(u.Crate_INJ, packet3) if err_flag == u.SOCK_OK: print("Writing new SCAN set point " + str(value3) + " to data 3") else: print(" check_status: ERROR, Could not access socket.") return packet4 = [ u.COMMAND_SCAN, SCAN_SET_DATA, 4, value4, 0, "Set SCN Data Value", "Y" ] err_flag, reply4 = u.send_command(u.Crate_INJ, packet4) if err_flag == u.SOCK_OK: print("Writing new SCAN set point " + str(value4) + " to data 4") else: print(" check_status: ERROR, Could not access socket.") return self.check_values()
def toggle(self): state = send_command('status')['status'] if 'close' in state: state = send_command('open')['status'] else: state = send_command('close')['status'] return redirect(url_for('admin.index'))
def check_values_inj(self): packet1 = [ u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_RD, 0, 0, "TB Get Data", "Y" ] err_flag, reply1 = u.send_command(u.Crate_INJ, packet1) print("I am here where you thought I was") print("COMMAND_HAPTB is " + str(u.COMMAND_HAPTB)) print("cfSockCommand returned : " + str(err_flag)) if err_flag == u.SOCK_OK: CurrentRD = int(reply1[3]) self.inj_ramp_delay_e.delete(0, tk.END) self.inj_ramp_delay_e.insert(0, str(CurrentRD)) print("Ramp delay is " + str(CurrentRD)) else: print("ERROR, Could not access socket.") return packet2 = [ u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_IT, 0, 0, "TB Get Data", "Y" ] err_flag, reply2 = u.send_command(u.Crate_INJ, packet2) if err_flag == u.SOCK_OK: CurrentIT = int(reply2[3]) self.inj_int_time_e.delete(0, tk.END) self.inj_int_time_e.insert(0, str(CurrentIT)) print("Integration time is " + str(CurrentIT)) else: print("ERROR, Could not access socket.") return packet3 = [ u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_OS, 0, 0, "TB Get Data", "Y" ] err_flag, reply3 = u.send_command(u.Crate_INJ, packet3) if err_flag == u.SOCK_OK: CurrentOS = int(reply3[3]) self.inj_oversamp_e.delete(0, tk.END) self.inj_oversamp_e.insert(0, str(CurrentOS)) print("Oversampling is " + str(CurrentOS)) else: print("ERROR, Could not access socket.") return
def set_kill(self): bmw_running, kill_switch = self.check_status() if not kill_switch: packet = [u.COMMAND_BMW, KILL, 0, 0, 0, 'BMW set kill', 'Y'] err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: print(tab_title + ' set_kill: BMW kill switch call is complete.') else: print(tab_title + ' set_kill: ERROR, Could not access socket.') self.check_status() else: packet = [u.COMMAND_BMW, UNKILL, 0, 0, 0, 'BMW lift kill', 'Y'] err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: print(tab_title + ' set_kill: BMW unkill switch call is complete.') else: print(tab_title + ' set_kill: ERROR, Could not access socket.') self.check_status()
def check_status(self): packet = [u.COMMAND_BMW, GET_STATUS, 0, 0, 0, "BMW status check", "Y"] err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: bmw_running = bool(reply[2]) print(tab_title + " check_status: bmw_running = " + str(bmw_running)) kill_switch = bool(reply[3]) print(tab_title + " check_status: kill_switch = " + str(kill_switch)) if kill_switch: self.ks_bm_l['text'] = 'Kill Switch is ON' else: self.ks_bm_l['text'] = 'Kill Switch is OFF' if bmw_running: self.status_bm_l['text'] = 'Beam Modulation is ON' self.bm_button['text'] = 'Set Kill Switch' else: self.status_bm_l['text'] = 'Beam Modulation is OFF' self.bm_button['text'] = 'Start Beam Modulation' return bmw_running, kill_switch else: print(tab_title + " check_status: ERROR, Could not access socket.") return False, False
def slack_update_door(): before_request() action = if_toggle(request.form.get('text')) if action in supported_actions: return 'The door is ' + send_command(action)['status'] + '!' else: return "This command " + action + " is not supported!"
def update_door(): before_request() action = if_toggle(request.get_json(force=True)['action']) if action in supported_actions: return jsonify(send_command(action)) else: return jsonify({'error': 'command: ' + action + ' unknown'})
def config_worker(request): """对worker进行配置管理 """ url_action = request.params.get('action','') dispatcher_config = ztq_core.get_dispatcher_config() worker_weight = dispatcher_config['worker_weight'] # 获取用户请求操作 worker_id = request.matchdict['id'] # 根据操作类型进行权重调整, if url_action == 'stop_worker': #停止worker worker_weight[worker_id] = 0 elif url_action == 'enable': #启用worker worker_weight[worker_id] = 5 elif url_action == 'worker_down' : #降低worker权重 worker_weight[worker_id] -= 1 if worker_weight[worker_id] < 1: worker_weight[worker_id] = 1 elif url_action == 'worker_up' : #提升worker权重 worker_weight[worker_id] += 1 if worker_weight[worker_id] >10: worker_weight[worker_id] = 10 elif url_action == 'delete': #删除还没启用的worker,删除操作不会导致调度配置更新 if worker_id in worker_weight: # 没有启用的情况 worker_weight.pop(worker_id) workers_dict = ztq_core.get_worker_state() del workers_dict[worker_id] worker_job = ztq_core.get_job_state(worker_id) for job_name, job_status in worker_job.items(): del worker_job[job_name] ztq_core.set_dispatcher_config(dispatcher_config) return HTTPFound(location = '/workerstatus') elif url_action == 'update': # 发报告指令到各命令队列让worker报告自身状态 worker_list = ztq_core.get_all_worker() for worker_name in worker_list: if worker_name == worker_id: utils.send_command(worker_name, 'report') time.sleep(1) return HTTPFound(location = '/workerstatus') # 更新调度策略并进行调度 ztq_core.set_dispatcher_config(dispatcher_config) utils.dispatch() return HTTPFound(location = '/workerstatus')
def config_worker(request): """对worker进行配置管理 """ url_action = request.params.get('action', '') dispatcher_config = ztq_core.get_dispatcher_config() worker_weight = dispatcher_config['worker_weight'] # 获取用户请求操作 worker_id = request.matchdict['id'] # 根据操作类型进行权重调整, if url_action == 'stop_worker': #停止worker worker_weight[worker_id] = 0 elif url_action == 'enable': #启用worker worker_weight[worker_id] = 5 elif url_action == 'worker_down': #降低worker权重 worker_weight[worker_id] -= 1 if worker_weight[worker_id] < 1: worker_weight[worker_id] = 1 elif url_action == 'worker_up': #提升worker权重 worker_weight[worker_id] += 1 if worker_weight[worker_id] > 10: worker_weight[worker_id] = 10 elif url_action == 'delete': #删除还没启用的worker,删除操作不会导致调度配置更新 if worker_id in worker_weight: # 没有启用的情况 worker_weight.pop(worker_id) workers_dict = ztq_core.get_worker_state() del workers_dict[worker_id] worker_job = ztq_core.get_job_state(worker_id) for job_name, job_status in worker_job.items(): del worker_job[job_name] ztq_core.set_dispatcher_config(dispatcher_config) return HTTPFound(location='/workerstatus') elif url_action == 'update': # 发报告指令到各命令队列让worker报告自身状态 worker_list = ztq_core.get_all_worker() for worker_name in worker_list: if worker_name == worker_id: utils.send_command(worker_name, 'report') time.sleep(1) return HTTPFound(location='/workerstatus') # 更新调度策略并进行调度 ztq_core.set_dispatcher_config(dispatcher_config) utils.dispatch() return HTTPFound(location='/workerstatus')
def check_values(self): fSample = [] fGain = [] fConvGain = [] fDAC = [] value = numADC i = 0 while i < value: packet = [u.COMMAND_HAPADC, HAPADC_GET_CSR, i, 0, 0, "ADC18 Get Sample", "Y"] err_flag, reply = u.send_command(u.Crate_RHRS, packet) if err_flag == u.SOCK_OK: if reply[3] == -1: fGain.append(-1) fDAC.append(-1) if ((reply[3] & 0x10)==16): fGain.append(GAINHI) else: fGain.apemd(GAINLO) if ((reply[3] & 0x8)==8): fDAC.append(DACON) else: fDAC.append(DACOFF) fSample.append(reply[3]) self.sample_settings[i].set(reply[3]) else: print("ERROR, Could not access socket.") return -1 packet = [u.COMMAND_HAPADC, ADC18_GET_INT, i, 0, 0, "ADC18 Get Int", "Y"] err_flag, reply = u.send_command(u.Crate_RHRS, packet) if err_flag == u.SOCK_OK: fIntGain.append(reply[3]) self.int_es[i].delete(0, tk.END) self.int_es[i].insert(0, str(reply[3])) else: print("ERROR, Could not access socket.") return -1 i += 1
def start_test(self): packet = [u.COMMAND_BMW, START, 0, 0, 0, "BMW Start Test", "Y"] err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: packet[0] = reply[0] self.test_step() else: print(tab_title + " start_test: ERROR, Could not access socket.")
def check_active_flag(self): active = False packet = [u.COMMAND_BMW, CHECK_ALIVE, 0, 0, 0, 'BMW status check', 'Y'] err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: active = bool(reply[3]) if active: self.script_bm_l['text'] = 'Beam Modulation script is ON' else: self.script_bm_l['text'] = 'Beam Modulation script is OFF' else: print(tab_title + ' check_active_flag: ERROR, Could not access socket.')
def get_label_adc(self, index): packet = [u.COMMAND_HAPADC, HAPADC_GET_LABEL, index, 0, 0, "ADC Get Label", "Y"] err_flag, reply = u.send_command(u.Crate_RHRS, packet) if err_flag == u.SOCK_OK: return int(reply[3]) else: print("ERROR, Could not access socket.") return -1
def get_num_adc(self): packet = [u.COMMAND_HAPADC, HAPADC_GET_NUMADC, 0, 0, 0, "ADC Get Number", "Y"] err_flag, reply = u.send_command(u.Crate_RHRS, packet) if err_flag == u.SOCK_OK: return int(reply[3]) else: print("ERROR, Could not access socket.") return -1
def test_step(self): value = int(self.test_e.get()) print(" " + tab_title + " Writing new set point: " + self.test_e.get() + " to " + self.button_titles[self.bm_test_index.get()]) packet = [u.COMMAND_BMW, TEST_SET_DATA, self.bm_test_index.get(), value, 0, "BMW Start Test Data", "Y"] err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: kill_switch = reply[2] if not kill_switch: self.start_time = time.perf_counter() else: print(tab_title + " test_step: ERROR, Could not access socket.")
def check_values_rt_spec(self): packet1 = [u.COMMAND_VQWK, VQWK_GET_DATA, VQWK_SPB, 0, 0, "VQWK Get Data", "Y"] err_flag, reply1 = u.send_command(u.Crate_RHRS, packet1) print("COMMAND_VQWK is " + str(u.COMMAND_VQWK)) print("cfSockCommand returned : " + str(err_flag)) if err_flag == u.SOCK_OK: CurrentSPB = int(reply1[3]) self.samples_rt_spec_e.delete(0, tk.END) self.samples_rt_spec_e.insert(0, str(CurrentSPB)) else: print("ERROR, Could not access socket.") return packet2 = [u.COMMAND_VQWK, VQWK_GET_DATA, VQWK_GD, 0, 0, "VQWK Get Data", "Y"] err_flag, reply2 = u.send_command(u.Crate_RHRS, packet2) if err_flag == u.SOCK_OK: CurrentGD = int(reply2[3]) self.gate_rt_spec_e.delete(0, tk.END) self.gate_rt_spec_e.insert(0, str(CurrentGD)) else: print("ERROR, Could not access socket.") return packet3 = [u.COMMAND_VQWK, VQWK_GET_DATA, VQWK_NB, 0, 0, "VQWK Get Data", "Y"] err_flag, reply3 = u.send_command(u.Crate_RHRS, packet3) if err_flag == u.SOCK_OK: CurrentNB = int(reply3[3]) self.blocks_rt_spec_e.delete(0, tk.END) self.blocks_rt_spec_e.insert(0, str(CurrentNB)) else: print("ERROR, Could not access socket.") return
def config_worker(request): """对worker进行配置管理 """ url_action = request.params.get('action', '') # 获取用户请求操作 worker_id = request.matchdict['id'] if url_action == 'delete': #删除还没启用的worker,删除操作不会导致调度配置更新 workers_dict = ztq_core.get_worker_state() del workers_dict[worker_id] worker_job = ztq_core.get_job_state(worker_id) for job_name, job_status in worker_job.items(): del worker_job[job_name] return HTTPFound(location='/workerstatus') elif url_action == 'update': # 发报告指令到各命令队列让worker报告自身状态 worker_list = ztq_core.get_all_worker() for worker_name in worker_list: if worker_name == worker_id: utils.send_command(worker_name, 'report') time.sleep(1) return HTTPFound(location='/workerstatus') return HTTPFound(location='/workerstatus')
def config_worker(request): """对worker进行配置管理 """ url_action = request.params.get('action','') # 获取用户请求操作 worker_id = request.matchdict['id'] if url_action == 'delete': #删除还没启用的worker,删除操作不会导致调度配置更新 workers_dict = ztq_core.get_worker_state() del workers_dict[worker_id] worker_job = ztq_core.get_job_state(worker_id) for job_name, job_status in worker_job.items(): del worker_job[job_name] return HTTPFound(location = '/workerstatus') elif url_action == 'update': # 发报告指令到各命令队列让worker报告自身状态 worker_list = ztq_core.get_all_worker() for worker_name in worker_list: if worker_name == worker_id: utils.send_command(worker_name, 'report') time.sleep(1) return HTTPFound(location = '/workerstatus') return HTTPFound(location = '/workerstatus')
def kill_server(self, but): #packet = [10, 10, 1, 2, 3, "Kill Server", "N"] #packet = [10, 10, 1, 2, 3, "Y", "Q"] #packet = [10, 10, 1, 2, 3, "Y", "Kill Server"] #packet = [10, 10, 1, 2, 3, "Kill Server", "Y"] #packet = [10, 10, 1, 2, 3, 1, tmpVar] packet = [10, 10, 1, 2, 3, "Not Q", "N"] err_flag, reply = u.send_command(but.crateN, packet) print("Reply = {}".format(reply)) if err_flag == u.SOCK_OK: print("{}".format(but.crateName)) else: print("ERROR, Could not access socket.") return -1
def change_status(self): bmw_running, kill_switch = self.check_status() packet = [] if bmw_running: packet = [u.COMMAND_BMW, KILL, 0, 0, 0, "BMW Status Change", "Y"] else: packet = [u.COMMAND_BMW, START, 0, 0, 0, "BMW Status Change", "Y"] print(tab_title + " Changing status of BMW client...") err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: print(tab_title + ' BMW status change call is complete') bmw_running, kill_switch = self.check_status() print(tab_title + ' change_status: command = ' + str(reply[1])) print(tab_title + ' change_status: bmw_running') print(tab_title + ' change_status: Exiting...') else: print(tab_title + " change_status: ERROR, Could not access socket.")
def set_status(self): if self.clean_setting.get() == 'CLEAN': status = 1 else: status = 0 packet = [ u.COMMAND_SCAN, SCAN_SET_STATUS, status, 0, 0, "SCN Status Change", "Y" ] err_flag, reply = u.send_command(u.Crate_INJ, packet) print("Setting SCN status: " + str(status)) if err_flag == u.SOCK_OK: print("SCAN status change call is complete") else: print(" check_status: ERROR, Could not access socket.")
def check_status(self): packet = [ u.COMMAND_SCAN, SCAN_GET_STATUS, 0, 0, 0, "SCN status check", "Y" ] err_flag, reply = u.send_command(u.Crate_INJ, packet) if err_flag == u.SOCK_OK: iclean = bool(reply[2]) if (iclean == SCN_INT_NOT): self.clean_setting.set(self.options[1]) elif (iclean == SCN_INT_CLN): self.clean_setting.set(self.options[0]) else: print("UNKNOWN REPLY FOR SCN STATUS: " + str(iclean)) self.clean_setting.set(self.options[1]) else: print(" check_status: ERROR, Could not access socket.") return
def if_toggle(action): if action in 'toggle': state = send_command('status')['status'] action = 'open' if 'close' in state else 'close' return action
def set_throttle(object_id, target_throttle): return send_command('set_throttle', object_id, target_throttle)
def status_report(object_id=None): response = send_command('status_report', object_id=object_id) return json.loads(response)
def send(self, command): send_command(command)['status'] return redirect(url_for('.index'))
def set_values_inj(self): value1 = int(self.inj_ramp_delay_e.get()) value2 = int(self.inj_int_time_e.get()) value3 = int(self.inj_oversamp_e.get()) packet1 = [ u.COMMAND_HAPTB, HAPTB_SET_DATA, HAPTB_RD, value1, 0, "TB Set Data", "Y" ] err_flag, reply1 = u.send_command(u.Crate_INJ, packet1) othererror = 0 if err_flag == u.SOCK_OK: if reply1[1] != 1: if reply1[1] == -2: print("Cannot set parameter, CODA run in progress!") else: print("Error:Server replied with TB error code: " + str(reply1[1])) othererror = 1 else: if reply1[2] != HAPTB_RD: print("Server replied with wrong TB number: " + str(reply1[2]) + " instead of " + str(HAPTB_RD)) othererror = 1 if reply1[3] != value1: print("Server replied with wrong TB set value: " + str(reply1[3]) + " instead of " + str(value1)) othererror = 1 else: print(" check_status: ERROR, Could not access socket.") if othererror == 1: print("Unknown error, cannot set TB parameter") packet2 = [ u.COMMAND_HAPTB, HAPTB_SET_DATA, HAPTB_IT, value2, 0, "TB Set Data", "Y" ] err_flag, reply2 = u.send_command(u.Crate_INJ, packet2) othererror = 0 if err_flag == u.SOCK_OK: if reply2[1] != 1: if reply2[1] == -2: print("Cannot set parameter, CODA run in progress!") else: print("Error:Server replied with TB error code: " + str(reply2[1])) othererror = 1 else: if reply2[2] != HAPTB_IT: print("Server replied with wrong TB number: " + str(reply2[2]) + " instead of " + str(HAPTB_IT)) othererror = 1 if reply2[3] != value2: print("Server replied with wrong TB set value: " + str(reply2[3]) + " instead of " + str(value2)) othererror = 1 else: print(" check_status: ERROR, Could not access socket.") if othererror == 1: print("Unknown error, cannot set TB parameter") packet3 = [ u.COMMAND_HAPTB, HAPTB_SET_DATA, HAPTB_OS, value3, 0, "TB Set Data", "Y" ] err_flag, reply3 = u.send_command(u.Crate_INJ, packet3) othererror = 0 if err_flag == u.SOCK_OK: if reply3[1] != 1: if reply3[1] == -2: print("Cannot set parameter, CODA run in progress!") else: print("Error:Server replied with TB error code: " + str(reply3[1])) othererror = 1 else: if reply3[2] != HAPTB_OS: print("Server replied with wrong TB number: " + str(reply3[2]) + " instead of " + str(HAPTB_OS)) othererror = 1 if reply3[3] != value3: print("Server replied with wrong TB set value: " + str(reply3[3]) + " instead of " + str(value3)) othererror = 1 else: print(" check_status: ERROR, Could not access socket.") if othererror == 1: print("Unknown error, cannot set TB parameter") self.check_values_inj()
def check_values(self): packet1 = [ u.COMMAND_SCAN, SCAN_GET_DATA, 1, 0, 0, "Check SCN Data Value", "Y" ] err_flag, reply1 = u.send_command(u.Crate_INJ, packet1) if err_flag == u.SOCK_OK: value1 = int(reply1[3]) self.inj_entries[0].delete(0, tk.END) self.inj_entries[0].insert(0, str(value1)) print("Value 1 is " + str(value1)) else: print(" check_status: ERROR, Could not access socket.") return packet2 = [ u.COMMAND_SCAN, SCAN_GET_DATA, 2, 0, 0, "Check SCN Data Value", "Y" ] err_flag, reply2 = u.send_command(u.Crate_INJ, packet2) if err_flag == u.SOCK_OK: value2 = int(reply2[3]) self.inj_entries[1].delete(0, tk.END) self.inj_entries[1].insert(0, str(value2)) print("Value 2 is " + str(value2)) else: print(" check_status: ERROR, Could not access socket.") return packet3 = [ u.COMMAND_SCAN, SCAN_GET_DATA, 3, 0, 0, "Check SCN Data Value", "Y" ] err_flag, reply3 = u.send_command(u.Crate_INJ, packet3) if err_flag == u.SOCK_OK: value3 = int(reply3[3]) self.inj_entries[2].delete(0, tk.END) self.inj_entries[2].insert(0, str(value3)) print("Value 3 is " + str(value3)) else: print(" check_status: ERROR, Could not access socket.") return packet4 = [ u.COMMAND_SCAN, SCAN_GET_DATA, 4, 0, 0, "Check SCN Data Value", "Y" ] err_flag, reply4 = u.send_command(u.Crate_INJ, packet4) if err_flag == u.SOCK_OK: value4 = int(reply4[3]) self.inj_entries[3].delete(0, tk.END) self.inj_entries[3].insert(0, str(value4)) print("Value 4 is " + str(value4)) else: print(" check_status: ERROR, Could not access socket.") return
def set_values_rt_spec(self): value1 = int(self.samples_rt_spec_e.get()) value2 = int(self.gate_rt_spec_e.get()) value3 = int(self.blocks_rt_spec_e.get()) i = 0 while (i <= 10): packet1 = [u.COMMAND_VQWK, VQWK_SET_DATA, VQWK_SPB, value1, i, "VQWK Set Data", "Y"] err_flag, reply1 = u.send_command(u.Crate_RHRS, packet1) othererror = 0 if err_flag == u.SOCK_OK: if reply1[1] != 1: if reply1[1] == -2: print("Cannot set parameter, CODA run in progress!") else: print("Error:Server replied with VQWK error code: " + str(reply1[1])) othererror = 1 else: if reply1[2] != VQWK_SPB: print("Server replied with wrong VQWK number: " +str(reply1[2])+ " instead of " +str(VQWK_SPB)) othererror = 1 if reply1[3] != value1: print("Server replied with wrong VQWK set value: " +str(reply1[3])+ " instead of " +str(value1)) othererror = 1 else: print(" check_status: ERROR, Could not access socket.") if othererror == 1: print("Unknown error, cannot set VQWK parameter") i += 1 i = 0 while (i <= 10): packet2 = [u.COMMAND_VQWK, VQWK_SET_DATA, VQWK_GD, value2, i, "VQWK Set Data", "Y"] err_flag, reply2 = u.send_command(u.Crate_RHRS, packet2) othererror = 0 if err_flag == u.SOCK_OK: if reply2[1] != 1: if reply2[1] == -2: print("Cannot set parameter, CODA run in progress!") else: print("Error:Server replied with VQWK error code: " + str(reply2[1])) othererror = 1 else: if reply2[2] != VQWK_GD: print("Server replied with wrong VQWK number: " +str(reply2[2])+ " instead of " +str(VQWK_GD)) othererror = 1 if reply2[3] != value2: print("Server replied with wrong VQWK set value: " +str(reply2[3])+ " instead of " +str(value2)) othererror = 1 else: print(" check_status: ERROR, Could not access socket.") if othererror == 1: print("Unknown error, cannot set VQWK parameter") i += 1 i = 0 while (i <= 10): packet3 = [u.COMMAND_VQWK, VQWK_SET_DATA, VQWK_NB, value3, 0, "VQWK Set Data", "Y"] err_flag, reply3 = u.send_command(u.Crate_RHRS, packet3) othererror = 0 if err_flag == u.SOCK_OK: if reply3[1] != 1: if reply3[1] == -2: print("Cannot set parameter, CODA run in progress!") else: print("Error:Server replied with VQWK error code: " + str(reply3[1])) othererror = 1 else: if reply3[2] != VQWK_NB: print("Server replied with wrong VQWK number: " +str(reply3[2])+ " instead of " +str(VQWK_NB)) othererror = 1 if reply3[3] != value3: print("Server replied with wrong VQWK set value: " +str(reply3[3])+ " instead of " +str(value3)) othererror = 1 else: print(" check_status: ERROR, Could not access socket.") if othererror == 1: print("Unknown error, cannot set VQWK parameter") i += 1 self.check_values_rt_spec()
def status_door(): content_type = request.headers.get('Content-Type', None) if content_type and content_type in 'application/json': return jsonify(send_command('status')) return redirect(url_for("admin.index"))
def set_rotation(object_id, target_pitch, target_yaw): return send_command('set_rotation', object_id, target_pitch, target_yaw)
def set_focus(object_id, target_focus): return send_command('set_focus', object_id, target_focus)
def door_status(): return send_command('status')['status']
def sensor_ping(object_id): response = send_command('sensor_ping', object_id=object_id) return json.loads(response)
def check_values(self): fSample = [] fIntGain = [] fConvGain = [] fDAC = [] value = numADC i = 0 while i < value: packet = [ u.COMMAND_ADC18, ADC18_GET_SAMP, i, 0, 0, "ADC18 Get Sample", "Y" ] err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: fSample.append(reply[3]) self.sample_settings[i].set(reply[3]) else: print("ERROR, Could not access socket.") return -1 packet = [ u.COMMAND_ADC18, ADC18_GET_INT, i, 0, 0, "ADC18 Get Int", "Y" ] err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: fIntGain.append(reply[3]) self.int_es[i].delete(0, tk.END) self.int_es[i].insert(0, str(reply[3])) else: print("ERROR, Could not access socket.") return -1 packet = [ u.COMMAND_ADC18, ADC18_GET_CONV, i, 0, 0, "ADC18 Get Conv", "Y" ] err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: fConvGain.append(reply[3]) self.conv_es[i].delete(0, tk.END) self.conv_es[i].insert(0, str(reply[3])) else: print("ERROR, Could not access socket.") return -1 packet = [ u.COMMAND_ADC18, ADC18_GET_DAC, i, 0, 0, "ADC18 Get DAC", "Y" ] err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: fDAC.append(reply[3]) if reply[3] == DACSAW: self.dac_settings[i].set('Saw') elif reply[3] == DACCONST: self.dac_settings[i].set('Const') elif reply[3] == DACTRI: self.dac_settings[i].set('Tri') else: self.dac_settings[i].set('Off') else: print("ERROR, Could not access socket.") return -1 i += 1
def set_power(object_id, power_toggle): if isinstance(power_toggle, bool): power_toggle = 1 if power_toggle else 0 return send_command('set_power', object_id, power_toggle)
def set_values(self): fSample = [] fIntGain = [] fConvGain = [] fDAC = [] value = numADC i = 0 while i < value: fIntGain.append(int(self.int_es[i].get())) if fIntGain[i] < 0 or fIntGain[i] > 3: print("ERROR: Int Value is out of range! Try (0-3)...") else: packet = [ u.COMMAND_ADC18, ADC18_SET_INT, i, fIntGain[i], 0, "ADC18 Set Int", "Y" ] err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: pass else: print("ERROR, Could not access socket.") return -1 fConvGain.append(int(self.conv_es[i].get())) if fConvGain[i] < 0 or fConvGain[i] > 15: print("ERROR: Conv Value is out of range! Try (0-15)...") else: packet = [ u.COMMAND_ADC18, ADC18_SET_CONV, i, fConvGain[i], 0, "ADC18 Set Conv", "Y" ] err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: pass else: print("ERROR, Could not access socket.") return -1 fDAC.append(self.dac_settings[i].get()) if fDAC[i] == 'Tri': dacflag = DACTRI elif fDAC[i] == 'Saw': dacflag = DACSAW elif fDAC[i] == 'Const': dacflag = DACCONST else: dacflag = DACOFF18 packet = [ u.COMMAND_ADC18, ADC18_SET_DAC, i, dacflag, 0, "ADC18 Set DAC", "Y" ] err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: pass else: print("ERROR, Could not access socket.") return -1 fSample.append(int(self.sample_settings[i].get())) packet = [ u.COMMAND_ADC18, ADC18_SET_SAMP, i, fSample[i], 0, "ADC18 Set Sample", "Y" ] err_flag, reply = u.send_command(u.Crate_CH, packet) if err_flag == u.SOCK_OK: pass else: print("ERROR, Could not access socket.") return -1 i += 1 self.check_values()