From 1729f17f9842e77fc4cfd474bba24726b748b858 Mon Sep 17 00:00:00 2001 From: Parity Account Date: Mon, 27 May 2019 09:47:21 -0400 Subject: [PATCH 01/30] Added funtionality to the scan, adc18, timeboard, and vqwk tabs. The adc18 tab still needs a little work to have it gereate both the ch and rtspec tabs. I was figuring out how to match the old crate picking flags. the utils file had a small issue with the crate order so that needed to be changed. --- GreenMonster.py | 4 +- tabs/gm_adc18.py | 231 ++++++++++++++-- tabs/gm_bmw.py | 1 + tabs/gm_scan.py | 156 ++++++++++- tabs/gm_timeboard.py | 304 ++++++++++++++++++--- tabs/gm_vqwk.py | 616 +++++++++++++++++++++++++++++++++++++++---- utils.py | 8 +- 7 files changed, 1200 insertions(+), 120 deletions(-) diff --git a/GreenMonster.py b/GreenMonster.py index 4029995..70f928e 100644 --- a/GreenMonster.py +++ b/GreenMonster.py @@ -14,6 +14,7 @@ import tabs.gm_timeboard as tmbd import tabs.gm_vqwk as vqwk import tabs.gm_adc18 as adc18s +import tabs.gm_adc18_2 as adc18s_2 import tabs.gm_vxworks as vxworks import utils as u @@ -49,7 +50,8 @@ def expert_tab(self, expt_tab): tab_control = ttk.Notebook(expt_tab) tab_titles = [('TimeBoard', tmbd.Timeboard), ('VQWK ADCs', vqwk.VQWK), - ('ADC18s, CH', adc18s.ADC18), + ('ADC18s, CH', adc18s.ADC18), + ('ADC18s, RtSpec', adc18s_2.ADC18), ('VXWorks Server', vxworks.VXWorks)] for title, fn in tab_titles: sub_tab = ttk.Frame(tab_control, width=800, height=600, style="My.TFrame") diff --git a/tabs/gm_adc18.py b/tabs/gm_adc18.py index b2f42fa..65fdf31 100644 --- a/tabs/gm_adc18.py +++ b/tabs/gm_adc18.py @@ -9,31 +9,88 @@ from tkinter import ttk import utils as u +ADC18_GET_NUMADC =1001 +ADC18_GET_LABEL =1002 +ADC18_GET_CSR =1003 +ADC18_SET_CONV =1004 +ADC18_SET_INT =1005 +ADC18_SET_PED =1006 +ADC18_GET_CONV =1007 +ADC18_GET_INT =1008 +ADC18_GET_PED =1009 +ADC18_SET_DAC =1010 +ADC18_GET_DAC =1011 +ADC18_SET_SAMP =1012 +ADC18_GET_SAMP =1013 +GA_MAXADC =20 +DACRADIO18 =100 +GM_ADC_GET =101 +GM_ADC_SET =201 +DACTRI =0 +DACSAW =1 +DACCONST =2 +DACOFF18 =3 + class ADC18(tk.Frame): def __init__(self, tab): + global numADC + numADC = self.get_num_adc() + ADClabels = [] + + i = 0 + while i < numADC: + ADClabels.append(self.get_label_adc(i)) + i += 1 + self.ch_frame = tk.LabelFrame(tab, text='CH', background=u.green_color) - self.adc_ls = [tk.Label(self.ch_frame, text='ADC 8', background=u.green_color), - tk.Label(self.ch_frame, text='ADC 10', background=u.green_color), - tk.Label(self.ch_frame, text='ADC 10', background=u.green_color), - tk.Label(self.ch_frame, text='ADC 11', background=u.green_color)] - self.int_es = [tk.Entry(self.ch_frame, width=3), - tk.Entry(self.ch_frame, width=3), - tk.Entry(self.ch_frame, width=3), - tk.Entry(self.ch_frame, width=3)] - self.conv_es = [tk.Entry(self.ch_frame, width=3), - tk.Entry(self.ch_frame, width=3), - tk.Entry(self.ch_frame, width=3), - tk.Entry(self.ch_frame, width=3)] - self.dac_settings = [tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar()] - self.sample_settings = [tk.IntVar(), tk.IntVar(), tk.IntVar(), tk.IntVar()] + self.adc_ls = [] + self.int_es = [] + self.conv_es = [] + self.dac_settings = [] + self.sample_settings = [] + + i = 0 + while i < numADC: + self.adc_ls.append(tk.Label(self.ch_frame, text='ADC '+str(ADClabels[i]), background=u.green_color)) + self.int_es.append(tk.Entry(self.ch_frame, width=3)) + self.conv_es.append(tk.Entry(self.ch_frame, width=3)) + self.dac_settings.append(tk.StringVar()) + self.sample_settings.append(tk.IntVar()) + i += 1 + labels = ['Label', 'Int', 'Conv', '-----', 'DAC', 'Settings', '-----', 'Sample by:'] for i, label in enumerate(labels): tk.Label(self.ch_frame, text=label, background=u.green_color).grid( row=0, column=i, padx=8, pady=10, sticky='W') - self.create_table() - def create_table(self): - for i in range(1, 5): + self.create_table(numADC) + self.check_values() + + def get_num_adc(self): + packet = [u.COMMAND_ADC18, ADC18_GET_NUMADC, 0, 0, 0, "ADC Get Number", "Y"] + err_flag, reply = u.send_command(u.Crate_CH, packet) + + if err_flag == u.SOCK_OK: + return int(reply[3]) + + else: + print("ERROR, Could not access socket.") + return -1 + + def get_label_adc(self, index): + packet = [u.COMMAND_ADC18, ADC18_GET_LABEL, index, 0, 0, "ADC Get Label", "Y"] + err_flag, reply = u.send_command(u.Crate_CH, packet) + + if err_flag == u.SOCK_OK: + return int(reply[3]) + + else: + print("ERROR, Could not access socket.") + return -1 + + + def create_table(self, value): + for i in range(1, value+1): self.adc_ls[i-1].grid(row=i, column=0, padx=10, pady=10, sticky='W') u.set_text(self.int_es[i-1], '3').grid(row=i, column=1, padx=10, pady=10) u.set_text(self.conv_es[i-1], '0').grid(row=i, column=2, padx=10, pady=10) @@ -46,10 +103,144 @@ def create_table(self): sample_by = self.sample_settings[i-1] sample_by.set(1) tk.OptionMenu(self.ch_frame, sample_by, 1, 2, 4, 8).grid(row=i, column=7) - tk.Button(self.ch_frame, text='Get Settings', background=u.green_color).grid( + tk.Button(self.ch_frame, text='Get Settings', background=u.green_color, command=self.check_values).grid( row=6, column=1, columnspan=2, pady=50, sticky='S') - tk.Button(self.ch_frame, text='Apply Settings', background=u.green_color).grid( + tk.Button(self.ch_frame, text='Apply Settings', background=u.green_color, command=self.set_values).grid( row=6, column=3, columnspan=2, pady=50, sticky='S') - tk.Button(self.ch_frame, text='Cancel', background=u.green_color).grid( + tk.Button(self.ch_frame, text='Cancel', background=u.green_color, command=self.check_values).grid( row=6, column=5, pady=50, sticky='S') self.ch_frame.pack(padx=20, pady=20) + + 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_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() diff --git a/tabs/gm_bmw.py b/tabs/gm_bmw.py index 8f654d4..721a7a2 100644 --- a/tabs/gm_bmw.py +++ b/tabs/gm_bmw.py @@ -40,6 +40,7 @@ def __init__(self, tab): self.script_frame_layout() self.test_frame_layout() self.bm_frame.pack(padx=20, pady=20, anchor='w') + self.check_status_button() def script_frame_layout(self): self.ks_bm_l.grid(row=0, column=0, padx=10, pady=10, sticky='W') diff --git a/tabs/gm_scan.py b/tabs/gm_scan.py index a9ce079..b78fda3 100644 --- a/tabs/gm_scan.py +++ b/tabs/gm_scan.py @@ -9,6 +9,18 @@ from tkinter import ttk import utils as u +SCAN_GET_DATA =1001 +SCAN_SET_DATA =1002 +SCAN_GET_STATUS =1003 +SCAN_SET_STATUS =1004 +GM_SCN_CHECK =6002 +GM_SCN_SET =6003 +SCN_RADIO_CLN =6101 +SCN_RADIO_NOT =6102 +SCN_RADIO_CLN_BT=0 +SCN_RADIO_NOT_BT=1 +SCN_INT_CLN =1 +SCN_INT_NOT =0 class ScanUtil(tk.Frame): def __init__(self, tab): @@ -27,14 +39,152 @@ def __init__(self, tab): tk.Entry(self.inj_frame)] for i, op in enumerate(self.options): tk.Radiobutton(self.util_frame, text=op, variable=self.clean_setting, - value=op, bg=u.green_color).grid(row=0, column=i, padx=10, pady=10, sticky='W') + value=op, bg=u.green_color, command=self.set_status).grid(row=0, column=i, padx=10, pady=10, sticky='W') self.fill_inj_frame() self.inj_frame.grid(row=1, column=0, columnspan=2, padx=10, pady=10, sticky='W') - tk.Button(self.util_frame, text='Check Status', bg=u.green_color).grid(row=2, column=0, padx=10, pady=10) - tk.Button(self.util_frame, text='Set Values', bg=u.green_color).grid(row=2, column=1, padx=10, pady=10) + tk.Button(self.util_frame, text='Check Status', bg=u.green_color, command=self.check_status).grid(row=2, column=0, padx=10, pady=10) + tk.Button(self.util_frame, text='Set Values', bg=u.green_color, command=self.set_values).grid(row=2, column=1, padx=10, pady=10) self.util_frame.pack(padx=20, pady=20, anchor='w') + self.check_status() + self.check_values() def fill_inj_frame(self): for r in range(0, 4): self.inj_labels[r].grid(row=r, column=0, padx=15, pady=10, sticky='E') u.set_text(self.inj_entries[r], '0').grid(row=r, column=1, padx=10, pady=10, sticky='W') + + 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 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_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 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() diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 558d07f..3c97874 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -10,6 +10,15 @@ import utils as u from ctypes import cdll +GM_HAPTB =1000 +GM_TB_GET =1001 +GM_TB_SET =1002 +HAPTB_GET_DATA =1001 +HAPTB_SET_DATA =1002 +HAPTB_RD =201 +HAPTB_IT =202 +HAPTB_OS =221 + class Timeboard(tk.Frame): def __init__(self, tab): self.ch_frame = tk.LabelFrame(tab, text='CH', background=u.green_color, width=500) @@ -23,53 +32,276 @@ def __init__(self, tab): self.ramp_delay_l.grid(row=0, column=0, padx=10, pady=5, sticky='W') self.int_time_l.grid(row=1, column=0, padx=10, pady=5, sticky='W') self.oversamp_l.grid(row=2, column=0, padx=10, pady=5, sticky='W') - u.set_text(self.ramp_delay_e, '40').grid(row=0, column=1) - u.set_text(self.int_time_e, '13200').grid(row=1, column=1) - u.set_text(self.oversamp_e, '0').grid(row=2, column=1) - tk.Button(self.ch_frame, text='Get Settings', background=u.green_color).grid( + u.set_text(self.ramp_delay_e, '0').grid(row=0, column=1, padx=10, pady=5, sticky='W') + u.set_text(self.int_time_e, '0').grid(row=1, column=1, padx=10, pady=5, sticky='W') + u.set_text(self.oversamp_e, '0').grid(row=2, column=1, padx=10, pady=5, sticky='W') + tk.Button(self.ch_frame, text='Get Settings', background=u.green_color, command=self.check_values_ch).grid( row=3, column=0, pady=10) - tk.Button(self.ch_frame, text='Apply Settings', background=u.green_color).grid( + tk.Button(self.ch_frame, text='Apply Settings', background=u.green_color, command=self.set_values_ch).grid( row=3, column=1, pady=10) self.ch_frame.pack(padx=20, pady=10, anchor='w') + + self.rt_spec_frame = tk.LabelFrame(tab, text='RtSpec', background=u.green_color, width=500) + self.rt_spec_ramp_delay_l = tk.Label(self.rt_spec_frame, text='Ramp Delay', background=u.green_color) + self.rt_spec_int_time_l = tk.Label(self.rt_spec_frame, text='Integrate Time', background=u.green_color) + self.rt_spec_oversamp_l = tk.Label(self.rt_spec_frame, text='Oversampling', background=u.green_color) + self.rt_spec_ramp_delay_e = tk.Entry(self.rt_spec_frame) + self.rt_spec_int_time_e = tk.Entry(self.rt_spec_frame) + self.rt_spec_oversamp_e = tk.Entry(self.rt_spec_frame) + + self.rt_spec_ramp_delay_l.grid(row=0, column=0, padx=10, pady=5, sticky='W') + self.rt_spec_int_time_l.grid(row=1, column=0, padx=10, pady=5, sticky='W') + self.rt_spec_oversamp_l.grid(row=2, column=0, padx=10, pady=5, sticky='W') + u.set_text(self.rt_spec_ramp_delay_e, '0').grid(row=0, column=1, padx=10, pady=5, sticky='W') + u.set_text(self.rt_spec_int_time_e, '0').grid(row=1, column=1, padx=10, pady=5, sticky='W') + u.set_text(self.rt_spec_oversamp_e, '0').grid(row=2, column=1, padx=10, pady=5, sticky='W') + tk.Button(self.rt_spec_frame, text='Get Settings', background=u.green_color, command=self.check_values_rt_spec).grid( + row=3, column=0, pady=10) + tk.Button(self.rt_spec_frame, text='Apply Settings', background=u.green_color, command=self.set_values_rt_spec).grid( + row=3, column=1, pady=10) + self.rt_spec_frame.pack(padx=20, pady=10, anchor='w') + + self.check_values_ch() + self.check_values_rt_spec() - ''' - def get_RD_value(self): - new_rd = self.lib.getRDvalue(self.obj) - self.ramp_delay_e = u.set_text(self.ramp_delay_e, str(new_rd)) + def check_values_ch(self): + packet1 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_RD, 0, 0, "TB Get Data", "Y"] + err_flag, reply1 = u.send_command(u.Crate_CH, 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.ramp_delay_e.delete(0, tk.END) + self.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_CH, packet2) + + if err_flag == u.SOCK_OK: + CurrentIT = int(reply2[3]) + self.int_time_e.delete(0, tk.END) + self.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_CH, packet3) + + if err_flag == u.SOCK_OK: + CurrentOS = int(reply3[3]) + self.oversamp_e.delete(0, tk.END) + self.oversamp_e.insert(0, str(CurrentOS)) + print("Oversampling is " + str(CurrentOS)) + + else: + print("ERROR, Could not access socket.") + return + + def check_values_rt_spec(self): + packet1 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_RD, 0, 0, "TB Get Data", "Y"] + err_flag, reply1 = u.send_command(u.Crate_RHRS, 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.rt_spec_ramp_delay_e.delete(0, tk.END) + self.rt_spec_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_RHRS, packet2) + + if err_flag == u.SOCK_OK: + CurrentIT = int(reply2[3]) + self.rt_spec_int_time_e.delete(0, tk.END) + self.rt_spec_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_RHRS, packet3) + + if err_flag == u.SOCK_OK: + CurrentOS = int(reply3[3]) + self.rt_spec_oversamp_e.delete(0, tk.END) + self.rt_spec_oversamp_e.insert(0, str(CurrentOS)) + print("Oversampling is " + str(CurrentOS)) + + else: + print("ERROR, Could not access socket.") + return + + def set_values_ch(self): + + value1 = int(self.ramp_delay_e.get()) + value2 = int(self.int_time_e.get()) + value3 = int(self.oversamp_e.get()) - def set_RD_value(self): - self.lib.setRDvalue(self.obj, int(self.ramp_delay_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_CH, 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") - def get_IS_value(self): - new_is = self.lib.getISvalue(self.obj) - self.int_time_e = u.set_text(self.int_time_e, str(new_is)) + packet2 = [u.COMMAND_HAPTB, HAPTB_SET_DATA, HAPTB_IT, value2, 0, "TB Set Data", "Y"] + err_flag, reply2 = u.send_command(u.Crate_CH, 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") - def set_IS_value(self): - self.lib.setISvalue(self.obj, int(self.int_time_e.get())) + packet3 = [u.COMMAND_HAPTB, HAPTB_SET_DATA, HAPTB_OS, value3, 0, "TB Set Data", "Y"] + err_flag, reply3 = u.send_command(u.Crate_CH, 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") - def get_OS_value(self): - new_os = self.lib.getOSvalue(self.obj) - self.oversamp_e = u.set_text(self.oversamp_e, str(new_os)) + self.check_values_ch() - def set_OS_value(self): - self.lib.setOSvalue(self.obj, int(self.oversamp_e.get())) + def set_values_rt_spec(self): - def pull_from_board(self): - self.lib.getValsTB(self.obj) + value1 = int(self.rt_spec_ramp_delay_e.get()) + value2 = int(self.rt_spec_int_time_e.get()) + value3 = int(self.rt_spec_oversamp_e.get()) - def push_to_board(self): - self.lib.setValsTB(self.obj) + packet1 = [u.COMMAND_HAPTB, HAPTB_SET_DATA, HAPTB_RD, value1, 0, "TB 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 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") - def get_all_values(self): - self.pull_from_board() - self.get_RD_value() - self.get_IS_value() - self.get_OS_value() + packet2 = [u.COMMAND_HAPTB, HAPTB_SET_DATA, HAPTB_IT, value2, 0, "TB 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 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") - def set_all_values(self): - self.set_RD_value() - self.set_IS_value() - self.set_OS_value() - self.push_to_board() + packet3 = [u.COMMAND_HAPTB, HAPTB_SET_DATA, HAPTB_OS, value3, 0, "TB 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 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_rt_spec() diff --git a/tabs/gm_vqwk.py b/tabs/gm_vqwk.py index 9931f7a..5ca668f 100644 --- a/tabs/gm_vqwk.py +++ b/tabs/gm_vqwk.py @@ -10,10 +10,23 @@ import utils as u from ctypes import cdll +GM_VQWK =7000 +GM_VQWK_GET =7001 +GM_VQWK_SET =7002 +VQWK_GET_DATA =7001 +VQWK_SET_DATA =7002 +VQWK_SPB =701 +VQWK_GD =702 +VQWK_NB =703 + + class VQWK(tk.Frame): def __init__(self, tab): self.ch_frame = tk.LabelFrame(tab, text='CH', background=u.green_color, width=500) self.inj_frame = tk.LabelFrame(tab, text='Inj', background=u.green_color, width=500) + self.lft_spec_frame = tk.LabelFrame(tab, text='LftSpec', background=u.green_color, width=500) + self.rt_spec_frame = tk.LabelFrame(tab, text='RtSpec', background=u.green_color, width=500) + self.samples_ch_l = tk.Label(self.ch_frame, text='Samples Per Block', background=u.green_color) self.gate_ch_l = tk.Label(self.ch_frame, text='Gate Delay', background=u.green_color) self.blocks_ch_l = tk.Label(self.ch_frame, text='Number of Blocks', background=u.green_color) @@ -32,90 +45,577 @@ def __init__(self, tab): self.fill_inj_frame() self.inj_frame.grid(row=0, column=1, padx=20, pady=10) + self.samples_lft_spec_l = tk.Label(self.lft_spec_frame, text='Samples Per Block', background=u.green_color) + self.gate_lft_spec_l = tk.Label(self.lft_spec_frame, text='Gate Delay', background=u.green_color) + self.blocks_lft_spec_l = tk.Label(self.lft_spec_frame, text='Number of Blocks', background=u.green_color) + self.samples_lft_spec_e = tk.Entry(self.lft_spec_frame) + self.gate_lft_spec_e = tk.Entry(self.lft_spec_frame) + self.blocks_lft_spec_e = tk.Entry(self.lft_spec_frame) + self.fill_lft_spec_frame() + self.lft_spec_frame.grid(row=1, column=0, padx=20, pady=10) + + self.samples_rt_spec_l = tk.Label(self.rt_spec_frame, text='Samples Per Block', background=u.green_color) + self.gate_rt_spec_l = tk.Label(self.rt_spec_frame, text='Gate Delay', background=u.green_color) + self.blocks_rt_spec_l = tk.Label(self.rt_spec_frame, text='Number of Blocks', background=u.green_color) + self.samples_rt_spec_e = tk.Entry(self.rt_spec_frame) + self.gate_rt_spec_e = tk.Entry(self.rt_spec_frame) + self.blocks_rt_spec_e = tk.Entry(self.rt_spec_frame) + self.fill_rt_spec_frame() + self.rt_spec_frame.grid(row=1, column=1, padx=20, pady=10) + + self.check_values_ch() + self.check_values_inj() + self.check_values_lft_spec() + self.check_values_rt_spec() + def fill_ch_frame(self): self.samples_ch_l.grid(row=0, column=0, padx=10, pady=5, sticky='W') self.gate_ch_l.grid(row=1, column=0, padx=10, pady=5, sticky='W') self.blocks_ch_l.grid(row=2, column=0, padx=10, pady=5, sticky='W') - u.set_text(self.samples_ch_e, '4141').grid(row=0, column=1) - u.set_text(self.gate_ch_e, '10').grid(row=1, column=1) - u.set_text(self.blocks_ch_e, '4').grid(row=2, column=1) - tk.Button(self.ch_frame, text='Get Settings', background=u.green_color).grid( + u.set_text(self.samples_ch_e, '0').grid(row=0, column=1) + u.set_text(self.gate_ch_e, '0').grid(row=1, column=1) + u.set_text(self.blocks_ch_e, '0').grid(row=2, column=1) + tk.Button(self.ch_frame, text='Get Settings', background=u.green_color, command=self.check_values_ch).grid( row=3, column=0, pady=10) - tk.Button(self.ch_frame, text='Apply Settings', background=u.green_color).grid( + tk.Button(self.ch_frame, text='Apply Settings', background=u.green_color, command=self.set_values_ch).grid( row=3, column=1, pady=10) def fill_inj_frame(self): self.samples_inj_l.grid(row=0, column=0, padx=10, pady=5, sticky='W') self.gate_inj_l.grid(row=1, column=0, padx=10, pady=5, sticky='W') self.blocks_inj_l.grid(row=2, column=0, padx=10, pady=5, sticky='W') - u.set_text(self.samples_inj_e, '496').grid(row=0, column=1) - u.set_text(self.gate_inj_e, '10').grid(row=1, column=1) - u.set_text(self.blocks_inj_e, '4').grid(row=2, column=1) - tk.Button(self.inj_frame, text='Get Settings', background=u.green_color).grid( + u.set_text(self.samples_inj_e, '0').grid(row=0, column=1) + u.set_text(self.gate_inj_e, '0').grid(row=1, column=1) + u.set_text(self.blocks_inj_e, '0').grid(row=2, column=1) + tk.Button(self.inj_frame, text='Get Settings', background=u.green_color, command=self.check_values_inj).grid( + row=3, column=0, pady=10) + tk.Button(self.inj_frame, text='Apply Settings', background=u.green_color, command=self.set_values_inj).grid( + row=3, column=1, pady=10) + + def fill_lft_spec_frame(self): + self.samples_lft_spec_l.grid(row=0, column=0, padx=10, pady=5, sticky='W') + self.gate_lft_spec_l.grid(row=1, column=0, padx=10, pady=5, sticky='W') + self.blocks_lft_spec_l.grid(row=2, column=0, padx=10, pady=5, sticky='W') + u.set_text(self.samples_lft_spec_e, '0').grid(row=0, column=1) + u.set_text(self.gate_lft_spec_e, '0').grid(row=1, column=1) + u.set_text(self.blocks_lft_spec_e, '0').grid(row=2, column=1) + tk.Button(self.lft_spec_frame, text='Get Settings', background=u.green_color, command=self.check_values_lft_spec).grid( + row=3, column=0, pady=10) + tk.Button(self.lft_spec_frame, text='Apply Settings', background=u.green_color, command=self.set_values_lft_spec).grid( + row=3, column=1, pady=10) + + def fill_rt_spec_frame(self): + self.samples_rt_spec_l.grid(row=0, column=0, padx=10, pady=5, sticky='W') + self.gate_rt_spec_l.grid(row=1, column=0, padx=10, pady=5, sticky='W') + self.blocks_rt_spec_l.grid(row=2, column=0, padx=10, pady=5, sticky='W') + u.set_text(self.samples_rt_spec_e, '0').grid(row=0, column=1) + u.set_text(self.gate_rt_spec_e, '0').grid(row=1, column=1) + u.set_text(self.blocks_rt_spec_e, '0').grid(row=2, column=1) + tk.Button(self.rt_spec_frame, text='Get Settings', background=u.green_color, command=self.check_values_rt_spec).grid( row=3, column=0, pady=10) - tk.Button(self.inj_frame, text='Apply Settings', background=u.green_color).grid( + tk.Button(self.rt_spec_frame, text='Apply Settings', background=u.green_color, command=self.set_values_rt_spec).grid( row=3, column=1, pady=10) - ''' - def get_samp_ch(self): - new_samp = self.lib.getSampVal1(self.obj) - self.samples_ch_e = u.set_text(self.samples_ch_e, new_samp) + def check_values_ch(self): + packet1 = [u.COMMAND_VQWK, VQWK_GET_DATA, VQWK_SPB, 0, 0, "VQWK Get Data", "Y"] + err_flag, reply1 = u.send_command(u.Crate_CH, 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_ch_e.delete(0, tk.END) + self.samples_ch_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_CH, packet2) + + if err_flag == u.SOCK_OK: + CurrentGD = int(reply2[3]) + self.gate_ch_e.delete(0, tk.END) + self.gate_ch_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_CH, packet3) + + if err_flag == u.SOCK_OK: + CurrentNB = int(reply3[3]) + self.blocks_ch_e.delete(0, tk.END) + self.blocks_ch_e.insert(0, str(CurrentNB)) + + else: + print("ERROR, Could not access socket.") + return + + def check_values_inj(self): + packet1 = [u.COMMAND_VQWK, VQWK_GET_DATA, VQWK_SPB, 0, 0, "VQWK Get Data", "Y"] + err_flag, reply1 = u.send_command(u.Crate_INJ, 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_inj_e.delete(0, tk.END) + self.samples_inj_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_INJ, packet2) + + if err_flag == u.SOCK_OK: + CurrentGD = int(reply2[3]) + self.gate_inj_e.delete(0, tk.END) + self.gate_inj_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_INJ, packet3) + + if err_flag == u.SOCK_OK: + CurrentNB = int(reply3[3]) + self.blocks_inj_e.delete(0, tk.END) + self.blocks_inj_e.insert(0, str(CurrentNB)) + + else: + print("ERROR, Could not access socket.") + return + + def check_values_lft_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_LHRS, 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_lft_spec_e.delete(0, tk.END) + self.samples_lft_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_LHRS, packet2) + + if err_flag == u.SOCK_OK: + CurrentGD = int(reply2[3]) + self.gate_lft_spec_e.delete(0, tk.END) + self.gate_lft_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_LHRS, packet3) + + if err_flag == u.SOCK_OK: + CurrentNB = int(reply3[3]) + self.blocks_lft_spec_e.delete(0, tk.END) + self.blocks_lft_spec_e.insert(0, str(CurrentNB)) + + else: + print("ERROR, Could not access socket.") + return + + 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 set_values_ch(self): - def set_samp_ch(self): - self.lib.setSampVal1(self.obj, int(self.samples_ch_e.get())) + value1 = int(self.samples_ch_e.get()) + value2 = int(self.gate_ch_e.get()) + value3 = int(self.blocks_ch_e.get()) - def get_gate_ch(self): - new_gate = self.lib.getGateVal1(self.obj) - self.gate_ch_e = u.set_text(self.gate_ch_e, new_gate) + 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_CH, 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 - def set_gate_ch(self): - self.lib.setGateVal1(self.obj, int(self.gate_ch_e.get())) + 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_CH, 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_CH, 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_ch() - def get_blocks_ch(self): - new_blok = self.lib.getBlokVal1(self.obj) - self.blocks_ch_e = u.set_text(self.blocks_ch_e, new_blok) + def set_values_inj(self): - def set_blocks_ch(self): - self.lib.setBlokVal1(self.obj, int(self.blocks_ch_e.get())) + value1 = int(self.samples_inj_e.get()) + value2 = int(self.gate_inj_e.get()) + value3 = int(self.blocks_inj_e.get()) - def get_samp_inj(self): - new_samp = self.lib.getSampVal2(self.obj) - self.samples_inj_e = u.set_text(self.samples_inj_e, new_samp) + 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_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 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 - def set_samp_inj(self): - self.lib.setSampVal2(self.obj, int(self.samples_inj_e.get())) + 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_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 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_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 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_inj() - def get_gate_inj(self): - new_gate = self.lib.getGateVal2(self.obj) - self.gate_inj_e = u.set_text(self.gate_inj_e, new_gate) + def set_values_lft_spec(self): - def set_gate_inj(self): - self.lib.setGateVal2(self.obj, int(self.gate_inj_e.get())) + value1 = int(self.samples_lft_spec_e.get()) + value2 = int(self.gate_lft_spec_e.get()) + value3 = int(self.blocks_lft_spec_e.get()) - def get_blocks_inj(self): - new_blok = self.lib.getBlokVal2(self.obj) - self.blocks_inj_e = u.set_text(self.blocks_inj_e, new_blok) + 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_LHRS, 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 - def set_blocks_inj(self): - self.lib.setBlokVal2(self.obj, int(self.blocks_inj_e.get())) + 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_LHRS, 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_LHRS, 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_lft_spec() - def get_settings_ch(self): - self.get_samp_ch() - self.get_gate_ch() - self.get_blocks_ch() + def set_values_rt_spec(self): - def set_settings_ch(self): - self.set_samp_ch() - self.set_gate_ch() - self.set_blocks_ch() + value1 = int(self.samples_rt_spec_e.get()) + value2 = int(self.gate_rt_spec_e.get()) + value3 = int(self.blocks_rt_spec_e.get()) - def get_settings_inj(self): - self.get_samp_inj() - self.get_gate_inj() - self.get_blocks_inj() + 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 - def set_settings_inj(self): - self.set_samp_inj() - self.set_gate_inj() - self.set_blocks_inj() - ''' + 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() diff --git a/utils.py b/utils.py index b75311b..1aac7d1 100644 --- a/utils.py +++ b/utils.py @@ -17,8 +17,12 @@ COMMAND_SCAN = 5000; COMMAND_ADC18 = 6000 COMMAND_VQWK = 7000 -Crate_CH = 0; Crate_INJ = 1 -Crate_LHRS = 2; Crate_RHRS = 3 +#Crate_CH = 0; Crate_INJ = 1 +#Crate_LHRS = 2; Crate_RHRS = 3 +#Crate_Test = 4 + +Crate_CH = 0; Crate_LHRS = 1 +Crate_RHRS = 2; Crate_INJ = 3 Crate_Test = 4 def set_text(entry, text): From eeafe3a4567752f63f94789fc978d1c0b81f6835 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 30 May 2019 11:56:23 -0400 Subject: [PATCH 02/30] added adc18 tabs --- tabs/gm_adc16.py | 224 +++++++++++++++++++++++++++++++++++++++++ tabs/gm_adc18_2.py | 246 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 470 insertions(+) create mode 100644 tabs/gm_adc16.py create mode 100644 tabs/gm_adc18_2.py diff --git a/tabs/gm_adc16.py b/tabs/gm_adc16.py new file mode 100644 index 0000000..f5cf617 --- /dev/null +++ b/tabs/gm_adc16.py @@ -0,0 +1,224 @@ +''' +Green Monster GUI Revamp +Containing ADC18s Tab +Code Commissioned 2019-01-16 +Code by A.J. Zec +''' + +import tkinter as tk +from tkinter import ttk +import utils as u + +GA_MAXADC =20 +GAINRADIO =100 +DACRADIO =200 +GM_ADC_GET =101 +GM_ADC_SET =201 +DACON =1 +DACOFF =2 +GAINLO =1 +GAINHI =2 +HAPADC_GET_NUMADC =1001 +HAPADC_GET_CSR =1002 +HAPADC_SET_CSR =1003 +HAPADC_GET_LABEL =1004 + +class ADC16(tk.Frame): + def __init__(self, tab): + global numADC + numADC = self.get_num_adc() + ADClabels = [] + + i = 0 + while i < numADC: + ADClabels.append(self.get_label_adc(i)) + i += 1 + + #numADC += 1 + #ADClabels.append(5) + + self.rt_spec_frame = tk.LabelFrame(tab, text='RtSpec', background=u.green_color) + self.adc_ls = [] + self.int_es = [] + self.conv_es = [] + self.dac_settings = [] + self.sample_settings = [] + + i = 0 + while i < numADC: + self.adc_ls.append(tk.Label(self.rt_spec_frame, text='ADC '+str(ADClabels[i]), background=u.green_color)) + self.int_es.append(tk.Entry(self.rt_spec_frame, width=3)) + self.conv_es.append(tk.Entry(self.rt_spec_frame, width=3)) + self.dac_settings.append(tk.StringVar()) + self.sample_settings.append(tk.IntVar()) + i += 1 + + labels = ['Label', 'Int', 'Conv', '-----', 'DAC', 'Settings', '-----', 'Sample by:'] + for i, label in enumerate(labels): + tk.Label(self.rt_spec_frame, text=label, background=u.green_color).grid( + row=0, column=i, padx=8, pady=10, sticky='W') + + self.create_table(numADC) + self.check_values() + + 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 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 create_table(self, value): + for i in range(1, value+1): + self.adc_ls[i-1].grid(row=i, column=0, padx=10, pady=10, sticky='W') + u.set_text(self.int_es[i-1], '3').grid(row=i, column=1, padx=10, pady=10) + u.set_text(self.conv_es[i-1], '0').grid(row=i, column=2, padx=10, pady=10) + setting = self.dac_settings[i-1] + settings = ['Tri', 'Saw', 'Const', 'Off'] + setting.set('Tri') + for j,s in enumerate(settings): + tk.Radiobutton(self.rt_spec_frame, text=s, variable=setting, value=s, background=u.green_color).grid( + row=i, column=j+3, padx=5, pady=10, sticky='W') + sample_by = self.sample_settings[i-1] + sample_by.set(1) + tk.OptionMenu(self.rt_spec_frame, sample_by, 1, 2, 4, 8).grid(row=i, column=7) + tk.Button(self.rt_spec_frame, text='Get Settings', background=u.green_color, command=self.check_values).grid( + row=6, column=1, columnspan=2, pady=50, sticky='S') + tk.Button(self.rt_spec_frame, text='Apply Settings', background=u.green_color, command=self.set_values).grid( + row=6, column=3, columnspan=2, pady=50, sticky='S') + tk.Button(self.rt_spec_frame, text='Cancel', background=u.green_color, command=self.check_values).grid( + row=6, column=5, pady=50, sticky='S') + self.rt_spec_frame.pack(padx=20, pady=20) + + 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 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_HAPADC, ADC18_SET_INT, i, fIntGain[i], 0, "ADC18 Set Int", "Y"] + err_flag, reply = u.send_command(u.Crate_RHRS, 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_HAPADC, ADC18_SET_CONV, i, fConvGain[i], 0, "ADC18 Set Conv", "Y"] + err_flag, reply = u.send_command(u.Crate_RHRS, 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_HAPADC, ADC18_SET_DAC, i, dacflag, 0, "ADC18 Set DAC", "Y"] + err_flag, reply = u.send_command(u.Crate_RHRS, 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_HAPADC, ADC18_SET_SAMP, i, fSample[i], 0, "ADC18 Set Sample", "Y"] + err_flag, reply = u.send_command(u.Crate_RHRS, packet) + + if err_flag == u.SOCK_OK: + pass + else: + print("ERROR, Could not access socket.") + return -1 + i += 1 + + #self.check_values() diff --git a/tabs/gm_adc18_2.py b/tabs/gm_adc18_2.py new file mode 100644 index 0000000..dfc06d2 --- /dev/null +++ b/tabs/gm_adc18_2.py @@ -0,0 +1,246 @@ +''' +Green Monster GUI Revamp +Containing ADC18s Tab +Code Commissioned 2019-01-16 +Code by A.J. Zec +''' + +import tkinter as tk +from tkinter import ttk +import utils as u + +ADC18_GET_NUMADC =1001 +ADC18_GET_LABEL =1002 +ADC18_GET_CSR =1003 +ADC18_SET_CONV =1004 +ADC18_SET_INT =1005 +ADC18_SET_PED =1006 +ADC18_GET_CONV =1007 +ADC18_GET_INT =1008 +ADC18_GET_PED =1009 +ADC18_SET_DAC =1010 +ADC18_GET_DAC =1011 +ADC18_SET_SAMP =1012 +ADC18_GET_SAMP =1013 +GA_MAXADC =20 +DACRADIO18 =100 +GM_ADC_GET =101 +GM_ADC_SET =201 +DACTRI =0 +DACSAW =1 +DACCONST =2 +DACOFF18 =3 + +class ADC18(tk.Frame): + def __init__(self, tab): + global numADC + numADC = self.get_num_adc() + ADClabels = [] + + i = 0 + while i < numADC: + ADClabels.append(self.get_label_adc(i)) + i += 1 + + self.rt_spec_frame = tk.LabelFrame(tab, text='RHRS', background=u.green_color) + self.adc_ls = [] + self.int_es = [] + self.conv_es = [] + self.dac_settings = [] + self.sample_settings = [] + + i = 0 + while i < numADC: + self.adc_ls.append(tk.Label(self.rt_spec_frame, text='ADC '+str(ADClabels[i]), background=u.green_color)) + self.int_es.append(tk.Entry(self.rt_spec_frame, width=3)) + self.conv_es.append(tk.Entry(self.rt_spec_frame, width=3)) + self.dac_settings.append(tk.StringVar()) + self.sample_settings.append(tk.IntVar()) + i += 1 + + labels = ['Label', 'Int', 'Conv', '-----', 'DAC', 'Settings', '-----', 'Sample by:'] + for i, label in enumerate(labels): + tk.Label(self.rt_spec_frame, text=label, background=u.green_color).grid( + row=0, column=i, padx=8, pady=10, sticky='W') + + self.create_table(numADC) + self.check_values() + + def get_num_adc(self): + packet = [u.COMMAND_ADC18, ADC18_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 get_label_adc(self, index): + packet = [u.COMMAND_ADC18, ADC18_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 create_table(self, value): + for i in range(1, value+1): + self.adc_ls[i-1].grid(row=i, column=0, padx=10, pady=10, sticky='W') + u.set_text(self.int_es[i-1], '3').grid(row=i, column=1, padx=10, pady=10) + u.set_text(self.conv_es[i-1], '0').grid(row=i, column=2, padx=10, pady=10) + setting = self.dac_settings[i-1] + settings = ['Tri', 'Saw', 'Const', 'Off'] + setting.set('Tri') + for j,s in enumerate(settings): + tk.Radiobutton(self.rt_spec_frame, text=s, variable=setting, value=s, background=u.green_color).grid( + row=i, column=j+3, padx=5, pady=10, sticky='W') + sample_by = self.sample_settings[i-1] + sample_by.set(1) + tk.OptionMenu(self.rt_spec_frame, sample_by, 1, 2, 4, 8).grid(row=i, column=7) + tk.Button(self.rt_spec_frame, text='Get Settings', background=u.green_color, command=self.check_values).grid( + row=6, column=1, columnspan=2, pady=50, sticky='S') + tk.Button(self.rt_spec_frame, text='Apply Settings', background=u.green_color, command=self.set_values).grid( + row=6, column=3, columnspan=2, pady=50, sticky='S') + tk.Button(self.rt_spec_frame, text='Cancel', background=u.green_color, command=self.check_values).grid( + row=6, column=5, pady=50, sticky='S') + self.rt_spec_frame.pack(padx=20, pady=20) + + 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_RHRS, 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_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 + + packet = [u.COMMAND_ADC18, ADC18_GET_CONV, i, 0, 0, "ADC18 Get Conv", "Y"] + err_flag, reply = u.send_command(u.Crate_RHRS, 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_RHRS, 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_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_RHRS, 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_RHRS, 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_RHRS, 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_RHRS, packet) + + if err_flag == u.SOCK_OK: + pass + else: + print("ERROR, Could not access socket.") + return -1 + i += 1 + + self.check_values() From 01c78ba536ecffae165a7325b06320dd92a6c952 Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Thu, 30 May 2019 22:49:45 -0400 Subject: [PATCH 03/30] testing general funtion in timeboard --- tabs/gm_timeboard.py | 54 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 3c97874..84ee2ef 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -22,6 +22,10 @@ class Timeboard(tk.Frame): def __init__(self, tab): self.ch_frame = tk.LabelFrame(tab, text='CH', background=u.green_color, width=500) + self.inj_frame = tk.LabelFrame(tab, text='Inj', background=u.green_color, width=500) + self.lft_spec_frame = tk.LabelFrame(tab, text='LftSpec', background=u.green_color, width=500) + self.rt_spec_frame = tk.LabelFrame(tab, text='RtSpec', background=u.green_color, width=500) + self.ramp_delay_l = tk.Label(self.ch_frame, text='Ramp Delay', background=u.green_color) self.int_time_l = tk.Label(self.ch_frame, text='Integrate Time', background=u.green_color) self.oversamp_l = tk.Label(self.ch_frame, text='Oversampling', background=u.green_color) @@ -41,7 +45,6 @@ def __init__(self, tab): row=3, column=1, pady=10) self.ch_frame.pack(padx=20, pady=10, anchor='w') - self.rt_spec_frame = tk.LabelFrame(tab, text='RtSpec', background=u.green_color, width=500) self.rt_spec_ramp_delay_l = tk.Label(self.rt_spec_frame, text='Ramp Delay', background=u.green_color) self.rt_spec_int_time_l = tk.Label(self.rt_spec_frame, text='Integrate Time', background=u.green_color) self.rt_spec_oversamp_l = tk.Label(self.rt_spec_frame, text='Oversampling', background=u.green_color) @@ -61,9 +64,54 @@ def __init__(self, tab): row=3, column=1, pady=10) self.rt_spec_frame.pack(padx=20, pady=10, anchor='w') - self.check_values_ch() - self.check_values_rt_spec() + #self.check_values_ch() + #self.check_values_rt_spec() + self.check_values(u.Crate_CH) + def check_values(self,crate): + packet1 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_RD, 0, 0, "TB Get Data", "Y"] + err_flag, reply1 = u.send_command(crate, 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.ramp_delay_e.delete(0, tk.END) + self.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, packet2) + + if err_flag == u.SOCK_OK: + CurrentIT = int(reply2[3]) + self.int_time_e.delete(0, tk.END) + self.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, packet3) + + if err_flag == u.SOCK_OK: + CurrentOS = int(reply3[3]) + self.oversamp_e.delete(0, tk.END) + self.oversamp_e.insert(0, str(CurrentOS)) + print("Oversampling is " + str(CurrentOS)) + + else: + print("ERROR, Could not access socket.") + return + def check_values_ch(self): packet1 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_RD, 0, 0, "TB Get Data", "Y"] err_flag, reply1 = u.send_command(u.Crate_CH, packet1) From 535513bd51f887e5815d23f30a2a1d2765cb2f06 Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Sat, 1 Jun 2019 16:31:46 -0400 Subject: [PATCH 04/30] testing git commands and updating functions. --- tabs/gm_timeboard.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 84ee2ef..149e8eb 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -87,7 +87,7 @@ def check_values(self,crate): return packet2 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_IT, 0, 0, "TB Get Data", "Y"] - err_flag, reply2 = u.send_command(u.crate, packet2) + err_flag, reply2 = u.send_command(crate, packet2) if err_flag == u.SOCK_OK: CurrentIT = int(reply2[3]) @@ -100,7 +100,7 @@ def check_values(self,crate): return packet3 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_OS, 0, 0, "TB Get Data", "Y"] - err_flag, reply3 = u.send_command(u.crate, packet3) + err_flag, reply3 = u.send_command(crate, packet3) if err_flag == u.SOCK_OK: CurrentOS = int(reply3[3]) From 9ac49d8f6f57226cb9f91ff370eda1503ba3a70f Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Sat, 1 Jun 2019 17:15:26 -0400 Subject: [PATCH 05/30] more changes to timing boards --- tabs/gm_timeboard.py | 287 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 262 insertions(+), 25 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 149e8eb..ef488f1 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -64,13 +64,52 @@ def __init__(self, tab): row=3, column=1, pady=10) self.rt_spec_frame.pack(padx=20, pady=10, anchor='w') - #self.check_values_ch() - #self.check_values_rt_spec() - self.check_values(u.Crate_CH) - - def check_values(self,crate): + self.lft_spec_ramp_delay_l = tk.Label(self.lft_spec_frame, text='Ramp Delay', background=u.green_color) + self.lft_spec_int_time_l = tk.Label(self.lft_spec_frame, text='Integrate Time', background=u.green_color) + self.lft_spec_oversamp_l = tk.Label(self.lft_spec_frame, text='Oversampling', background=u.green_color) + self.lft_spec_ramp_delay_e = tk.Entry(self.lft_spec_frame) + self.lft_spec_int_time_e = tk.Entry(self.lft_spec_frame) + self.lft_spec_oversamp_e = tk.Entry(self.lft_spec_frame) + + self.lft_spec_ramp_delay_l.grid(row=0, column=0, padx=10, pady=5, sticky='W') + self.lft_spec_int_time_l.grid(row=1, column=0, padx=10, pady=5, sticky='W') + self.lft_spec_oversamp_l.grid(row=2, column=0, padx=10, pady=5, sticky='W') + u.set_text(self.lft_spec_ramp_delay_e, '0').grid(row=0, column=1, padx=10, pady=5, sticky='W') + u.set_text(self.lft_spec_int_time_e, '0').grid(row=1, column=1, padx=10, pady=5, sticky='W') + u.set_text(self.lft_spec_oversamp_e, '0').grid(row=2, column=1, padx=10, pady=5, sticky='W') + tk.Button(self.lft_spec_frame, text='Get Settings', background=u.green_color, command=self.check_values_lft_spec).grid( + row=3, column=0, pady=10) + tk.Button(self.lft_spec_frame, text='Apply Settings', background=u.green_color, command=self.set_values_lft_spec).grid( + row=3, column=1, pady=10) + self.lft_spec_frame.pack(padx=20, pady=10, anchor='w') + + self.inj_ramp_delay_l = tk.Label(self.inj_frame, text='Ramp Delay', background=u.green_color) + self.inj_int_time_l = tk.Label(self.inj_frame, text='Integrate Time', background=u.green_color) + self.inj_oversamp_l = tk.Label(self.inj_frame, text='Oversampling', background=u.green_color) + self.inj_ramp_delay_e = tk.Entry(self.inj_frame) + self.inj_int_time_e = tk.Entry(self.inj_frame) + self.inj_oversamp_e = tk.Entry(self.inj_frame) + + self.inj_ramp_delay_l.grid(row=0, column=0, padx=10, pady=5, sticky='W') + self.inj_int_time_l.grid(row=1, column=0, padx=10, pady=5, sticky='W') + self.inj_oversamp_l.grid(row=2, column=0, padx=10, pady=5, sticky='W') + u.set_text(self.inj_ramp_delay_e, '0').grid(row=0, column=1, padx=10, pady=5, sticky='W') + u.set_text(self.inj_int_time_e, '0').grid(row=1, column=1, padx=10, pady=5, sticky='W') + u.set_text(self.inj_oversamp_e, '0').grid(row=2, column=1, padx=10, pady=5, sticky='W') + tk.Button(self.inj_frame, text='Get Settings', background=u.green_color, command=self.check_values_inj).grid( + row=3, column=0, pady=10) + tk.Button(self.inj_frame, text='Apply Settings', background=u.green_color, command=self.set_values_inj).grid( + row=3, column=1, pady=10) + self.inj_frame.pack(padx=20, pady=10, anchor='w') + + self.check_values_ch() + self.check_values_rt_spec() + self.check_values_lft_spec() + self.check_values_inj() + + def check_values_ch(self): packet1 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_RD, 0, 0, "TB Get Data", "Y"] - err_flag, reply1 = u.send_command(crate, packet1) + err_flag, reply1 = u.send_command(u.Crate_CH, packet1) print("I am here where you thought I was") print("COMMAND_HAPTB is " + str(u.COMMAND_HAPTB)) @@ -87,7 +126,7 @@ def check_values(self,crate): return packet2 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_IT, 0, 0, "TB Get Data", "Y"] - err_flag, reply2 = u.send_command(crate, packet2) + err_flag, reply2 = u.send_command(u.Crate_CH, packet2) if err_flag == u.SOCK_OK: CurrentIT = int(reply2[3]) @@ -100,7 +139,7 @@ def check_values(self,crate): return packet3 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_OS, 0, 0, "TB Get Data", "Y"] - err_flag, reply3 = u.send_command(crate, packet3) + err_flag, reply3 = u.send_command(u.Crate_CH, packet3) if err_flag == u.SOCK_OK: CurrentOS = int(reply3[3]) @@ -112,9 +151,9 @@ def check_values(self,crate): print("ERROR, Could not access socket.") return - def check_values_ch(self): + def check_values_rt_spec(self): packet1 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_RD, 0, 0, "TB Get Data", "Y"] - err_flag, reply1 = u.send_command(u.Crate_CH, packet1) + err_flag, reply1 = u.send_command(u.Crate_RHRS, packet1) print("I am here where you thought I was") print("COMMAND_HAPTB is " + str(u.COMMAND_HAPTB)) @@ -122,8 +161,8 @@ def check_values_ch(self): if err_flag == u.SOCK_OK: CurrentRD = int(reply1[3]) - self.ramp_delay_e.delete(0, tk.END) - self.ramp_delay_e.insert(0, str(CurrentRD)) + self.rt_spec_ramp_delay_e.delete(0, tk.END) + self.rt_spec_ramp_delay_e.insert(0, str(CurrentRD)) print("Ramp delay is " + str(CurrentRD)) else: @@ -131,12 +170,12 @@ def check_values_ch(self): return packet2 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_IT, 0, 0, "TB Get Data", "Y"] - err_flag, reply2 = u.send_command(u.Crate_CH, packet2) + err_flag, reply2 = u.send_command(u.Crate_RHRS, packet2) if err_flag == u.SOCK_OK: CurrentIT = int(reply2[3]) - self.int_time_e.delete(0, tk.END) - self.int_time_e.insert(0, str(CurrentIT)) + self.rt_spec_int_time_e.delete(0, tk.END) + self.rt_spec_int_time_e.insert(0, str(CurrentIT)) print("Integration time is " + str(CurrentIT)) else: @@ -144,19 +183,63 @@ def check_values_ch(self): return packet3 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_OS, 0, 0, "TB Get Data", "Y"] - err_flag, reply3 = u.send_command(u.Crate_CH, packet3) + err_flag, reply3 = u.send_command(u.Crate_RHRS, packet3) if err_flag == u.SOCK_OK: CurrentOS = int(reply3[3]) - self.oversamp_e.delete(0, tk.END) - self.oversamp_e.insert(0, str(CurrentOS)) + self.rt_spec_oversamp_e.delete(0, tk.END) + self.rt_spec_oversamp_e.insert(0, str(CurrentOS)) print("Oversampling is " + str(CurrentOS)) else: print("ERROR, Could not access socket.") return - def check_values_rt_spec(self): + def check_values_lft_spec(self): + packet1 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_RD, 0, 0, "TB Get Data", "Y"] + err_flag, reply1 = u.send_command(u.Crate_LHRS, 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.lft_spec_ramp_delay_e.delete(0, tk.END) + self.lft_spec_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_LHRS, packet2) + + if err_flag == u.SOCK_OK: + CurrentIT = int(reply2[3]) + self.lft_spec_int_time_e.delete(0, tk.END) + self.lft_spec_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_LHRS, packet3) + + if err_flag == u.SOCK_OK: + CurrentOS = int(reply3[3]) + self.lft_spec_oversamp_e.delete(0, tk.END) + self.lft_spec_oversamp_e.insert(0, str(CurrentOS)) + print("Oversampling is " + str(CurrentOS)) + + else: + print("ERROR, Could not access socket.") + return + + 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_RHRS, packet1) @@ -166,8 +249,8 @@ def check_values_rt_spec(self): if err_flag == u.SOCK_OK: CurrentRD = int(reply1[3]) - self.rt_spec_ramp_delay_e.delete(0, tk.END) - self.rt_spec_ramp_delay_e.insert(0, str(CurrentRD)) + 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: @@ -179,8 +262,8 @@ def check_values_rt_spec(self): if err_flag == u.SOCK_OK: CurrentIT = int(reply2[3]) - self.rt_spec_int_time_e.delete(0, tk.END) - self.rt_spec_int_time_e.insert(0, str(CurrentIT)) + 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: @@ -192,8 +275,8 @@ def check_values_rt_spec(self): if err_flag == u.SOCK_OK: CurrentOS = int(reply3[3]) - self.rt_spec_oversamp_e.delete(0, tk.END) - self.rt_spec_oversamp_e.insert(0, str(CurrentOS)) + self.inj_oversamp_e.delete(0, tk.END) + self.inj_oversamp_e.insert(0, str(CurrentOS)) print("Oversampling is " + str(CurrentOS)) else: @@ -353,3 +436,157 @@ def set_values_rt_spec(self): print("Unknown error, cannot set TB parameter") self.check_values_rt_spec() + + def set_values_lft_spec(self): + + value1 = int(self.lft_spec_ramp_delay_e.get()) + value2 = int(self.lft_spec_int_time_e.get()) + value3 = int(self.lft_spec_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_LHRS, 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_LHRS, 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_LHRS, 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_lft_spec() + + 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_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 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_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 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_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 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() From 1d1a9b39f82127467f65075ca5b7d5d62801b567 Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Sat, 1 Jun 2019 17:26:28 -0400 Subject: [PATCH 06/30] testing timeboard --- tabs/gm_timeboard.py | 68 ++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index ef488f1..2ce515c 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -43,26 +43,26 @@ def __init__(self, tab): row=3, column=0, pady=10) tk.Button(self.ch_frame, text='Apply Settings', background=u.green_color, command=self.set_values_ch).grid( row=3, column=1, pady=10) - self.ch_frame.pack(padx=20, pady=10, anchor='w') + self.ch_frame.pack(row=0, column=0, padx=20, pady=10, anchor='w') - self.rt_spec_ramp_delay_l = tk.Label(self.rt_spec_frame, text='Ramp Delay', background=u.green_color) - self.rt_spec_int_time_l = tk.Label(self.rt_spec_frame, text='Integrate Time', background=u.green_color) - self.rt_spec_oversamp_l = tk.Label(self.rt_spec_frame, text='Oversampling', background=u.green_color) - self.rt_spec_ramp_delay_e = tk.Entry(self.rt_spec_frame) - self.rt_spec_int_time_e = tk.Entry(self.rt_spec_frame) - self.rt_spec_oversamp_e = tk.Entry(self.rt_spec_frame) + self.inj_ramp_delay_l = tk.Label(self.inj_frame, text='Ramp Delay', background=u.green_color) + self.inj_int_time_l = tk.Label(self.inj_frame, text='Integrate Time', background=u.green_color) + self.inj_oversamp_l = tk.Label(self.inj_frame, text='Oversampling', background=u.green_color) + self.inj_ramp_delay_e = tk.Entry(self.inj_frame) + self.inj_int_time_e = tk.Entry(self.inj_frame) + self.inj_oversamp_e = tk.Entry(self.inj_frame) - self.rt_spec_ramp_delay_l.grid(row=0, column=0, padx=10, pady=5, sticky='W') - self.rt_spec_int_time_l.grid(row=1, column=0, padx=10, pady=5, sticky='W') - self.rt_spec_oversamp_l.grid(row=2, column=0, padx=10, pady=5, sticky='W') - u.set_text(self.rt_spec_ramp_delay_e, '0').grid(row=0, column=1, padx=10, pady=5, sticky='W') - u.set_text(self.rt_spec_int_time_e, '0').grid(row=1, column=1, padx=10, pady=5, sticky='W') - u.set_text(self.rt_spec_oversamp_e, '0').grid(row=2, column=1, padx=10, pady=5, sticky='W') - tk.Button(self.rt_spec_frame, text='Get Settings', background=u.green_color, command=self.check_values_rt_spec).grid( + self.inj_ramp_delay_l.grid(row=0, column=0, padx=10, pady=5, sticky='W') + self.inj_int_time_l.grid(row=1, column=0, padx=10, pady=5, sticky='W') + self.inj_oversamp_l.grid(row=2, column=0, padx=10, pady=5, sticky='W') + u.set_text(self.inj_ramp_delay_e, '0').grid(row=0, column=1, padx=10, pady=5, sticky='W') + u.set_text(self.inj_int_time_e, '0').grid(row=1, column=1, padx=10, pady=5, sticky='W') + u.set_text(self.inj_oversamp_e, '0').grid(row=2, column=1, padx=10, pady=5, sticky='W') + tk.Button(self.inj_frame, text='Get Settings', background=u.green_color, command=self.check_values_inj).grid( row=3, column=0, pady=10) - tk.Button(self.rt_spec_frame, text='Apply Settings', background=u.green_color, command=self.set_values_rt_spec).grid( + tk.Button(self.inj_frame, text='Apply Settings', background=u.green_color, command=self.set_values_inj).grid( row=3, column=1, pady=10) - self.rt_spec_frame.pack(padx=20, pady=10, anchor='w') + self.inj_frame.pack(row=0, column=1, padx=20, pady=10, anchor='w') self.lft_spec_ramp_delay_l = tk.Label(self.lft_spec_frame, text='Ramp Delay', background=u.green_color) self.lft_spec_int_time_l = tk.Label(self.lft_spec_frame, text='Integrate Time', background=u.green_color) @@ -81,31 +81,31 @@ def __init__(self, tab): row=3, column=0, pady=10) tk.Button(self.lft_spec_frame, text='Apply Settings', background=u.green_color, command=self.set_values_lft_spec).grid( row=3, column=1, pady=10) - self.lft_spec_frame.pack(padx=20, pady=10, anchor='w') + self.lft_spec_frame.pack(row=1, column=0, padx=20, pady=10, anchor='w') - self.inj_ramp_delay_l = tk.Label(self.inj_frame, text='Ramp Delay', background=u.green_color) - self.inj_int_time_l = tk.Label(self.inj_frame, text='Integrate Time', background=u.green_color) - self.inj_oversamp_l = tk.Label(self.inj_frame, text='Oversampling', background=u.green_color) - self.inj_ramp_delay_e = tk.Entry(self.inj_frame) - self.inj_int_time_e = tk.Entry(self.inj_frame) - self.inj_oversamp_e = tk.Entry(self.inj_frame) + self.rt_spec_ramp_delay_l = tk.Label(self.rt_spec_frame, text='Ramp Delay', background=u.green_color) + self.rt_spec_int_time_l = tk.Label(self.rt_spec_frame, text='Integrate Time', background=u.green_color) + self.rt_spec_oversamp_l = tk.Label(self.rt_spec_frame, text='Oversampling', background=u.green_color) + self.rt_spec_ramp_delay_e = tk.Entry(self.rt_spec_frame) + self.rt_spec_int_time_e = tk.Entry(self.rt_spec_frame) + self.rt_spec_oversamp_e = tk.Entry(self.rt_spec_frame) - self.inj_ramp_delay_l.grid(row=0, column=0, padx=10, pady=5, sticky='W') - self.inj_int_time_l.grid(row=1, column=0, padx=10, pady=5, sticky='W') - self.inj_oversamp_l.grid(row=2, column=0, padx=10, pady=5, sticky='W') - u.set_text(self.inj_ramp_delay_e, '0').grid(row=0, column=1, padx=10, pady=5, sticky='W') - u.set_text(self.inj_int_time_e, '0').grid(row=1, column=1, padx=10, pady=5, sticky='W') - u.set_text(self.inj_oversamp_e, '0').grid(row=2, column=1, padx=10, pady=5, sticky='W') - tk.Button(self.inj_frame, text='Get Settings', background=u.green_color, command=self.check_values_inj).grid( + self.rt_spec_ramp_delay_l.grid(row=0, column=0, padx=10, pady=5, sticky='W') + self.rt_spec_int_time_l.grid(row=1, column=0, padx=10, pady=5, sticky='W') + self.rt_spec_oversamp_l.grid(row=2, column=0, padx=10, pady=5, sticky='W') + u.set_text(self.rt_spec_ramp_delay_e, '0').grid(row=0, column=1, padx=10, pady=5, sticky='W') + u.set_text(self.rt_spec_int_time_e, '0').grid(row=1, column=1, padx=10, pady=5, sticky='W') + u.set_text(self.rt_spec_oversamp_e, '0').grid(row=2, column=1, padx=10, pady=5, sticky='W') + tk.Button(self.rt_spec_frame, text='Get Settings', background=u.green_color, command=self.check_values_rt_spec).grid( row=3, column=0, pady=10) - tk.Button(self.inj_frame, text='Apply Settings', background=u.green_color, command=self.set_values_inj).grid( + tk.Button(self.rt_spec_frame, text='Apply Settings', background=u.green_color, command=self.set_values_rt_spec).grid( row=3, column=1, pady=10) - self.inj_frame.pack(padx=20, pady=10, anchor='w') + self.rt_spec_frame.pack(row=1, column=1, padx=20, pady=10, anchor='w') self.check_values_ch() - self.check_values_rt_spec() - self.check_values_lft_spec() self.check_values_inj() + self.check_values_lft_spec() + self.check_values_rt_spec() def check_values_ch(self): packet1 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_RD, 0, 0, "TB Get Data", "Y"] From b7947d84cc285080f911abb712a36954ea3070ac Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Sat, 1 Jun 2019 17:29:14 -0400 Subject: [PATCH 07/30] more testing --- tabs/gm_timeboard.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 2ce515c..4ece772 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -43,7 +43,7 @@ def __init__(self, tab): row=3, column=0, pady=10) tk.Button(self.ch_frame, text='Apply Settings', background=u.green_color, command=self.set_values_ch).grid( row=3, column=1, pady=10) - self.ch_frame.pack(row=0, column=0, padx=20, pady=10, anchor='w') + self.ch_frame.pack(row=0, column=0, padx=20, pady=10) self.inj_ramp_delay_l = tk.Label(self.inj_frame, text='Ramp Delay', background=u.green_color) self.inj_int_time_l = tk.Label(self.inj_frame, text='Integrate Time', background=u.green_color) @@ -62,7 +62,7 @@ def __init__(self, tab): row=3, column=0, pady=10) tk.Button(self.inj_frame, text='Apply Settings', background=u.green_color, command=self.set_values_inj).grid( row=3, column=1, pady=10) - self.inj_frame.pack(row=0, column=1, padx=20, pady=10, anchor='w') + self.inj_frame.pack(row=0, column=1, padx=20, pady=10) self.lft_spec_ramp_delay_l = tk.Label(self.lft_spec_frame, text='Ramp Delay', background=u.green_color) self.lft_spec_int_time_l = tk.Label(self.lft_spec_frame, text='Integrate Time', background=u.green_color) @@ -81,7 +81,7 @@ def __init__(self, tab): row=3, column=0, pady=10) tk.Button(self.lft_spec_frame, text='Apply Settings', background=u.green_color, command=self.set_values_lft_spec).grid( row=3, column=1, pady=10) - self.lft_spec_frame.pack(row=1, column=0, padx=20, pady=10, anchor='w') + self.lft_spec_frame.pack(row=1, column=0, padx=20, pady=10) self.rt_spec_ramp_delay_l = tk.Label(self.rt_spec_frame, text='Ramp Delay', background=u.green_color) self.rt_spec_int_time_l = tk.Label(self.rt_spec_frame, text='Integrate Time', background=u.green_color) @@ -100,7 +100,7 @@ def __init__(self, tab): row=3, column=0, pady=10) tk.Button(self.rt_spec_frame, text='Apply Settings', background=u.green_color, command=self.set_values_rt_spec).grid( row=3, column=1, pady=10) - self.rt_spec_frame.pack(row=1, column=1, padx=20, pady=10, anchor='w') + self.rt_spec_frame.pack(row=1, column=1, padx=20, pady=10) self.check_values_ch() self.check_values_inj() From 7ed3c56a3fdc6a7f07dacb2beae6d207b507ef6e Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Sat, 1 Jun 2019 17:31:47 -0400 Subject: [PATCH 08/30] gridding broken --- tabs/gm_timeboard.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 4ece772..6a1d2f0 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -43,7 +43,7 @@ def __init__(self, tab): row=3, column=0, pady=10) tk.Button(self.ch_frame, text='Apply Settings', background=u.green_color, command=self.set_values_ch).grid( row=3, column=1, pady=10) - self.ch_frame.pack(row=0, column=0, padx=20, pady=10) + self.ch_frame.grid(row=0, column=0, padx=20, pady=10) self.inj_ramp_delay_l = tk.Label(self.inj_frame, text='Ramp Delay', background=u.green_color) self.inj_int_time_l = tk.Label(self.inj_frame, text='Integrate Time', background=u.green_color) @@ -62,7 +62,7 @@ def __init__(self, tab): row=3, column=0, pady=10) tk.Button(self.inj_frame, text='Apply Settings', background=u.green_color, command=self.set_values_inj).grid( row=3, column=1, pady=10) - self.inj_frame.pack(row=0, column=1, padx=20, pady=10) + self.inj_frame.grid(row=0, column=1, padx=20, pady=10) self.lft_spec_ramp_delay_l = tk.Label(self.lft_spec_frame, text='Ramp Delay', background=u.green_color) self.lft_spec_int_time_l = tk.Label(self.lft_spec_frame, text='Integrate Time', background=u.green_color) @@ -81,7 +81,7 @@ def __init__(self, tab): row=3, column=0, pady=10) tk.Button(self.lft_spec_frame, text='Apply Settings', background=u.green_color, command=self.set_values_lft_spec).grid( row=3, column=1, pady=10) - self.lft_spec_frame.pack(row=1, column=0, padx=20, pady=10) + self.lft_spec_frame.grid(row=1, column=0, padx=20, pady=10) self.rt_spec_ramp_delay_l = tk.Label(self.rt_spec_frame, text='Ramp Delay', background=u.green_color) self.rt_spec_int_time_l = tk.Label(self.rt_spec_frame, text='Integrate Time', background=u.green_color) @@ -100,7 +100,7 @@ def __init__(self, tab): row=3, column=0, pady=10) tk.Button(self.rt_spec_frame, text='Apply Settings', background=u.green_color, command=self.set_values_rt_spec).grid( row=3, column=1, pady=10) - self.rt_spec_frame.pack(row=1, column=1, padx=20, pady=10) + self.rt_spec_frame.grid(row=1, column=1, padx=20, pady=10) self.check_values_ch() self.check_values_inj() From e9b6bcd7019ef3a6d656cdb04710727d94a9923b Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Sat, 1 Jun 2019 17:39:54 -0400 Subject: [PATCH 09/30] testing injector timingboard --- tabs/gm_timeboard.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 6a1d2f0..73c97cd 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -241,7 +241,7 @@ def check_values_lft_spec(self): 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_RHRS, packet1) + 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)) @@ -258,7 +258,7 @@ def check_values_inj(self): return packet2 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_IT, 0, 0, "TB Get Data", "Y"] - err_flag, reply2 = u.send_command(u.Crate_RHRS, packet2) + err_flag, reply2 = u.send_command(u.Crate_INJ, packet2) if err_flag == u.SOCK_OK: CurrentIT = int(reply2[3]) @@ -271,7 +271,7 @@ def check_values_inj(self): return packet3 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_OS, 0, 0, "TB Get Data", "Y"] - err_flag, reply3 = u.send_command(u.Crate_RHRS, packet3) + err_flag, reply3 = u.send_command(u.Crate_INJ, packet3) if err_flag == u.SOCK_OK: CurrentOS = int(reply3[3]) From 11889d3a31a80391f425c45cf931f2ab3e889041 Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Sun, 2 Jun 2019 13:39:11 -0400 Subject: [PATCH 10/30] added options for all kill commands and added injector set functionality in timeboards. --- tabs/gm_timeboard.py | 6 +++--- tabs/gm_vxworks.py | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 73c97cd..f2ef84f 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -521,7 +521,7 @@ def set_values_inj(self): 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_RHRS, packet1) + err_flag, reply1 = u.send_command(u.Crate_INJ, packet1) othererror = 0 if err_flag == u.SOCK_OK: @@ -544,7 +544,7 @@ def set_values_inj(self): 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_RHRS, packet2) + err_flag, reply2 = u.send_command(u.Crate_INJ, packet2) othererror = 0 if err_flag == u.SOCK_OK: @@ -567,7 +567,7 @@ def set_values_inj(self): 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_RHRS, packet3) + err_flag, reply3 = u.send_command(u.Crate_INJ, packet3) othererror = 0 if err_flag == u.SOCK_OK: diff --git a/tabs/gm_vxworks.py b/tabs/gm_vxworks.py index e5fa886..235a6c2 100644 --- a/tabs/gm_vxworks.py +++ b/tabs/gm_vxworks.py @@ -17,4 +17,8 @@ def __init__(self, tab): row=0, column=0, padx=2, pady=2) tk.Button(self.vx_frame, text='Kill VXWorks Server, Inj', bg=u.green_color, width=30).grid( row=1, column=0, padx=2, pady=2) + tk.Button(self.vx_frame, text='Kill VXWorks Server, LftSpec', bg=u.green_color, width=30).grid( + row=2, column=0, padx=2, pady=2) + tk.Button(self.vx_frame, text='Kill VXWorks Server, RtSpec', bg=u.green_color, width=30).grid( + row=3, column=0, padx=2, pady=2) self.vx_frame.place(relx=0.5, rely=0.5, anchor=tk.CENTER) From 64e454843b0b98c47331bb2a4cf762a9447dd45b Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Sun, 2 Jun 2019 14:37:57 -0400 Subject: [PATCH 11/30] first attempt at kill server command --- tabs/gm_vxworks.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tabs/gm_vxworks.py b/tabs/gm_vxworks.py index 235a6c2..6b5ede2 100644 --- a/tabs/gm_vxworks.py +++ b/tabs/gm_vxworks.py @@ -9,11 +9,16 @@ from tkinter import ttk import utils as u + KILL_SERVER_1 =5001 + KILL_SERVER_2 =5002 + KILL_SERVER_3 =5003 + KILL_SERVER_4 =5004 + KILL_SERVER_5 =5005 class VXWorks(tk.Frame): def __init__(self, tab): self.vx_frame = tk.Frame(tab, bg=u.green_color) - tk.Button(self.vx_frame, text='Kill VXWorks Server, CH', bg=u.green_color, width=30).grid( + tk.Button(self.vx_frame, text='Kill VXWorks Server, CH', bg=u.green_color, width=30, command=self.kill_server(u.Crate_CH,KILL_SERVER_1)).grid( row=0, column=0, padx=2, pady=2) tk.Button(self.vx_frame, text='Kill VXWorks Server, Inj', bg=u.green_color, width=30).grid( row=1, column=0, padx=2, pady=2) @@ -22,3 +27,14 @@ def __init__(self, tab): tk.Button(self.vx_frame, text='Kill VXWorks Server, RtSpec', bg=u.green_color, width=30).grid( row=3, column=0, padx=2, pady=2) self.vx_frame.place(relx=0.5, rely=0.5, anchor=tk.CENTER) + + def kill_server(self, crate, command): + packet = [command, command, 0, 0, 0, "Kill Server", "Y"] + err_flag, reply = u.send_command(crate packet) + + if err_flag == u.SOCK_OK: + print("Killed VXWorks Server, ") + + else: + print("ERROR, Could not access socket.") + return -1 \ No newline at end of file From 6cab63d859637d038f1f9a53fcfbfe1beddb5e87 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 5 Jun 2019 11:15:48 -0400 Subject: [PATCH 12/30] Cameron's changed to make commands recognize the Y or N reply flag. currently not used. --- tabs/gm_bmw.py | 2 +- tabs/gm_vxworks.py | 44 ++++++++++++++++++++++++++------------------ utils.py | 19 +++++++++++++++---- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/tabs/gm_bmw.py b/tabs/gm_bmw.py index 721a7a2..a2f59d1 100644 --- a/tabs/gm_bmw.py +++ b/tabs/gm_bmw.py @@ -101,7 +101,7 @@ def check_status(self): 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' + 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: diff --git a/tabs/gm_vxworks.py b/tabs/gm_vxworks.py index 6b5ede2..f9d4ff9 100644 --- a/tabs/gm_vxworks.py +++ b/tabs/gm_vxworks.py @@ -9,32 +9,40 @@ from tkinter import ttk import utils as u - KILL_SERVER_1 =5001 - KILL_SERVER_2 =5002 - KILL_SERVER_3 =5003 - KILL_SERVER_4 =5004 - KILL_SERVER_5 =5005 +KILL_SERVER_1 =5001 +KILL_SERVER_2 =5002 +KILL_SERVER_3 =5003 +KILL_SERVER_4 =5004 +KILL_SERVER_5 =5005 class VXWorks(tk.Frame): def __init__(self, tab): self.vx_frame = tk.Frame(tab, bg=u.green_color) - tk.Button(self.vx_frame, text='Kill VXWorks Server, CH', bg=u.green_color, width=30, command=self.kill_server(u.Crate_CH,KILL_SERVER_1)).grid( - row=0, column=0, padx=2, pady=2) - tk.Button(self.vx_frame, text='Kill VXWorks Server, Inj', bg=u.green_color, width=30).grid( - row=1, column=0, padx=2, pady=2) - tk.Button(self.vx_frame, text='Kill VXWorks Server, LftSpec', bg=u.green_color, width=30).grid( - row=2, column=0, padx=2, pady=2) - tk.Button(self.vx_frame, text='Kill VXWorks Server, RtSpec', bg=u.green_color, width=30).grid( - row=3, column=0, padx=2, pady=2) + self.crateStrings = ["Kill VXWorks Server, CH","Kill VXWorks Server, INJ","Kill VXWorks Server, LftSpec","Kill VXWorks Server, RtSpec"] + self.crateNumbers = [u.Crate_CH,u.Crate_INJ,u.Crate_LHRS,u.Crate_RHRS] + self.buttonsList = [] + for counter in range(0,len(self.crateStrings)): + self.buttonsList.append(tk.Button(self.vx_frame, text=self.crateStrings[counter], bg=u.green_color, width=30, command=self.kill_server)) + self.buttonsList[counter].crateN = self.crateNumbers[counter] + self.buttonsList[counter].crateName = self.crateStrings[counter] + self.buttonsList[counter].config(command = lambda but=self.buttonsList[counter]: self.kill_server(but)) + + self.buttonsList[counter].grid(row=counter, column=0, padx=2, pady=2) self.vx_frame.place(relx=0.5, rely=0.5, anchor=tk.CENTER) - def kill_server(self, crate, command): - packet = [command, command, 0, 0, 0, "Kill Server", "Y"] - err_flag, reply = u.send_command(crate packet) + 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("Killed VXWorks Server, ") + print("{}".format(but.crateName)) else: print("ERROR, Could not access socket.") - return -1 \ No newline at end of file + return -1 diff --git a/utils.py b/utils.py index 1aac7d1..31d2743 100644 --- a/utils.py +++ b/utils.py @@ -50,12 +50,23 @@ def send_command(crate_num, packet): err_flag = lib.GMSockCommand(crate_num, packet[0], packet[1], packet[2], packet[3], packet[4]) + replyBool = "Y" ind = 0; reply = [] fin = open('reply.txt') - for line in fin.readlines(): - if ind < 5: reply += [int(line)] - else: reply += [str(line)] - ind += 1 + if (len(packet)>6): + replyBool = packet[6] + #print("Reply status declared = {}".format(packet[6])) + if replyBool == "Y" or replyBool == 'Y': + #print("Reply requested") + for line in fin.readlines(): + if ind < 5: + reply += [int(line)] + else: + reply += [str(line)] + ind += 1 + else: + #print("Reply not requested") + reply = "No Reply" fin.close() os.remove('reply.txt') From 8e96ab6045154302c209885e965332e9199c9102 Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Thu, 6 Jun 2019 12:22:39 -0400 Subject: [PATCH 13/30] testing default reading --- tabs/gm_timeboard.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index f2ef84f..3a26229 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -18,6 +18,7 @@ HAPTB_RD =201 HAPTB_IT =202 HAPTB_OS =221 +PATH ="/adaqfs/home/apar/devices/crl/vqwkTiming.flags" class Timeboard(tk.Frame): def __init__(self, tab): @@ -106,6 +107,19 @@ def __init__(self, tab): self.check_values_inj() self.check_values_lft_spec() self.check_values_rt_spec() + self.read_defaults() + + def read_defaults(self): + infile = open(path,'r') + for line in infile: + if (line[0] == ';'): + continue + else: + delayCH = int(line[(line.index("HAPTB_delay_CH=") + 14):line.index(",HAPTB_int_time_CH=")]) + print(delayCH) + + def set_defaults(self): + return def check_values_ch(self): packet1 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_RD, 0, 0, "TB Get Data", "Y"] From fee3e85b99bfb5ba09052beebeebc947c7e959c1 Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Thu, 6 Jun 2019 14:16:41 -0400 Subject: [PATCH 14/30] testing writing to file --- tabs/gm_timeboard.py | 47 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 3a26229..a8cd5ac 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -26,6 +26,7 @@ def __init__(self, tab): self.inj_frame = tk.LabelFrame(tab, text='Inj', background=u.green_color, width=500) self.lft_spec_frame = tk.LabelFrame(tab, text='LftSpec', background=u.green_color, width=500) self.rt_spec_frame = tk.LabelFrame(tab, text='RtSpec', background=u.green_color, width=500) + self.get_defaults_butt = tk.Button(tab, text='Get Defaults', background=u.green_color, width=500) self.ramp_delay_l = tk.Label(self.ch_frame, text='Ramp Delay', background=u.green_color) self.int_time_l = tk.Label(self.ch_frame, text='Integrate Time', background=u.green_color) @@ -103,6 +104,8 @@ def __init__(self, tab): row=3, column=1, pady=10) self.rt_spec_frame.grid(row=1, column=1, padx=20, pady=10) + self.get_defaults_butt.grid(row=2, column=0, padx=20, pady=10) + self.check_values_ch() self.check_values_inj() self.check_values_lft_spec() @@ -110,16 +113,52 @@ def __init__(self, tab): self.read_defaults() def read_defaults(self): - infile = open(path,'r') + infile = open(PATH,'r') for line in infile: if (line[0] == ';'): continue else: - delayCH = int(line[(line.index("HAPTB_delay_CH=") + 14):line.index(",HAPTB_int_time_CH=")]) - print(delayCH) + delayCH = int(line[(line.index("HAPTB_delay_CH=") + 15):line.index(",HAPTB_int_time_CH=")]) + inttimeCH = int(line[(line.index("HAPTB_int_time_CH=") + 18):line.index(",HAPTB_delay_INJ=")]) + + delayINJ = int(line[(line.index("HAPTB_delay_INJ=") + 16):line.index(",HAPTB_int_time_INJ=")]) + inttimeINJ = int(line[(line.index("HAPTB_int_time_INJ=") + 19):line.index(",HAPTB_delay_RHRS=")]) + + delayRHRS = int(line[(line.index("HAPTB_delay_RHRS=") + 17):line.index(",HAPTB_int_time_RHRS=")]) + inttimeRHRS = int(line[(line.index("HAPTB_int_time_RHRS=") + 20):line.index(",HAPTB_delay_LHRS=")]) + + delayLHRS = int(line[(line.index("HAPTB_delay_LHRS=") + 17):line.index(",HAPTB_int_time_LHRS=")]) + inttimeLHRS = int(line[(line.index("HAPTB_int_time_LHRS=") + 20):]) + infile.close() def set_defaults(self): - return + delayCH = int(self.ramp_delay_e.get()) + inttimeCH = int(self.int_time_e.get()) + value3 = int(self.oversamp_e.get()) + + delayINJ = int(self.inj_ramp_delay_e.get()) + inttimeINJ = int(self.inj_int_time_e.get()) + value3 = int(self.inj_oversamp_e.get()) + + delayRHRS = int(self.rt_spec_ramp_delay_e.get()) + inttimeRHRS = int(self.rt_spec_int_time_e.get()) + value3 = int(self.rt_spec_oversamp_e.get()) + + delayLHRS = int(self.lft_spec_ramp_delay_e.get()) + inttimeLHRS = int(self.lft_spec_int_time_e.get()) + value3 = int(self.lft_spec_oversamp_e.get()) + + newdefaultstring = "AUTO_GENERATED_CONTENT=1,HAPTB_delay_CH="+str(delayCH)+",HAPTB_int_time_CH="+str(inttimeCH)+",HAPTB_delay_INJ="+str(delayINJ)+",HAPTB_int_time_INJ="+str(inttimeINJ)+",HAPTB_delay_RHRS"+str(delayRHRS)+",HAPTB_int_time_RHRS="+str(inttimeRHRS)+",HAPTB_delay_LHRS="+str(delayLHRS)+",HAPTB_int_time_LHRS="+str(inttimeLHRS) + + infile.open(PATH,'r+') + i = 0 + for line in infile: + i+=1 + if (line[0] != ';'): + line.write(";" + line) + infile.write(newdefaultstring) + infile.close() + def check_values_ch(self): packet1 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_RD, 0, 0, "TB Get Data", "Y"] From e955fdecea13f7f9eab38c11b2ef750d3e9aa578 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 6 Jun 2019 14:24:33 -0400 Subject: [PATCH 15/30] adding and removing tabs. --- GreenMonster.py | 15 +- tabs/gm_adc18_lftspec.py | 246 +++++++++++++++++++++ tabs/{gm_adc18_2.py => gm_adc18_rtspec.py} | 0 3 files changed, 255 insertions(+), 6 deletions(-) create mode 100644 tabs/gm_adc18_lftspec.py rename tabs/{gm_adc18_2.py => gm_adc18_rtspec.py} (100%) diff --git a/GreenMonster.py b/GreenMonster.py index 70f928e..e40da89 100644 --- a/GreenMonster.py +++ b/GreenMonster.py @@ -13,9 +13,10 @@ import tabs.gm_scan as scan_util import tabs.gm_timeboard as tmbd import tabs.gm_vqwk as vqwk -import tabs.gm_adc18 as adc18s -import tabs.gm_adc18_2 as adc18s_2 -import tabs.gm_vxworks as vxworks +#import tabs.gm_adc18 as adc18s +import tabs.gm_adc18_rtspec as adc18s_rtspec +import tabs.gm_adc18_lftspec as adc18s_lftspec +#import tabs.gm_vxworks as vxworks import utils as u class GreenMonster: @@ -50,9 +51,11 @@ def expert_tab(self, expt_tab): tab_control = ttk.Notebook(expt_tab) tab_titles = [('TimeBoard', tmbd.Timeboard), ('VQWK ADCs', vqwk.VQWK), - ('ADC18s, CH', adc18s.ADC18), - ('ADC18s, RtSpec', adc18s_2.ADC18), - ('VXWorks Server', vxworks.VXWorks)] + #('ADC18s, CH', adc18s.ADC18), + ('ADC18s, RtSpec', adc18s_rtspec.ADC18), + ('ADC18s, LftSpec',adc18s_lftspec.ADC18), + #('VXWorks Server', vxworks.VXWorks) + ] for title, fn in tab_titles: sub_tab = ttk.Frame(tab_control, width=800, height=600, style="My.TFrame") tab_control.add(sub_tab, text=title) diff --git a/tabs/gm_adc18_lftspec.py b/tabs/gm_adc18_lftspec.py new file mode 100644 index 0000000..56d2dde --- /dev/null +++ b/tabs/gm_adc18_lftspec.py @@ -0,0 +1,246 @@ +''' +Green Monster GUI Revamp +Containing ADC18s Tab +Code Commissioned 2019-01-16 +Code by A.J. Zec +''' + +import tkinter as tk +from tkinter import ttk +import utils as u + +ADC18_GET_NUMADC =1001 +ADC18_GET_LABEL =1002 +ADC18_GET_CSR =1003 +ADC18_SET_CONV =1004 +ADC18_SET_INT =1005 +ADC18_SET_PED =1006 +ADC18_GET_CONV =1007 +ADC18_GET_INT =1008 +ADC18_GET_PED =1009 +ADC18_SET_DAC =1010 +ADC18_GET_DAC =1011 +ADC18_SET_SAMP =1012 +ADC18_GET_SAMP =1013 +GA_MAXADC =20 +DACRADIO18 =100 +GM_ADC_GET =101 +GM_ADC_SET =201 +DACTRI =0 +DACSAW =1 +DACCONST =2 +DACOFF18 =3 + +class ADC18(tk.Frame): + def __init__(self, tab): + global numADC + numADC = self.get_num_adc() + ADClabels = [] + + i = 0 + while i < numADC: + ADClabels.append(self.get_label_adc(i)) + i += 1 + + self.lft_spec_frame = tk.LabelFrame(tab, text='LHRS', background=u.green_color) + self.adc_ls = [] + self.int_es = [] + self.conv_es = [] + self.dac_settings = [] + self.sample_settings = [] + + i = 0 + while i < numADC: + self.adc_ls.append(tk.Label(self.lft_spec_frame, text='ADC '+str(ADClabels[i]), background=u.green_color)) + self.int_es.append(tk.Entry(self.lft_spec_frame, width=3)) + self.conv_es.append(tk.Entry(self.lft_spec_frame, width=3)) + self.dac_settings.append(tk.StringVar()) + self.sample_settings.append(tk.IntVar()) + i += 1 + + labels = ['Label', 'Int', 'Conv', '-----', 'DAC', 'Settings', '-----', 'Sample by:'] + for i, label in enumerate(labels): + tk.Label(self.lft_spec_frame, text=label, background=u.green_color).grid( + row=0, column=i, padx=8, pady=10, sticky='W') + + self.create_table(numADC) + self.check_values() + + def get_num_adc(self): + packet = [u.COMMAND_ADC18, ADC18_GET_NUMADC, 0, 0, 0, "ADC Get Number", "Y"] + err_flag, reply = u.send_command(u.Crate_LHRS, packet) + + if err_flag == u.SOCK_OK: + return int(reply[3]) + + else: + print("ERROR, Could not access socket.") + return -1 + + def get_label_adc(self, index): + packet = [u.COMMAND_ADC18, ADC18_GET_LABEL, index, 0, 0, "ADC Get Label", "Y"] + err_flag, reply = u.send_command(u.Crate_LHRS, packet) + + if err_flag == u.SOCK_OK: + return int(reply[3]) + + else: + print("ERROR, Could not access socket.") + return -1 + + + def create_table(self, value): + for i in range(1, value+1): + self.adc_ls[i-1].grid(row=i, column=0, padx=10, pady=10, sticky='W') + u.set_text(self.int_es[i-1], '3').grid(row=i, column=1, padx=10, pady=10) + u.set_text(self.conv_es[i-1], '0').grid(row=i, column=2, padx=10, pady=10) + setting = self.dac_settings[i-1] + settings = ['Tri', 'Saw', 'Const', 'Off'] + setting.set('Tri') + for j,s in enumerate(settings): + tk.Radiobutton(self.lft_spec_frame, text=s, variable=setting, value=s, background=u.green_color).grid( + row=i, column=j+3, padx=5, pady=10, sticky='W') + sample_by = self.sample_settings[i-1] + sample_by.set(1) + tk.OptionMenu(self.lft_spec_frame, sample_by, 1, 2, 4, 8).grid(row=i, column=7) + tk.Button(self.lft_spec_frame, text='Get Settings', background=u.green_color, command=self.check_values).grid( + row=6, column=1, columnspan=2, pady=50, sticky='S') + tk.Button(self.lft_spec_frame, text='Apply Settings', background=u.green_color, command=self.set_values).grid( + row=6, column=3, columnspan=2, pady=50, sticky='S') + tk.Button(self.lft_spec_frame, text='Cancel', background=u.green_color, command=self.check_values).grid( + row=6, column=5, pady=50, sticky='S') + self.lft_spec_frame.pack(padx=20, pady=20) + + 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_LHRS, 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_LHRS, 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_LHRS, 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_LHRS, 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_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_LHRS, 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_LHRS, 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_LHRS, 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_LHRS, packet) + + if err_flag == u.SOCK_OK: + pass + else: + print("ERROR, Could not access socket.") + return -1 + i += 1 + + self.check_values() diff --git a/tabs/gm_adc18_2.py b/tabs/gm_adc18_rtspec.py similarity index 100% rename from tabs/gm_adc18_2.py rename to tabs/gm_adc18_rtspec.py From fe81aaaff62ef26addaa6d7730c96c98fa21046f Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 6 Jun 2019 15:28:17 -0400 Subject: [PATCH 16/30] added button to get defaults --- tabs/gm_timeboard.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index a8cd5ac..1b20d2d 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -26,7 +26,7 @@ def __init__(self, tab): self.inj_frame = tk.LabelFrame(tab, text='Inj', background=u.green_color, width=500) self.lft_spec_frame = tk.LabelFrame(tab, text='LftSpec', background=u.green_color, width=500) self.rt_spec_frame = tk.LabelFrame(tab, text='RtSpec', background=u.green_color, width=500) - self.get_defaults_butt = tk.Button(tab, text='Get Defaults', background=u.green_color, width=500) + self.defaults_frame = tk.Button(tab, text='Defaults', background=u.green_color, width=500) self.ramp_delay_l = tk.Label(self.ch_frame, text='Ramp Delay', background=u.green_color) self.int_time_l = tk.Label(self.ch_frame, text='Integrate Time', background=u.green_color) @@ -104,7 +104,9 @@ def __init__(self, tab): row=3, column=1, pady=10) self.rt_spec_frame.grid(row=1, column=1, padx=20, pady=10) - self.get_defaults_butt.grid(row=2, column=0, padx=20, pady=10) + tk.Button(self.defaults_frame, text='Get Defaults', background=u.green_color, command=self.read_defaults).grid( + row=0, column=0, pady=10) + self.defaults_frame.grid(row=2, column=0, padx=20, pady=10) self.check_values_ch() self.check_values_inj() From 7df86e29c0dc092c3361829f93e853e275874f1e Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Thu, 6 Jun 2019 16:03:39 -0400 Subject: [PATCH 17/30] added set default button --- tabs/gm_timeboard.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 1b20d2d..7e67b0a 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -106,15 +106,32 @@ def __init__(self, tab): tk.Button(self.defaults_frame, text='Get Defaults', background=u.green_color, command=self.read_defaults).grid( row=0, column=0, pady=10) + tk.Button(self.defaults_frame, text='Set Defaults', background=u.green_color, command=self.set_defaults).grid( + row=0, column=0, pady=10) self.defaults_frame.grid(row=2, column=0, padx=20, pady=10) + self.first_values() self.check_values_ch() self.check_values_inj() self.check_values_lft_spec() self.check_values_rt_spec() + + def first_values(self): self.read_defaults() + print(delayCH) + self.ramp_delay_e.delete(0, tk.END) + self.ramp_delay_e.insert(0, str(delayCH)) def read_defaults(self): + global delayCH + global inttimeCH + global delayINJ + global inttimeINJ + global delayRHRS + global inttimeRHRS + global delayLHRS + global inttimeLHRS + infile = open(PATH,'r') for line in infile: if (line[0] == ';'): From a7f041430acc14c9428b8c9997541f385ef439f9 Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Thu, 6 Jun 2019 16:24:30 -0400 Subject: [PATCH 18/30] added set all and check all. --- tabs/gm_timeboard.py | 52 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 7e67b0a..4780524 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -104,24 +104,51 @@ def __init__(self, tab): row=3, column=1, pady=10) self.rt_spec_frame.grid(row=1, column=1, padx=20, pady=10) - tk.Button(self.defaults_frame, text='Get Defaults', background=u.green_color, command=self.read_defaults).grid( + tk.Button(self.defaults_frame, text='Get All', background=u.green_color, command=self.check_all).grid( row=0, column=0, pady=10) + tk.Button(self.defaults_frame, text='Set All', background=u.green_color, command=self.set_all).grid( + row=0, column=1, pady=10) + tk.Button(self.defaults_frame, text='Get Defaults', background=u.green_color, command=self.read_defaults).grid( + row=1, column=0, pady=10) tk.Button(self.defaults_frame, text='Set Defaults', background=u.green_color, command=self.set_defaults).grid( - row=0, column=0, pady=10) + row=1, column=1, pady=10) + self.defaults_frame.grid(row=2, column=0, padx=20, pady=10) self.first_values() - self.check_values_ch() - self.check_values_inj() - self.check_values_lft_spec() - self.check_values_rt_spec() + self.check_all() def first_values(self): self.read_defaults() - print(delayCH) + self.ramp_delay_e.delete(0, tk.END) self.ramp_delay_e.insert(0, str(delayCH)) + self.int_time_e.delete(0, tk.END) + self.int_time_e.insert(0, str(inttimeCH)) + + self.inj_ramp_delay_e.delete(0, tk.END) + self.inj_ramp_delay_e.insert(0, str(delayINJ)) + + self.inj_int_time_e.delete(0, tk.END) + self.inj_int_time_e.insert(0, str(inttimeINJ)) + + self.lft_spec_ramp_delay_e.delete(0, tk.END) + self.lft_spec_ramp_delay_e.insert(0, str(delayLHRS)) + + self.lft_spec_int_time_e.delete(0, tk.END) + self.lft_spec_int_time_e.insert(0, str(inttimeLHRS)) + + self.rt_spec_ramp_delay_e.delete(0, tk.END) + self.rt_spec_ramp_delay_e.insert(0, str(delayRHRS)) + + self.rt_spec_int_time_e.delete(0, tk.END) + self.rt_spec_int_time_e.insert(0, str(inttimeRHRS)) + + #self.oversamp_e.delete(0, tk.END) + #self.oversamp_e.insert(0, str(osCH)) + #self.set_all() + def read_defaults(self): global delayCH global inttimeCH @@ -178,6 +205,17 @@ def set_defaults(self): infile.write(newdefaultstring) infile.close() + def check_all(self): + self.check_values_ch() + self.check_values_inj() + self.check_values_lft_spec() + self.check_values_rt_spec() + + def set_all(self): + self.set_values_ch() + self.set_values_inj() + self.set_values_lft_spec() + self.set_values_rt_spec() def check_values_ch(self): packet1 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_RD, 0, 0, "TB Get Data", "Y"] From 92963dbaa239aac3099de505c220cf5431324076 Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Thu, 6 Jun 2019 16:30:31 -0400 Subject: [PATCH 19/30] trying to fix button problems --- tabs/gm_timeboard.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 4780524..3ba986d 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -105,15 +105,15 @@ def __init__(self, tab): self.rt_spec_frame.grid(row=1, column=1, padx=20, pady=10) tk.Button(self.defaults_frame, text='Get All', background=u.green_color, command=self.check_all).grid( - row=0, column=0, pady=10) + row=0, column=0, padx=10, pady=10) tk.Button(self.defaults_frame, text='Set All', background=u.green_color, command=self.set_all).grid( - row=0, column=1, pady=10) + row=0, column=1, padx=10, pady=10) tk.Button(self.defaults_frame, text='Get Defaults', background=u.green_color, command=self.read_defaults).grid( - row=1, column=0, pady=10) + row=1, column=0, padx=10, pady=10) tk.Button(self.defaults_frame, text='Set Defaults', background=u.green_color, command=self.set_defaults).grid( - row=1, column=1, pady=10) + row=1, column=1, padx=10, pady=10) - self.defaults_frame.grid(row=2, column=0, padx=20, pady=10) + self.defaults_frame.grid(row=2, column=0, padx=20, pady=10, columnspan=2) self.first_values() self.check_all() From 3fabf77dae5b2900c13d74477032ac6b81359127 Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Thu, 6 Jun 2019 17:10:05 -0400 Subject: [PATCH 20/30] fixed issue with frame --- tabs/gm_timeboard.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 3ba986d..e276398 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -26,7 +26,7 @@ def __init__(self, tab): self.inj_frame = tk.LabelFrame(tab, text='Inj', background=u.green_color, width=500) self.lft_spec_frame = tk.LabelFrame(tab, text='LftSpec', background=u.green_color, width=500) self.rt_spec_frame = tk.LabelFrame(tab, text='RtSpec', background=u.green_color, width=500) - self.defaults_frame = tk.Button(tab, text='Defaults', background=u.green_color, width=500) + self.defaults_frame = tk.LabelFrame(tab, text='Defaults', background=u.green_color, width=1000) self.ramp_delay_l = tk.Label(self.ch_frame, text='Ramp Delay', background=u.green_color) self.int_time_l = tk.Label(self.ch_frame, text='Integrate Time', background=u.green_color) @@ -196,12 +196,12 @@ def set_defaults(self): newdefaultstring = "AUTO_GENERATED_CONTENT=1,HAPTB_delay_CH="+str(delayCH)+",HAPTB_int_time_CH="+str(inttimeCH)+",HAPTB_delay_INJ="+str(delayINJ)+",HAPTB_int_time_INJ="+str(inttimeINJ)+",HAPTB_delay_RHRS"+str(delayRHRS)+",HAPTB_int_time_RHRS="+str(inttimeRHRS)+",HAPTB_delay_LHRS="+str(delayLHRS)+",HAPTB_int_time_LHRS="+str(inttimeLHRS) - infile.open(PATH,'r+') + infile = open(PATH,'r+') i = 0 for line in infile: i+=1 if (line[0] != ';'): - line.write(";" + line) + infile.write(";" + line) infile.write(newdefaultstring) infile.close() From 8543d215352aa276b755724c392dbe5f1c1b0081 Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Thu, 6 Jun 2019 18:36:53 -0400 Subject: [PATCH 21/30] fixing issues writing to defaults. --- tabs/gm_timeboard.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index e276398..547af57 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -196,15 +196,38 @@ def set_defaults(self): newdefaultstring = "AUTO_GENERATED_CONTENT=1,HAPTB_delay_CH="+str(delayCH)+",HAPTB_int_time_CH="+str(inttimeCH)+",HAPTB_delay_INJ="+str(delayINJ)+",HAPTB_int_time_INJ="+str(inttimeINJ)+",HAPTB_delay_RHRS"+str(delayRHRS)+",HAPTB_int_time_RHRS="+str(inttimeRHRS)+",HAPTB_delay_LHRS="+str(delayLHRS)+",HAPTB_int_time_LHRS="+str(inttimeLHRS) - infile = open(PATH,'r+') + #infile = open(PATH,'r+') + #i = 0 + #for line in infile: + # i+=1 + # if (line[0] != ';'): + # infile.write(";" + line) + #infile.write(newdefaultstring) + #infile.close() + + buff = [] i = 0 + infile = open(PATH,'r') for line in infile: - i+=1 + buff.append(line) if (line[0] != ';'): - infile.write(";" + line) - infile.write(newdefaultstring) + buff[i] = (";" + line) + i+=1 infile.close() + buff.append(newdefaultstring) + + with open(PATH, 'a') as f: + # Get the previous contents + lines = f.readlines() + + # Overwrite + for i in range(len(buff)): + f.write(buff[i]) + if len(lines) > len(buff): + for i in range(len(buff), len(lines)): + f.write(lines[i]) + def check_all(self): self.check_values_ch() self.check_values_inj() From 2eb3c9b26b2513624da2afb00f04cb7c5208ba35 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 6 Jun 2019 21:08:08 -0400 Subject: [PATCH 22/30] finished fixing buttons for setting defaults. --- tabs/gm_timeboard.py | 85 +++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 52 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 547af57..b4105af 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -115,39 +115,9 @@ def __init__(self, tab): self.defaults_frame.grid(row=2, column=0, padx=20, pady=10, columnspan=2) - self.first_values() - self.check_all() - - def first_values(self): self.read_defaults() - - self.ramp_delay_e.delete(0, tk.END) - self.ramp_delay_e.insert(0, str(delayCH)) - - self.int_time_e.delete(0, tk.END) - self.int_time_e.insert(0, str(inttimeCH)) - - self.inj_ramp_delay_e.delete(0, tk.END) - self.inj_ramp_delay_e.insert(0, str(delayINJ)) - - self.inj_int_time_e.delete(0, tk.END) - self.inj_int_time_e.insert(0, str(inttimeINJ)) - - self.lft_spec_ramp_delay_e.delete(0, tk.END) - self.lft_spec_ramp_delay_e.insert(0, str(delayLHRS)) - - self.lft_spec_int_time_e.delete(0, tk.END) - self.lft_spec_int_time_e.insert(0, str(inttimeLHRS)) - - self.rt_spec_ramp_delay_e.delete(0, tk.END) - self.rt_spec_ramp_delay_e.insert(0, str(delayRHRS)) - - self.rt_spec_int_time_e.delete(0, tk.END) - self.rt_spec_int_time_e.insert(0, str(inttimeRHRS)) - - #self.oversamp_e.delete(0, tk.END) - #self.oversamp_e.insert(0, str(osCH)) - #self.set_all() + self.set_all() + self.check_all() def read_defaults(self): global delayCH @@ -174,9 +144,33 @@ def read_defaults(self): inttimeRHRS = int(line[(line.index("HAPTB_int_time_RHRS=") + 20):line.index(",HAPTB_delay_LHRS=")]) delayLHRS = int(line[(line.index("HAPTB_delay_LHRS=") + 17):line.index(",HAPTB_int_time_LHRS=")]) - inttimeLHRS = int(line[(line.index("HAPTB_int_time_LHRS=") + 20):]) + inttimeLHRS = int(line[(line.index("HAPTB_int_time_LHRS=") + 20):line.index("\n")]) infile.close() + self.ramp_delay_e.delete(0, tk.END) + self.ramp_delay_e.insert(0, str(delayCH)) + + self.int_time_e.delete(0, tk.END) + self.int_time_e.insert(0, str(inttimeCH)) + + self.inj_ramp_delay_e.delete(0, tk.END) + self.inj_ramp_delay_e.insert(0, str(delayINJ)) + + self.inj_int_time_e.delete(0, tk.END) + self.inj_int_time_e.insert(0, str(inttimeINJ)) + + self.lft_spec_ramp_delay_e.delete(0, tk.END) + self.lft_spec_ramp_delay_e.insert(0, str(delayLHRS)) + + self.lft_spec_int_time_e.delete(0, tk.END) + self.lft_spec_int_time_e.insert(0, str(inttimeLHRS)) + + self.rt_spec_ramp_delay_e.delete(0, tk.END) + self.rt_spec_ramp_delay_e.insert(0, str(delayRHRS)) + + self.rt_spec_int_time_e.delete(0, tk.END) + self.rt_spec_int_time_e.insert(0, str(inttimeRHRS)) + def set_defaults(self): delayCH = int(self.ramp_delay_e.get()) inttimeCH = int(self.int_time_e.get()) @@ -194,16 +188,7 @@ def set_defaults(self): inttimeLHRS = int(self.lft_spec_int_time_e.get()) value3 = int(self.lft_spec_oversamp_e.get()) - newdefaultstring = "AUTO_GENERATED_CONTENT=1,HAPTB_delay_CH="+str(delayCH)+",HAPTB_int_time_CH="+str(inttimeCH)+",HAPTB_delay_INJ="+str(delayINJ)+",HAPTB_int_time_INJ="+str(inttimeINJ)+",HAPTB_delay_RHRS"+str(delayRHRS)+",HAPTB_int_time_RHRS="+str(inttimeRHRS)+",HAPTB_delay_LHRS="+str(delayLHRS)+",HAPTB_int_time_LHRS="+str(inttimeLHRS) - - #infile = open(PATH,'r+') - #i = 0 - #for line in infile: - # i+=1 - # if (line[0] != ';'): - # infile.write(";" + line) - #infile.write(newdefaultstring) - #infile.close() + newdefaultstring = "AUTO_GENERATED_CONTENT=1,HAPTB_delay_CH="+str(delayCH)+",HAPTB_int_time_CH="+str(inttimeCH)+",HAPTB_delay_INJ="+str(delayINJ)+",HAPTB_int_time_INJ="+str(inttimeINJ)+",HAPTB_delay_RHRS="+str(delayRHRS)+",HAPTB_int_time_RHRS="+str(inttimeRHRS)+",HAPTB_delay_LHRS="+str(delayLHRS)+",HAPTB_int_time_LHRS="+str(inttimeLHRS)+"\n" buff = [] i = 0 @@ -217,16 +202,11 @@ def set_defaults(self): buff.append(newdefaultstring) - with open(PATH, 'a') as f: - # Get the previous contents - lines = f.readlines() + outfile = open(PATH,'w') + for i in range(len(buff)): + outfile.write(buff[i]) + outfile.close() - # Overwrite - for i in range(len(buff)): - f.write(buff[i]) - if len(lines) > len(buff): - for i in range(len(buff), len(lines)): - f.write(lines[i]) def check_all(self): self.check_values_ch() @@ -723,3 +703,4 @@ def set_values_inj(self): print("Unknown error, cannot set TB parameter") self.check_values_inj() + From 83cdaa376a6cbf554bf8062b1aafba452225d096 Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Thu, 6 Jun 2019 23:24:40 -0400 Subject: [PATCH 23/30] added defaults buttons for vqwk tab like timeboard tab --- tabs/gm_vqwk.py | 137 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 136 insertions(+), 1 deletion(-) diff --git a/tabs/gm_vqwk.py b/tabs/gm_vqwk.py index 5ca668f..d69992f 100644 --- a/tabs/gm_vqwk.py +++ b/tabs/gm_vqwk.py @@ -18,7 +18,7 @@ VQWK_SPB =701 VQWK_GD =702 VQWK_NB =703 - +PATH ="/adaqfs/home/apar/devices/crl/injector/g0inj.flags" class VQWK(tk.Frame): def __init__(self, tab): @@ -26,6 +26,7 @@ def __init__(self, tab): self.inj_frame = tk.LabelFrame(tab, text='Inj', background=u.green_color, width=500) self.lft_spec_frame = tk.LabelFrame(tab, text='LftSpec', background=u.green_color, width=500) self.rt_spec_frame = tk.LabelFrame(tab, text='RtSpec', background=u.green_color, width=500) + self.defaults_frame = tk.LabelFrame(tab, text='Defaults', background=u.green_color, width=1000) self.samples_ch_l = tk.Label(self.ch_frame, text='Samples Per Block', background=u.green_color) self.gate_ch_l = tk.Label(self.ch_frame, text='Gate Delay', background=u.green_color) @@ -63,11 +64,145 @@ def __init__(self, tab): self.fill_rt_spec_frame() self.rt_spec_frame.grid(row=1, column=1, padx=20, pady=10) + tk.Button(self.defaults_frame, text='Get All', background=u.green_color, command=self.check_all).grid( + row=0, column=0, padx=10, pady=10) + tk.Button(self.defaults_frame, text='Set All', background=u.green_color, command=self.set_all).grid( + row=0, column=1, padx=10, pady=10) + tk.Button(self.defaults_frame, text='Get Defaults', background=u.green_color, command=self.read_defaults).grid( + row=1, column=0, padx=10, pady=10) + tk.Button(self.defaults_frame, text='Set Defaults', background=u.green_color, command=self.set_defaults).grid( + row=1, column=1, padx=10, pady=10) + + self.defaults_frame.grid(row=2, column=0, padx=20, pady=10, columnspan=2) + + self.read_defaults() + self.set_all() + self.check_all() + + def read_defaults(self): + global samplesCH + global gateCH + global blocksCH + global samplesINJ + global gateINJ + global blocksINJ + global samplesRHRS + global gateRHRS + global blocksRHRS + global samplesLHRS + global gateLHRS + global blocksLHRS + + infile = open(PATH,'r') + for line in infile: + if (line[0] == ';'): + continue + else: + samplesCH = int(line[(line.index("CHvqwksamples=") + 14):line.index(", CHvqwkdelay=")]) + gateCH = int(line[(line.index("CHvqwkdelay=") + 12):line.index(", CHvqwkblocks=")]) + blocksCH = int(line[(line.index("CHvqwkblocks=") + 13):line.index(", CHvqwkperiod=")]) + + samplesINJ = int(line[(line.index("INJvqwksamples=") + 14):line.index(", INJvqwkdelay=")]) + gateINJ = int(line[(line.index("INJvqwkdelay=") + 12):line.index(", INJvqwkblocks=")]) + blocksINJ = int(line[(line.index("INJvqwkblocks=") + 13):line.index(", INJvqwkperiod=")]) + + samplesRHRS = int(line[(line.index("RHRSvqwksamples=") + 14):line.index(", RHRSvqwkdelay=")]) + gateRHRS = int(line[(line.index("RHRSvqwkdelay=") + 12):line.index(", RHRSvqwkblocks=")]) + blocksRHRS = int(line[(line.index("RHRSvqwkblocks=") + 13):line.index(", RHRSvqwkperiod=")]) + + samplesLHRS = int(line[(line.index("LHRSvqwksamples=") + 14):line.index(", LHRSvqwkdelay=")]) + gateLHRS = int(line[(line.index("LHRSvqwkdelay=") + 12):line.index(", LHRSvqwkblocks=")]) + blocksLHRS = int(line[(line.index("LHRSvqwkblocks=") + 13):line.index(", LHRSvqwkperiod=")]) + infile.close() + + self.samples_ch_e.delete(0, tk.END) + self.samples_ch_e.insert(0, str(samplesCH)) + + self.gate_ch_e.delete(0, tk.END) + self.gate_ch_e.insert(0, str(gateCH)) + + self.blocks_ch_e.delete(0, tk.END) + self.blocks_ch_e.insert(0, str(blocksCH)) + + self.samples_inj_e.delete(0, tk.END) + self.samples_inj_e.insert(0, str(samplesINJ)) + + self.gate_inj_e.delete(0, tk.END) + self.gate_inj_e.insert(0, str(gateINJ)) + + self.blocks_inj_e.delete(0, tk.END) + self.blocks_inj_e.insert(0, str(blocksINJ)) + + self.samples_rt_spec_e.delete(0, tk.END) + self.samples_rt_spec_e.insert(0, str(samplesRHRS)) + + self.gate_rt_spec_e.delete(0, tk.END) + self.gate_rt_spec_e.insert(0, str(gateRHRS)) + + self.blocks_rt_spec_e.delete(0, tk.END) + self.blocks_rt_spec_e.insert(0, str(blocksRHRS)) + + self.samples_lft_spec_e.delete(0, tk.END) + self.samples_lft_spec_e.insert(0, str(samplesLHRS)) + + self.gate_lft_spec_e.delete(0, tk.END) + self.gate_lft_spec_e.insert(0, str(gateLHRS)) + + self.blocks_lft_spec_e.delete(0, tk.END) + self.blocks_lft_spec_e.insert(0, str(blocksLHRS)) + + def set_defaults(self): + samplesCH = int(self.samples_ch_e.get()) + gateCH = int(self.gate_ch_e.get()) + blocksCH = int(self.blocks_ch_e.get()) + + samplesINJ = int(self.samples_inj_e.get()) + gateINJ = int(self.gate_inj_e.get()) + blocksINJ = int(self.blocks_inj_e.get()) + + samplesRHRS = int(self.samples_rt_spec_e.get()) + gateRHRS = int(self.gate_rt_spec_e.get()) + blocksRHRS = int(self.blocks_rt_spec_e.get()) + + samplesLHRS = int(self.samples_lft_spec_e.get()) + gateLHRS = int(self.gate_lft_spec_e.get()) + blocksLHRS = int(self.blocks_lft_spec_e.get()) + + newdefaultstringCH = "CHcrateheader=3, CHbadc=0x80, CHnadc=10, CHvqwksamples="+str(samplesCH)+", CHvqwkdelay="+str(gateCH)+", CHvqwkblocks="+str(blocksCH)+", CHvqwkperiod=0, CHvqwkinternal=2, CHnscaler=1, " + newdefaultstringINJ = "INJcrateheader=3, INJbadc=0x80, INJnadc=10, INJvqwksamples="+str(samplesINJ)+", INJvqwkdelay="+str(gateINJ)+", INJvqwkblocks="+str(blocksINJ)+", INJvqwkperiod=0, INJvqwkinternal=2, INJnscaler=1, " + newdefaultstringRHRS = "RHRScrateheader=3, RHRSbadc=0x80, RHRSnadc=10, RHRSvqwksamples="+str(samplesRHRS)+", RHRSvqwkdelay="+str(gateRHRS)+", RHRSvqwkblocks="+str(blocksRHRS)+", RHRSvqwkperiod=0, RHRSvqwkinternal=2, RHRSnscaler=1, " + newdefaultstringLHRS = "LHRScrateheader=3, LHRSbadc=0x80, LHRSnadc=10, LHRSvqwksamples="+str(samplesLHRS)+", LHRSvqwkdelay="+str(gateLHRS)+", LHRSvqwkblocks="+str(blocksLHRS)+", LHRSvqwkperiod=0, LHRSvqwkinternal=2, LHRSnscaler=1\n" + + buff = [] + i = 0 + infile = open(PATH,'r') + for line in infile: + buff.append(line) + if (line[0] != ';'): + buff[i] = (";" + line) + i+=1 + infile.close() + + buff.append(newdefaultstringCH + newdefaultstringINJ + newdefaultstringRHRS + newdefaultstringLHRS) + + outfile = open(PATH,'w') + for i in range(len(buff)): + outfile.write(buff[i]) + outfile.close() + + + def check_all(self): self.check_values_ch() self.check_values_inj() self.check_values_lft_spec() self.check_values_rt_spec() + def set_all(self): + self.set_values_ch() + self.set_values_inj() + self.set_values_lft_spec() + self.set_values_rt_spec() + def fill_ch_frame(self): self.samples_ch_l.grid(row=0, column=0, padx=10, pady=5, sticky='W') self.gate_ch_l.grid(row=1, column=0, padx=10, pady=5, sticky='W') From 86d5640bd75a247b43a01b677efe0c2dc7456346 Mon Sep 17 00:00:00 2001 From: Robert Radloff Date: Thu, 6 Jun 2019 23:36:13 -0400 Subject: [PATCH 24/30] fixed indicies --- tabs/gm_vqwk.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tabs/gm_vqwk.py b/tabs/gm_vqwk.py index d69992f..32b4bb8 100644 --- a/tabs/gm_vqwk.py +++ b/tabs/gm_vqwk.py @@ -79,7 +79,7 @@ def __init__(self, tab): self.set_all() self.check_all() - def read_defaults(self): + def read_defaults(self): global samplesCH global gateCH global blocksCH @@ -102,17 +102,17 @@ def read_defaults(self): gateCH = int(line[(line.index("CHvqwkdelay=") + 12):line.index(", CHvqwkblocks=")]) blocksCH = int(line[(line.index("CHvqwkblocks=") + 13):line.index(", CHvqwkperiod=")]) - samplesINJ = int(line[(line.index("INJvqwksamples=") + 14):line.index(", INJvqwkdelay=")]) - gateINJ = int(line[(line.index("INJvqwkdelay=") + 12):line.index(", INJvqwkblocks=")]) - blocksINJ = int(line[(line.index("INJvqwkblocks=") + 13):line.index(", INJvqwkperiod=")]) + samplesINJ = int(line[(line.index("INJvqwksamples=") + 15):line.index(", INJvqwkdelay=")]) + gateINJ = int(line[(line.index("INJvqwkdelay=") + 13):line.index(", INJvqwkblocks=")]) + blocksINJ = int(line[(line.index("INJvqwkblocks=") + 14):line.index(", INJvqwkperiod=")]) - samplesRHRS = int(line[(line.index("RHRSvqwksamples=") + 14):line.index(", RHRSvqwkdelay=")]) - gateRHRS = int(line[(line.index("RHRSvqwkdelay=") + 12):line.index(", RHRSvqwkblocks=")]) - blocksRHRS = int(line[(line.index("RHRSvqwkblocks=") + 13):line.index(", RHRSvqwkperiod=")]) + samplesRHRS = int(line[(line.index("RHRSvqwksamples=") + 16):line.index(", RHRSvqwkdelay=")]) + gateRHRS = int(line[(line.index("RHRSvqwkdelay=") + 14):line.index(", RHRSvqwkblocks=")]) + blocksRHRS = int(line[(line.index("RHRSvqwkblocks=") + 15):line.index(", RHRSvqwkperiod=")]) - samplesLHRS = int(line[(line.index("LHRSvqwksamples=") + 14):line.index(", LHRSvqwkdelay=")]) - gateLHRS = int(line[(line.index("LHRSvqwkdelay=") + 12):line.index(", LHRSvqwkblocks=")]) - blocksLHRS = int(line[(line.index("LHRSvqwkblocks=") + 13):line.index(", LHRSvqwkperiod=")]) + samplesLHRS = int(line[(line.index("LHRSvqwksamples=") + 16):line.index(", LHRSvqwkdelay=")]) + gateLHRS = int(line[(line.index("LHRSvqwkdelay=") + 14):line.index(", LHRSvqwkblocks=")]) + blocksLHRS = int(line[(line.index("LHRSvqwkblocks=") + 15):line.index(", LHRSvqwkperiod=")]) infile.close() self.samples_ch_e.delete(0, tk.END) From 7735a2ef5e4e094689fe77e8e9b37b9d8f25a54b Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 7 Jun 2019 15:19:56 -0400 Subject: [PATCH 25/30] changed button text, changed flag file arguments back to default. --- tabs/gm_timeboard.py | 19 ++++++------ tabs/gm_vqwk.py | 71 ++++++++++++++++++++++++++++---------------- 2 files changed, 55 insertions(+), 35 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index b4105af..09b01d1 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -22,11 +22,11 @@ class Timeboard(tk.Frame): def __init__(self, tab): - self.ch_frame = tk.LabelFrame(tab, text='CH', background=u.green_color, width=500) - self.inj_frame = tk.LabelFrame(tab, text='Inj', background=u.green_color, width=500) - self.lft_spec_frame = tk.LabelFrame(tab, text='LftSpec', background=u.green_color, width=500) - self.rt_spec_frame = tk.LabelFrame(tab, text='RtSpec', background=u.green_color, width=500) - self.defaults_frame = tk.LabelFrame(tab, text='Defaults', background=u.green_color, width=1000) + self.ch_frame = tk.LabelFrame(tab, text='Counting House', background=u.green_color, width=500) + self.inj_frame = tk.LabelFrame(tab, text='Injector', background=u.green_color, width=500) + self.lft_spec_frame = tk.LabelFrame(tab, text='Left Spectrometer', background=u.green_color, width=500) + self.rt_spec_frame = tk.LabelFrame(tab, text='Right Spectrometer', background=u.green_color, width=500) + self.defaults_frame = tk.LabelFrame(tab, text='Default Controls', background=u.green_color, width=1000) self.ramp_delay_l = tk.Label(self.ch_frame, text='Ramp Delay', background=u.green_color) self.int_time_l = tk.Label(self.ch_frame, text='Integrate Time', background=u.green_color) @@ -104,15 +104,16 @@ def __init__(self, tab): row=3, column=1, pady=10) self.rt_spec_frame.grid(row=1, column=1, padx=20, pady=10) - tk.Button(self.defaults_frame, text='Get All', background=u.green_color, command=self.check_all).grid( + tk.Button(self.defaults_frame, text='Get All Values From Boards', background=u.green_color, command=self.check_all).grid( row=0, column=0, padx=10, pady=10) - tk.Button(self.defaults_frame, text='Set All', background=u.green_color, command=self.set_all).grid( + tk.Button(self.defaults_frame, text='Set All Values to Boards', background=u.green_color, command=self.set_all).grid( row=0, column=1, padx=10, pady=10) - tk.Button(self.defaults_frame, text='Get Defaults', background=u.green_color, command=self.read_defaults).grid( + tk.Button(self.defaults_frame, text='Get Default Values From File', background=u.green_color, command=self.read_defaults).grid( row=1, column=0, padx=10, pady=10) - tk.Button(self.defaults_frame, text='Set Defaults', background=u.green_color, command=self.set_defaults).grid( + tk.Button(self.defaults_frame, text='Write Values to Defaults File', background=u.green_color, command=self.set_defaults).grid( row=1, column=1, padx=10, pady=10) + self.defaults_frame.grid(row=2, column=0, padx=20, pady=10, columnspan=2) self.read_defaults() diff --git a/tabs/gm_vqwk.py b/tabs/gm_vqwk.py index 32b4bb8..62a89ec 100644 --- a/tabs/gm_vqwk.py +++ b/tabs/gm_vqwk.py @@ -22,11 +22,11 @@ class VQWK(tk.Frame): def __init__(self, tab): - self.ch_frame = tk.LabelFrame(tab, text='CH', background=u.green_color, width=500) - self.inj_frame = tk.LabelFrame(tab, text='Inj', background=u.green_color, width=500) - self.lft_spec_frame = tk.LabelFrame(tab, text='LftSpec', background=u.green_color, width=500) - self.rt_spec_frame = tk.LabelFrame(tab, text='RtSpec', background=u.green_color, width=500) - self.defaults_frame = tk.LabelFrame(tab, text='Defaults', background=u.green_color, width=1000) + self.ch_frame = tk.LabelFrame(tab, text='Counting House', background=u.green_color, width=500) + self.inj_frame = tk.LabelFrame(tab, text='Injector', background=u.green_color, width=500) + self.lft_spec_frame = tk.LabelFrame(tab, text='Left Spectrometer', background=u.green_color, width=500) + self.rt_spec_frame = tk.LabelFrame(tab, text='Right Spectrometer', background=u.green_color, width=500) + self.defaults_frame = tk.LabelFrame(tab, text='Default Controls', background=u.green_color, width=1000) self.samples_ch_l = tk.Label(self.ch_frame, text='Samples Per Block', background=u.green_color) self.gate_ch_l = tk.Label(self.ch_frame, text='Gate Delay', background=u.green_color) @@ -64,13 +64,13 @@ def __init__(self, tab): self.fill_rt_spec_frame() self.rt_spec_frame.grid(row=1, column=1, padx=20, pady=10) - tk.Button(self.defaults_frame, text='Get All', background=u.green_color, command=self.check_all).grid( + tk.Button(self.defaults_frame, text='Get All Values From Boards', background=u.green_color, command=self.check_all).grid( row=0, column=0, padx=10, pady=10) - tk.Button(self.defaults_frame, text='Set All', background=u.green_color, command=self.set_all).grid( + tk.Button(self.defaults_frame, text='Set All Values to Boards', background=u.green_color, command=self.set_all).grid( row=0, column=1, padx=10, pady=10) - tk.Button(self.defaults_frame, text='Get Defaults', background=u.green_color, command=self.read_defaults).grid( + tk.Button(self.defaults_frame, text='Get All Default Values From Inj File', background=u.green_color, command=self.read_defaults).grid( row=1, column=0, padx=10, pady=10) - tk.Button(self.defaults_frame, text='Set Defaults', background=u.green_color, command=self.set_defaults).grid( + tk.Button(self.defaults_frame, text='Write Inj Values to Defaults File', background=u.green_color, command=self.set_defaults).grid( row=1, column=1, padx=10, pady=10) self.defaults_frame.grid(row=2, column=0, padx=20, pady=10, columnspan=2) @@ -98,21 +98,37 @@ def read_defaults(self): if (line[0] == ';'): continue else: - samplesCH = int(line[(line.index("CHvqwksamples=") + 14):line.index(", CHvqwkdelay=")]) - gateCH = int(line[(line.index("CHvqwkdelay=") + 12):line.index(", CHvqwkblocks=")]) - blocksCH = int(line[(line.index("CHvqwkblocks=") + 13):line.index(", CHvqwkperiod=")]) + samplesINJ = int(line[(line.index("vqwksamples=") + 12):line.index(",vqwkdelay=")]) + gateINJ = int(line[(line.index("vqwkdelay=") + 10):line.index(",vqwkblocks=")]) + blocksINJ = int(line[(line.index("vqwkblocks=") + 11):line.index(",vqwkperiod=")]) - samplesINJ = int(line[(line.index("INJvqwksamples=") + 15):line.index(", INJvqwkdelay=")]) - gateINJ = int(line[(line.index("INJvqwkdelay=") + 13):line.index(", INJvqwkblocks=")]) - blocksINJ = int(line[(line.index("INJvqwkblocks=") + 14):line.index(", INJvqwkperiod=")]) + samplesCH = samplesINJ + samplesRHRS = samplesINJ + samplesLHRS = samplesINJ - samplesRHRS = int(line[(line.index("RHRSvqwksamples=") + 16):line.index(", RHRSvqwkdelay=")]) - gateRHRS = int(line[(line.index("RHRSvqwkdelay=") + 14):line.index(", RHRSvqwkblocks=")]) - blocksRHRS = int(line[(line.index("RHRSvqwkblocks=") + 15):line.index(", RHRSvqwkperiod=")]) + gateCH = gateINJ + gateRHRS = gateINJ + gateLHRS = gateINJ - samplesLHRS = int(line[(line.index("LHRSvqwksamples=") + 16):line.index(", LHRSvqwkdelay=")]) - gateLHRS = int(line[(line.index("LHRSvqwkdelay=") + 14):line.index(", LHRSvqwkblocks=")]) - blocksLHRS = int(line[(line.index("LHRSvqwkblocks=") + 15):line.index(", LHRSvqwkperiod=")]) + blocksCH = blocksINJ + blocksRHRS = blocksINJ + blocksLHRS = blocksINJ + + #samplesCH = int(line[(line.index("CHvqwksamples=") + 14):line.index(", CHvqwkdelay=")]) + #gateCH = int(line[(line.index("CHvqwkdelay=") + 12):line.index(", CHvqwkblocks=")]) + #blocksCH = int(line[(line.index("CHvqwkblocks=") + 13):line.index(", CHvqwkperiod=")]) + + #samplesINJ = int(line[(line.index("INJvqwksamples=") + 15):line.index(", INJvqwkdelay=")]) + #gateINJ = int(line[(line.index("INJvqwkdelay=") + 13):line.index(", INJvqwkblocks=")]) + #blocksINJ = int(line[(line.index("INJvqwkblocks=") + 14):line.index(", INJvqwkperiod=")]) + + #samplesRHRS = int(line[(line.index("RHRSvqwksamples=") + 16):line.index(", RHRSvqwkdelay=")]) + #gateRHRS = int(line[(line.index("RHRSvqwkdelay=") + 14):line.index(", RHRSvqwkblocks=")]) + #blocksRHRS = int(line[(line.index("RHRSvqwkblocks=") + 15):line.index(", RHRSvqwkperiod=")]) + + #samplesLHRS = int(line[(line.index("LHRSvqwksamples=") + 16):line.index(", LHRSvqwkdelay=")]) + #gateLHRS = int(line[(line.index("LHRSvqwkdelay=") + 14):line.index(", LHRSvqwkblocks=")]) + #blocksLHRS = int(line[(line.index("LHRSvqwkblocks=") + 15):line.index(", LHRSvqwkperiod=")]) infile.close() self.samples_ch_e.delete(0, tk.END) @@ -168,10 +184,12 @@ def set_defaults(self): gateLHRS = int(self.gate_lft_spec_e.get()) blocksLHRS = int(self.blocks_lft_spec_e.get()) - newdefaultstringCH = "CHcrateheader=3, CHbadc=0x80, CHnadc=10, CHvqwksamples="+str(samplesCH)+", CHvqwkdelay="+str(gateCH)+", CHvqwkblocks="+str(blocksCH)+", CHvqwkperiod=0, CHvqwkinternal=2, CHnscaler=1, " - newdefaultstringINJ = "INJcrateheader=3, INJbadc=0x80, INJnadc=10, INJvqwksamples="+str(samplesINJ)+", INJvqwkdelay="+str(gateINJ)+", INJvqwkblocks="+str(blocksINJ)+", INJvqwkperiod=0, INJvqwkinternal=2, INJnscaler=1, " - newdefaultstringRHRS = "RHRScrateheader=3, RHRSbadc=0x80, RHRSnadc=10, RHRSvqwksamples="+str(samplesRHRS)+", RHRSvqwkdelay="+str(gateRHRS)+", RHRSvqwkblocks="+str(blocksRHRS)+", RHRSvqwkperiod=0, RHRSvqwkinternal=2, RHRSnscaler=1, " - newdefaultstringLHRS = "LHRScrateheader=3, LHRSbadc=0x80, LHRSnadc=10, LHRSvqwksamples="+str(samplesLHRS)+", LHRSvqwkdelay="+str(gateLHRS)+", LHRSvqwkblocks="+str(blocksLHRS)+", LHRSvqwkperiod=0, LHRSvqwkinternal=2, LHRSnscaler=1\n" + newdefaultstring = "crateheader=3,badc=0x80,nadc=10,vqwksamples="+str(samplesCH)+",vqwkdelay="+str(gateCH)+",vqwkblocks="+str(blocksCH)+",vqwkperiod=0,vqwkinternal=2,nscaler=1\n" + + #newdefaultstringCH = "CHcrateheader=3, CHbadc=0x80, CHnadc=10, CHvqwksamples="+str(samplesCH)+", CHvqwkdelay="+str(gateCH)+", CHvqwkblocks="+str(blocksCH)+", CHvqwkperiod=0, CHvqwkinternal=2, CHnscaler=1, " + #newdefaultstringINJ = "INJcrateheader=3, INJbadc=0x80, INJnadc=10, INJvqwksamples="+str(samplesINJ)+", INJvqwkdelay="+str(gateINJ)+", INJvqwkblocks="+str(blocksINJ)+", INJvqwkperiod=0, INJvqwkinternal=2, INJnscaler=1, " + #newdefaultstringRHRS = "RHRScrateheader=3, RHRSbadc=0x80, RHRSnadc=10, RHRSvqwksamples="+str(samplesRHRS)+", RHRSvqwkdelay="+str(gateRHRS)+", RHRSvqwkblocks="+str(blocksRHRS)+", RHRSvqwkperiod=0, RHRSvqwkinternal=2, RHRSnscaler=1, " + #newdefaultstringLHRS = "LHRScrateheader=3, LHRSbadc=0x80, LHRSnadc=10, LHRSvqwksamples="+str(samplesLHRS)+", LHRSvqwkdelay="+str(gateLHRS)+", LHRSvqwkblocks="+str(blocksLHRS)+", LHRSvqwkperiod=0, LHRSvqwkinternal=2, LHRSnscaler=1\n" buff = [] i = 0 @@ -183,7 +201,8 @@ def set_defaults(self): i+=1 infile.close() - buff.append(newdefaultstringCH + newdefaultstringINJ + newdefaultstringRHRS + newdefaultstringLHRS) + buff.append(newdefaultstring) + #buff.append(newdefaultstringCH + newdefaultstringINJ + newdefaultstringRHRS + newdefaultstringLHRS) outfile = open(PATH,'w') for i in range(len(buff)): From ff725b377177967315f6b3b41632ad0f47f6fcdd Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 10 Jun 2019 11:16:52 -0400 Subject: [PATCH 26/30] changed default file reading and writing to only edit lines below autogenerated warning. --- tabs/gm_timeboard.py | 15 +++++++++++---- tabs/gm_vqwk.py | 15 +++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 09b01d1..0a0c9a6 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -193,12 +193,19 @@ def set_defaults(self): buff = [] i = 0 + autogen = 0 infile = open(PATH,'r') for line in infile: - buff.append(line) - if (line[0] != ';'): - buff[i] = (";" + line) - i+=1 + if (line == ";;;;;;;LINES BELOW ARE AUTOGENERATED;;;;;;;\n"): + autogen = 1 + buff.append(line) + i+=1 + continue + if (autogen == 0): + buff.append(line) + i+=1 + if (line[0] != ';' and autogen == 0): + buff[i-1] = (";" + line) infile.close() buff.append(newdefaultstring) diff --git a/tabs/gm_vqwk.py b/tabs/gm_vqwk.py index 62a89ec..bdf5162 100644 --- a/tabs/gm_vqwk.py +++ b/tabs/gm_vqwk.py @@ -193,12 +193,19 @@ def set_defaults(self): buff = [] i = 0 + autogen = 0 infile = open(PATH,'r') for line in infile: - buff.append(line) - if (line[0] != ';'): - buff[i] = (";" + line) - i+=1 + if (line == ";;;;;;;LINES BELOW ARE AUTOGENERATED;;;;;;;\n"): + autogen = 1 + buff.append(line) + i+=1 + continue + if (autogen == 0): + buff.append(line) + i+=1 + if (line[0] != ';' and autogen == 0): + buff[i-1] = (";" + line) infile.close() buff.append(newdefaultstring) From 095d8449ae23b874fe4fd6ff893f7bbd3809b23c Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 20 Jun 2019 09:14:05 -0400 Subject: [PATCH 27/30] Small fixes to scan and default reading. Scan tab wasnt updating the values at the right times. the vqwk and timeboard tabs no longer read from the defaults file on startup. --- tabs/gm_scan.py | 123 +++++++++++-------------------------------- tabs/gm_timeboard.py | 4 +- tabs/gm_vqwk.py | 4 +- 3 files changed, 35 insertions(+), 96 deletions(-) diff --git a/tabs/gm_scan.py b/tabs/gm_scan.py index b78fda3..9af28b0 100644 --- a/tabs/gm_scan.py +++ b/tabs/gm_scan.py @@ -42,10 +42,9 @@ def __init__(self, tab): value=op, bg=u.green_color, command=self.set_status).grid(row=0, column=i, padx=10, pady=10, sticky='W') self.fill_inj_frame() self.inj_frame.grid(row=1, column=0, columnspan=2, padx=10, pady=10, sticky='W') - tk.Button(self.util_frame, text='Check Status', bg=u.green_color, command=self.check_status).grid(row=2, column=0, padx=10, pady=10) + tk.Button(self.util_frame, text='Check Values', bg=u.green_color, command=self.check_values).grid(row=2, column=0, padx=10, pady=10) tk.Button(self.util_frame, text='Set Values', bg=u.green_color, command=self.set_values).grid(row=2, column=1, padx=10, pady=10) self.util_frame.pack(padx=20, pady=20, anchor='w') - self.check_status() self.check_values() def fill_inj_frame(self): @@ -72,58 +71,24 @@ def check_status(self): return 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) + i = 0 + while i < 4: + packet = [u.COMMAND_SCAN, SCAN_GET_DATA, i+1, 0, 0, "Check SCN Data Value", "Y"] + err_flag, reply = u.send_command(u.Crate_INJ, packet) - 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 + if err_flag == u.SOCK_OK: + value = int(reply[3]) + self.inj_entries[i].delete(0, tk.END) + self.inj_entries[i].insert(0, str(value)) + print("Value is " + str(value)) - 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: + else: + print(" check_status: ERROR, Could not access socket.") + return - 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)) + i += 1 - else: - print(" check_status: ERROR, Could not access socket.") - return + self.check_status() def set_status(self): if self.clean_setting.get() == 'CLEAN': @@ -131,6 +96,8 @@ def set_status(self): else: status = 0 + self.set_values() + packet = [u.COMMAND_SCAN, SCAN_SET_STATUS, status, 0, 0, "SCN Status Change", "Y"] err_flag, reply = u.send_command(u.Crate_INJ, packet) @@ -140,51 +107,23 @@ def set_status(self): else: print(" check_status: ERROR, Could not access socket.") - 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 + self.check_values() - 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) + def set_values(self): + i = 0 + while i < 4: + value = int(self.inj_entries[i].get()) + packet = [u.COMMAND_SCAN, SCAN_SET_DATA, i+1, value, 0, "Set SCN Data Value", "Y"] + err_flag, reply = u.send_command(u.Crate_INJ, packet) - 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 + if err_flag == u.SOCK_OK: + print("Writing new SCAN set point " + str(value) + " to data " + str(i)) - 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 - else: - print(" check_status: ERROR, Could not access socket.") - return + i += 1 self.check_values() + diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index 0a0c9a6..ecd4581 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -116,8 +116,8 @@ def __init__(self, tab): self.defaults_frame.grid(row=2, column=0, padx=20, pady=10, columnspan=2) - self.read_defaults() - self.set_all() + #self.read_defaults() + #self.set_all() self.check_all() def read_defaults(self): diff --git a/tabs/gm_vqwk.py b/tabs/gm_vqwk.py index bdf5162..1e24b4e 100644 --- a/tabs/gm_vqwk.py +++ b/tabs/gm_vqwk.py @@ -75,8 +75,8 @@ def __init__(self, tab): self.defaults_frame.grid(row=2, column=0, padx=20, pady=10, columnspan=2) - self.read_defaults() - self.set_all() + #self.read_defaults() + #self.set_all() self.check_all() def read_defaults(self): From 1d3b57031167cfd2e91b746d2890172d52132b8c Mon Sep 17 00:00:00 2001 From: Cameron Clarke Date: Sat, 4 Jan 2020 12:26:13 -0500 Subject: [PATCH 28/30] Adding an EPICs value acquisition system and timer to scan util tab --- GreenMonster.py | 5 ++- tabs/gm_scan.py | 108 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 109 insertions(+), 4 deletions(-) diff --git a/GreenMonster.py b/GreenMonster.py index e40da89..2c0131c 100644 --- a/GreenMonster.py +++ b/GreenMonster.py @@ -74,7 +74,10 @@ def create_widgets(self): for title, fn in tab_titles: tab = ttk.Frame(tab_control, width=800, height=600, style="My.TFrame") tab_control.add(tab, text=title) - fn(tab) + if "ScanUtil" in title: + fn(tab,self) + else: + fn(tab) tab_control.grid(row=0, column=0, columnspan=2) fenway = tk.PhotoImage(file='gm.ppm') fenway_pahk = tk.Label(self.win, image=fenway, cursor="hand2", bg=u.green_color) diff --git a/tabs/gm_scan.py b/tabs/gm_scan.py index 9af28b0..23b0efd 100644 --- a/tabs/gm_scan.py +++ b/tabs/gm_scan.py @@ -8,6 +8,8 @@ import tkinter as tk from tkinter import ttk import utils as u +import os +import subprocess SCAN_GET_DATA =1001 SCAN_SET_DATA =1002 @@ -23,9 +25,10 @@ SCN_INT_NOT =0 class ScanUtil(tk.Frame): - def __init__(self, tab): + def __init__(self, tab, gm): self.util_frame = tk.LabelFrame(tab, text='SCAN UTILITY', bg=u.green_color) - self.options = ['CLEAN', 'NOT CLEAN'] + self.GM = gm + self.options = ['CLEAN', 'NOT CLEAN', 'GRAB EPICS/NOT CLEAN'] self.clean_setting = tk.StringVar() self.clean_setting.set(self.options[0]) self.inj_frame = tk.LabelFrame(self.util_frame, text='Inj', bg=u.green_color) @@ -37,21 +40,90 @@ def __init__(self, tab): tk.Entry(self.inj_frame), tk.Entry(self.inj_frame), tk.Entry(self.inj_frame)] + self.epics_frame = tk.LabelFrame(self.util_frame, text='EPICS', bg=u.green_color) + self.epics_labels = [tk.Label(self.epics_frame, text='Epics Variable 1', bg=u.green_color), + tk.Label(self.epics_frame, text='Epics Variable 2', bg=u.green_color), + tk.Label(self.epics_frame, text='Epics Variable 3', bg=u.green_color), + tk.Label(self.epics_frame, text='Epics Variable 4', bg=u.green_color)] + self.epics_entries = [tk.Entry(self.epics_frame), + tk.Entry(self.epics_frame), + tk.Entry(self.epics_frame), + tk.Entry(self.epics_frame)] + self.timer_frame = tk.LabelFrame(self.util_frame, text='Timer (seconds)', bg=u.green_color) + self.timer_labels = [tk.Label(self.timer_frame, text='0', fg='#ffffff', bg='#3C5353', padx=10, pady=10)] + self.timer_entries = [tk.Entry(self.timer_frame)] for i, op in enumerate(self.options): tk.Radiobutton(self.util_frame, text=op, variable=self.clean_setting, value=op, bg=u.green_color, command=self.set_status).grid(row=0, column=i, padx=10, pady=10, sticky='W') self.fill_inj_frame() self.inj_frame.grid(row=1, column=0, columnspan=2, padx=10, pady=10, sticky='W') + self.fill_epics_frame() + self.epics_frame.grid(row=1, column=2, columnspan=1, padx=10, pady=10, sticky='W') + self.fill_timer_frame() + self.timer_frame.grid(row=3, column=0, columnspan=5, padx=10, pady=10, sticky='W') tk.Button(self.util_frame, text='Check Values', bg=u.green_color, command=self.check_values).grid(row=2, column=0, padx=10, pady=10) tk.Button(self.util_frame, text='Set Values', bg=u.green_color, command=self.set_values).grid(row=2, column=1, padx=10, pady=10) + tk.Button(self.util_frame, text='Grab EPICS', bg=u.green_color, command=self.check_EPICS).grid(row=2, column=2, padx=10, pady=10) + tk.Button(self.timer_frame, text='Start', bg=u.green_color, command=lambda: self.start_timer()).grid(row=0, column=2, padx=5, pady=5) + tk.Button(self.timer_frame, text='Pause', bg=u.green_color, command=lambda: self.pause_timer()).grid(row=0, column=3, padx=5, pady=5) + tk.Button(self.timer_frame, text='Clear', bg=u.green_color, command=lambda: self.clear_timer()).grid(row=0, column=4, padx=5, pady=5) self.util_frame.pack(padx=20, pady=20, anchor='w') self.check_values() + self.startTimer = False + self.timer_loop() def fill_inj_frame(self): for r in range(0, 4): self.inj_labels[r].grid(row=r, column=0, padx=15, pady=10, sticky='E') u.set_text(self.inj_entries[r], '0').grid(row=r, column=1, padx=10, pady=10, sticky='W') + def fill_epics_frame(self): + for r in range(0, 4): + self.epics_labels[r].grid(row=r, column=0, padx=15, pady=10, sticky='E') + u.set_text(self.epics_entries[r], 'None').grid(row=r, column=1, padx=10, pady=10, sticky='W') + + def fill_timer_frame(self): + self.timer_labels[0].grid(row=0, column=0, padx=15, pady=10, sticky='E') + u.set_text(self.timer_entries[0], '0').grid(row=0, column=1, padx=10, pady=10, sticky='W') + + def start_timer(self): + self.startTimer = True + self.timer_labels[0].config(text=self.timer_entries[0].get()) + + def timer_loop(self): + # Make a timing thing: + if self.startTimer is True: + try: + localTime = int(float(self.timer_labels[0].cget("text"))) + except ValueError: + localTime = 0 + if localTime<=0: + localTime = 0 + self.startTimer = False + self.timer_frame.config(bg='#9E1A1A') + self.timer_labels[0].config(bg='#3E1515') + else: + localTime = localTime - 1 + self.timer_labels[0].config(text=str(localTime)) + #self.timer_entries[0].delete(0, tk.END) + #self.timer_entries[0].insert(0, str(localTime)) + self.GM.win.after(1000,self.timer_loop) # Recursion loop here - splits off a new instance of this function and finishes the one currently running (be careful) + #else: + # gm.win.after(1000,self.timer_loop(gm),gm) # Recursion loop here - splits off a new instance of this function and finishes the one currently running (be careful) + + def pause_timer(self): + self.startTimer = False + self.timer_frame.config(bg=u.green_color) + self.timer_labels[0].config(bg='#3C5353') + + def clear_timer(self): + self.startTimer = False + self.timer_labels[0].config(text='0') + #self.timer_entries[0].delete(0, tk.END) + #self.timer_entries[0].insert(0, '0') + self.timer_frame.config(bg=u.green_color) + self.timer_labels[0].config(bg='#3C5353') + 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) @@ -90,12 +162,42 @@ def check_values(self): self.check_status() + def check_EPICS(self): + i = 0 + while i < 4: + # if inj_ + cmds = ['caget', '-t', '-w 1', self.epics_entries[i].get()] + value = "NULL" + if "None" not in self.epics_entries[i].get(): + value = subprocess.Popen(cmds, stdout=subprocess.PIPE).stdout.read().strip().decode('ascii') # Needs to be decoded... be careful + if value != "NULL" and "Invalid" not in value: + #self.inj_entries[i] = str(value) + value = int(round(float(value))) + self.inj_entries[i].delete(0, tk.END) + self.inj_entries[i].insert(0, str(value)) + i += 1 + self.check_status() + def set_status(self): if self.clean_setting.get() == 'CLEAN': status = 1 else: status = 0 + if self.clean_setting.get() == 'GRAB EPICS/NOT CLEAN': + i = 0 + while i < 4: + # if inj_ + cmds = ['caget', '-t', '-w 1', self.epics_entries[i].get()] + value = "NULL" + if "None" not in self.epics_entries[i].get(): + value = subprocess.Popen(cmds, stdout=subprocess.PIPE).stdout.read().strip().decode('ascii') # Needs to be decoded... be careful + if value != "NULL" and "Invalid" not in value: + #self.inj_entries[i] = str(value) + self.inj_entries[i].delete(0, tk.END) + self.inj_entries[i].insert(0, str(value)) + i += 1 + self.set_values() packet = [u.COMMAND_SCAN, SCAN_SET_STATUS, status, 0, 0, "SCN Status Change", "Y"] @@ -112,7 +214,7 @@ def set_status(self): def set_values(self): i = 0 while i < 4: - value = int(self.inj_entries[i].get()) + value = int(round(float(self.inj_entries[i].get()))) packet = [u.COMMAND_SCAN, SCAN_SET_DATA, i+1, value, 0, "Set SCN Data Value", "Y"] err_flag, reply = u.send_command(u.Crate_INJ, packet) From f97b17010d2fc31a10e80c1844a2d40db1947189 Mon Sep 17 00:00:00 2001 From: Cameron Clarke Date: Sat, 4 Jan 2020 14:45:43 -0500 Subject: [PATCH 29/30] Start refreshes alarm color too --- tabs/gm_scan.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tabs/gm_scan.py b/tabs/gm_scan.py index 23b0efd..c3b9416 100644 --- a/tabs/gm_scan.py +++ b/tabs/gm_scan.py @@ -89,6 +89,8 @@ def fill_timer_frame(self): def start_timer(self): self.startTimer = True self.timer_labels[0].config(text=self.timer_entries[0].get()) + self.timer_frame.config(bg=u.green_color) + self.timer_labels[0].config(bg='#3C5353') def timer_loop(self): # Make a timing thing: From c948cdd317e1d14a07ea05bdde5d1e91db8461c2 Mon Sep 17 00:00:00 2001 From: Cameron Clarke Date: Mon, 6 Jul 2020 13:51:40 -0400 Subject: [PATCH 30/30] Adding a feature to look at a local adaq system file to check HRS If boolean false then don't load HRS related methods at boot --- GreenMonster.py | 34 +++++++++++++++++++++++++++------- includeHRS.flags | 1 + tabs/gm_timeboard.py | 25 +++++++++++++++++++++---- tabs/gm_vqwk.py | 24 ++++++++++++++++++++---- 4 files changed, 69 insertions(+), 15 deletions(-) create mode 100644 includeHRS.flags diff --git a/GreenMonster.py b/GreenMonster.py index 2c0131c..3409070 100644 --- a/GreenMonster.py +++ b/GreenMonster.py @@ -6,6 +6,7 @@ import tkinter as tk from tkinter import ttk +import distutils.util import os import webbrowser @@ -47,15 +48,34 @@ def quit(self): def educate_yourself(self, event): webbrowser.open_new(r"https://en.wikipedia.org/wiki/Green_Monster") + def checkHRSflag(self): + hrsinfile = open("/adaqfs/home/apar/devices/PyGreenMonster/includeHRS.flags",'r') + tmp="False" + for line in hrsinfile: + print("Include HRSs = " + line) + tmp=bool(distutils.util.strtobool(line.strip('\n'))) + print("Include HRSs = " + str(tmp)) + return tmp + def expert_tab(self, expt_tab): tab_control = ttk.Notebook(expt_tab) - tab_titles = [('TimeBoard', tmbd.Timeboard), - ('VQWK ADCs', vqwk.VQWK), - #('ADC18s, CH', adc18s.ADC18), - ('ADC18s, RtSpec', adc18s_rtspec.ADC18), - ('ADC18s, LftSpec',adc18s_lftspec.ADC18), - #('VXWorks Server', vxworks.VXWorks) - ] + tab_titles = [] + if self.checkHRSflag(): + tab_titles = [('TimeBoard', tmbd.Timeboard), + ('VQWK ADCs', vqwk.VQWK), + #('ADC18s, CH', adc18s.ADC18), + # FIXME No HRSs + ('ADC18s, RtSpec', adc18s_rtspec.ADC18), + ('ADC18s, LftSpec',adc18s_lftspec.ADC18), + #('VXWorks Server', vxworks.VXWorks) + ] + else: + tab_titles = [('TimeBoard', tmbd.Timeboard), + ('VQWK ADCs', vqwk.VQWK), + #('ADC18s, CH', adc18s.ADC18), + # FIXME No HRSs + #('VXWorks Server', vxworks.VXWorks) + ] for title, fn in tab_titles: sub_tab = ttk.Frame(tab_control, width=800, height=600, style="My.TFrame") tab_control.add(sub_tab, text=title) diff --git a/includeHRS.flags b/includeHRS.flags new file mode 100644 index 0000000..bc59c12 --- /dev/null +++ b/includeHRS.flags @@ -0,0 +1 @@ +False diff --git a/tabs/gm_timeboard.py b/tabs/gm_timeboard.py index ecd4581..6455d30 100644 --- a/tabs/gm_timeboard.py +++ b/tabs/gm_timeboard.py @@ -8,6 +8,7 @@ import tkinter as tk from tkinter import ttk import utils as u +import distutils.util from ctypes import cdll GM_HAPTB =1000 @@ -19,6 +20,7 @@ HAPTB_IT =202 HAPTB_OS =221 PATH ="/adaqfs/home/apar/devices/crl/vqwkTiming.flags" +HRSFLAG ="/adaqfs/home/apar/devices/PyGreenMonster/includeHRS.flags" class Timeboard(tk.Frame): def __init__(self, tab): @@ -34,6 +36,7 @@ def __init__(self, tab): self.ramp_delay_e = tk.Entry(self.ch_frame) self.int_time_e = tk.Entry(self.ch_frame) self.oversamp_e = tk.Entry(self.ch_frame) + self.includeHRSs = self.checkHRSflag(); self.ramp_delay_l.grid(row=0, column=0, padx=10, pady=5, sticky='W') self.int_time_l.grid(row=1, column=0, padx=10, pady=5, sticky='W') @@ -120,6 +123,16 @@ def __init__(self, tab): #self.set_all() self.check_all() + def checkHRSflag(self): + hrsinfile = open(HRSFLAG,'r') + tmp="False" + for line in hrsinfile: + print("Include HRSs = " + line) + tmp=bool(distutils.util.strtobool(line.strip('\n'))) + print("Include HRSs = " + str(tmp)) + return tmp + + def read_defaults(self): global delayCH global inttimeCH @@ -219,14 +232,18 @@ def set_defaults(self): def check_all(self): self.check_values_ch() self.check_values_inj() - self.check_values_lft_spec() - self.check_values_rt_spec() + # no HRS + if self.includeHRSs: + self.check_values_lft_spec() + self.check_values_rt_spec() def set_all(self): self.set_values_ch() self.set_values_inj() - self.set_values_lft_spec() - self.set_values_rt_spec() + #no HRS + if self.includeHRSs: + self.set_values_lft_spec() + self.set_values_rt_spec() def check_values_ch(self): packet1 = [u.COMMAND_HAPTB, HAPTB_GET_DATA, HAPTB_RD, 0, 0, "TB Get Data", "Y"] diff --git a/tabs/gm_vqwk.py b/tabs/gm_vqwk.py index 1e24b4e..ca198be 100644 --- a/tabs/gm_vqwk.py +++ b/tabs/gm_vqwk.py @@ -8,6 +8,7 @@ import tkinter as tk from tkinter import ttk import utils as u +import distutils.util from ctypes import cdll GM_VQWK =7000 @@ -19,6 +20,7 @@ VQWK_GD =702 VQWK_NB =703 PATH ="/adaqfs/home/apar/devices/crl/injector/g0inj.flags" +HRSFLAG ="/adaqfs/home/apar/devices/PyGreenMonster/includeHRS.flags" class VQWK(tk.Frame): def __init__(self, tab): @@ -34,6 +36,7 @@ def __init__(self, tab): self.samples_ch_e = tk.Entry(self.ch_frame) self.gate_ch_e = tk.Entry(self.ch_frame) self.blocks_ch_e = tk.Entry(self.ch_frame) + self.includeHRSs = self.checkHRSflag(); self.fill_ch_frame() self.ch_frame.grid(row=0, column=0, padx=20, pady=10) @@ -79,6 +82,15 @@ def __init__(self, tab): #self.set_all() self.check_all() + def checkHRSflag(self): + hrsinfile = open(HRSFLAG,'r') + tmp="False" + for line in hrsinfile: + print("Include HRSs = " + line) + tmp=bool(distutils.util.strtobool(line.strip('\n'))) + print("Include HRSs = " + str(tmp)) + return tmp + def read_defaults(self): global samplesCH global gateCH @@ -220,14 +232,18 @@ def set_defaults(self): def check_all(self): self.check_values_ch() self.check_values_inj() - self.check_values_lft_spec() - self.check_values_rt_spec() + # no HRS + if self.includeHRSs: + self.check_values_lft_spec() + self.check_values_rt_spec() def set_all(self): self.set_values_ch() self.set_values_inj() - self.set_values_lft_spec() - self.set_values_rt_spec() + # no HRS + if self.includeHRSs: + self.set_values_lft_spec() + self.set_values_rt_spec() def fill_ch_frame(self): self.samples_ch_l.grid(row=0, column=0, padx=10, pady=5, sticky='W')