Commit 4534a75b authored by Matheus Müller's avatar Matheus Müller
Browse files

Pause debugado, implementado LLDT, modificacoes graficas

parent 13f6bbcd
......@@ -94,7 +94,7 @@ int main(int argc, char **argv)
{
int w;
unsigned int histograma[8192];
unsigned int temp = 0;
unsigned int temp = 0, lldt=10;
unsigned int tempo_pause = 0;
unsigned int nmr_ADC_pause=0;
unsigned int tempo_pause_vivo=0;
......@@ -114,7 +114,7 @@ int main(int argc, char **argv)
N957_UINT16 *data_buff= NULL; // read data buffer
unsigned long *histo_buff= NULL; // Histogram data buffer
int32_t tot_data_read= 0;
int i;
int ii, i;
char aux_string[ 100];
BOOL paused= FALSE;
BOOL do_exit= FALSE;
......@@ -174,7 +174,9 @@ int main(int argc, char **argv)
{
ret_val= -5;
goto exit_point;
}
}
N957_SetLLD( user_setting.m_N957_handle, lldt );
if( ( N957_error_code=N957_GetTimer(user_setting.m_N957_handle, &data32)!= N957Success))
{
ret_val= -6;
......@@ -230,6 +232,7 @@ int main(int argc, char **argv)
do_exit= FALSE;
while( !do_exit) {
N957_UINT16 data_read;
......@@ -255,8 +258,11 @@ int main(int argc, char **argv)
}
tot_data_read+= data_read;
if(paused)
goto dentro_for;
if(paused) {
i=0; // goto nao zerava o i
goto dentro_for; // por causa data_read =0, quando pausado
}
for( i= 0; i< data_read; i++) {
dentro_for:
// Check for user commands
......@@ -299,6 +305,7 @@ dentro_for:
tempo_pause = tempo_pause + data32;
N957_GetLiveTime(user_setting.m_N957_handle, &data32);
tempo_pause_vivo = tempo_pause_vivo + data32;
if( ( N957_error_code= N957_StartAcquire( user_setting.m_N957_handle, user_setting.m_mode))!= N957Success)
{
ret_val= -8;
......@@ -357,8 +364,8 @@ dentro_for:
TRACE("[");
for(w=0; w<(8192-fator+1); w)
{
for(i=w; i<=(w+fator-1); i++)
temp = temp + histograma[i];
for(ii=w; ii<=(w+fator-1); ii++)
temp = temp + histograma[ii];
TRACE1("%i",temp);
if (w!=(8192-fator))
TRACE(",");
......@@ -373,6 +380,13 @@ dentro_for:
N957_GetLiveTime(user_setting.m_N957_handle, &data32);
TRACE1("%d\n",data32 +tempo_pause_vivo);
break;
case 'j':
lldt = lldt + 1;
break;
case 'l':
N957_SetLLD( user_setting.m_N957_handle, lldt);
lldt=0;
break;
case 'z':
log = fopen("save.dat", "w+");
for(w=0; w<8192; w++)
......@@ -395,7 +409,7 @@ dentro_for:
}
}
// Calculate the histogram
++histo_buff[ data_buff[ i]& ( N957_MAX_HISTO_SAMPLES- 1)];
// Log to file (if enabled)
......
......@@ -113,7 +113,8 @@ class InterestRegion:
self.Area = self.Area + Data[n]
self.label2['text']='Total counts: %d' %self.Area
else:
tkMessageBox.showinfo("Error", "Invalid values")
self.label2['text']="Invalid values"
#tkMessageBox.showinfo("Error", "Invalid values")
def roiroi():
global ROIs
......@@ -202,7 +203,7 @@ def graphic(): # Le os dados
settime()
def dump(): # Sinal para programa coletor enviar os dados
global child
global child
child.send('i')
def realtimeplot(): # Funcao recursiva para plot em tempo real
......@@ -241,17 +242,6 @@ def pause(): # Para/Continua a aquisicao de dados
Interface['labels'][3]['text'] = 'Acquiring'
realtimeplot()
def restart(): # Reinicia o programa de aquisicao (não funciona)
global child
Control['paused'] = True
child.send('j')
time.sleep(1)
child = pexpect.spawn('./N957Run')
time.sleep(3.3)
child.send('s')
Interface['buttons'][0].invoke()
Control['paused'] = False
def save(): # Salva os dados no arquivo selecionado
global child, Data
Control['count'] = Control['count'] + 1
......@@ -298,6 +288,7 @@ def refreshrate(): # Define a frequencia de atualizacao do grafico
if int(rrent.get()) > 99: # Valores muito baixos causam stack overflow
Control['t'] = int(rrent.get())
Interface['labels'][4].configure(text = ' Refresh Rate %dms' %Control['t'])
rrwin.destroy()
else:
tkMessageBox.showinfo("Warning", "This refresh rate is likely to reach maximum recursion depht!")
else:
......@@ -307,6 +298,30 @@ def refreshrate(): # Define a frequencia de atualizacao do grafico
rrbut.pack(side='left')
rrwin.mainloop()
def lldt():
Interface['buttons'][1].invoke()
lldtwin = tk.Tk()
lldtwin.title('Low level Detect Treshold')
lldtent = tk.Entry(lldtwin)
lldtent.pack(side='left')
lldtlab = tk.Label(lldtwin, text='%')
lldtlab.pack(side='left')
def setlldt():
global child
if lldtent.get().isdigit():
if int(lldtent.get()) < 100: # Percentual
for k in arange(0, int(lldtent.get()), 1):
child.send('j')
child.send('l')
lldtwin.destroy()
else:
tkMessageBox.showinfo("Error", "Invalid value; Percent based")
lldtbut = tk.Button(lldtwin, text = 'Set', command = lambda i=i: setlldt(), bd=2, width=7, height=1)
lldtbut.pack(side='left')
lldtwin.mainloop()
##############################################################################
##############################################################################
# Safe Exit
......@@ -348,11 +363,11 @@ Interface['spinboxes'][0].pack()
menubar = tk.Menu(root, relief='raised', bd=2)
filemenu = tk.Menu(menubar, tearoff=0)
filemenu.add_command(label="Open", command = lambda i=i:load())
#filemenu.add_command(label="Restart Program", command = lambda i=i:restart())
filemenu.add_command(label="Exit", command = sys.exit)
settings = tk.Menu(menubar, tearoff=0)
settings.add_command(label="Refresh Rate", command = lambda i=i:refreshrate())
settings.add_command(label="Low level detect treshold", command = lambda i=i:lldt())
settings.add_command(label="Plot Refresh Rate", command = lambda i=i:refreshrate())
settings.add_command(label="Regions of Interest", command = lambda i=i: roiroi())
menubar.add_cascade(label="File", menu=filemenu)
......@@ -374,7 +389,7 @@ for i in range(3):
Interface['frames'][i+7].pack(side = 'left', fill='x', expand=1)
Interface['labels'].insert(3,tk.Label(Interface['frames'][7], text='Acquiring', anchor='w'))
Interface['labels'].insert(4,tk.Label(Interface['frames'][8], text='Refresh Rate %dms' %Control['t'], anchor='center'))
Interface['labels'].insert(4,tk.Label(Interface['frames'][8], text='Plot Refresh Rate %dms' %Control['t'], anchor='center'))
Interface['labels'].insert(5,tk.Label(Interface['frames'][9], text='%s.%d' %(Control['filename'], Control['count']), anchor='e'))
for n in arange(3,6):
......@@ -478,6 +493,8 @@ root.bind_all("<Alt-KeyPress-1>", key_1)
root.bind_all("<Alt-KeyPress-2>", key_1)
root.bind_all("<Alt-KeyPress-3>", key_2)
root.bind_all("<Alt-KeyPress-6>", key_3)
root.bind_all("<Alt-KeyPress-4>", save)
root.bind_all("<Alt-KeyPress-5>", saveas)
##############################################################################
##############################################################################
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment