Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1729f17
Added funtionality to the scan, adc18, timeboard, and vqwk tabs.
May 27, 2019
eeafe3a
added adc18 tabs
May 30, 2019
01c78ba
testing general funtion in timeboard
rr521111 May 31, 2019
535513b
testing git commands and updating functions.
rr521111 Jun 1, 2019
9ac49d8
more changes to timing boards
rr521111 Jun 1, 2019
1d1a9b3
testing timeboard
rr521111 Jun 1, 2019
b7947d8
more testing
rr521111 Jun 1, 2019
7ed3c56
gridding broken
rr521111 Jun 1, 2019
e9b6bcd
testing injector timingboard
rr521111 Jun 1, 2019
11889d3
added options for all kill commands and added injector set functional…
rr521111 Jun 2, 2019
64e4548
first attempt at kill server command
rr521111 Jun 2, 2019
6cab63d
Cameron's changed to make commands recognize the Y or N reply flag. c…
Jun 5, 2019
8e96ab6
testing default reading
rr521111 Jun 6, 2019
fee3e85
testing writing to file
rr521111 Jun 6, 2019
e955fde
adding and removing tabs.
Jun 6, 2019
fe81aaa
added button to get defaults
Jun 6, 2019
7df86e2
added set default button
rr521111 Jun 6, 2019
a7f0414
added set all and check all.
rr521111 Jun 6, 2019
92963db
trying to fix button problems
rr521111 Jun 6, 2019
3fabf77
fixed issue with frame
rr521111 Jun 6, 2019
8543d21
fixing issues writing to defaults.
rr521111 Jun 6, 2019
2eb3c9b
finished fixing buttons for setting defaults.
Jun 7, 2019
83cdaa3
added defaults buttons for vqwk tab like timeboard tab
rr521111 Jun 7, 2019
86d5640
fixed indicies
rr521111 Jun 7, 2019
7735a2e
changed button text, changed flag file arguments back to default.
Jun 7, 2019
ff725b3
changed default file reading and writing to only edit lines below aut…
Jun 10, 2019
095d844
Small fixes to scan and default reading.
Jun 20, 2019
1d3b570
Adding an EPICs value acquisition system and timer to scan util tab
cameronc137 Jan 4, 2020
f97b170
Start refreshes alarm color too
cameronc137 Jan 4, 2020
c948cdd
Adding a feature to look at a local adaq system file to check HRS
cameronc137 Jul 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 35 additions & 7 deletions GreenMonster.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@

import tkinter as tk
from tkinter import ttk
import distutils.util
import os
import webbrowser

import tabs.gm_bmw as bmw
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_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:
Expand Down Expand Up @@ -45,12 +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),
('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)
Expand All @@ -69,7 +94,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)
Expand Down
1 change: 1 addition & 0 deletions includeHRS.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
False
224 changes: 224 additions & 0 deletions tabs/gm_adc16.py
Original file line number Diff line number Diff line change
@@ -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()
Loading