Commit d00e9996 authored by Julio Tambara's avatar Julio Tambara
Browse files

Adicionado novo slot(python) para o segundo detector

parent e89d1570
......@@ -120,50 +120,7 @@ int main(int argc, char **argv)
}
}
switch( getch()) {
case 's':
case 'S':
break;
default:
TRACE("erro_4");
goto exit_point;
}
if( N957_GetScaler(user_setting.m_N957_handle, &data32))
{
TRACE("erro_5");
goto exit_point;
}
N957_SetLLD( user_setting.m_N957_handle, lldt );
//if( N957_GetTimer(user_setting.m_N957_handle, &data32)!= N957Success))
//{
// ret_val= -6;
// goto exit_point;
//}
//if(N957_GetLiveTime(user_setting.m_N957_handle, &data32))
//{
// TRACE("erro_7");
// goto exit_point;
//}
if(N957_StartAcquire( user_setting.m_N957_handle, user_setting.m_mode))
{
TRACE("erro_6");
goto exit_point;
}
if( user_setting.m_debug) {
if( (N957_SetSwConvFlag( user_setting.m_N957_handle, N957_TRUE)))
{
TRACE("erro_7");
goto exit_point;
}
}
data_buff= malloc( user_setting.m_bldim* sizeof( N957_UINT16));
if( data_buff== NULL)
{
......@@ -188,7 +145,7 @@ int main(int argc, char **argv)
}*/
do_exit= FALSE;
while( !do_exit) {
//TRACE("flag :1 \n");
......@@ -215,15 +172,36 @@ int main(int argc, char **argv)
goto exit_point;
}
tot_data_read+= data_read;
/*if(paused) {
i=0; // goto nao zerava o i
goto dentro_for; // por causa data_read =0, quando pausado
TRACE("Pausou");
}JULIO*/
//TRACE("flag :2 \n");
// Check for user commands
if( kbhit()) {
switch( getch()) {
case 's':
case 'S':
if( N957_GetScaler(user_setting.m_N957_handle, &data32))
{
TRACE("erro_5");
goto exit_point;
}
if(N957_StartAcquire( user_setting.m_N957_handle, user_setting.m_mode))
{
TRACE("erro_6");
goto exit_point;
}
if( user_setting.m_debug) {
if( (N957_SetSwConvFlag( user_setting.m_N957_handle, N957_TRUE)))
{
TRACE("erro_7");
goto exit_point;
}
}
break;
case 'r':
case 'R':
// reset the histogram here
......
......@@ -22,17 +22,28 @@ from matplotlib.figure import Figure
child = pexpect.spawn('./N957Run')
time.sleep(3.3)
child.send('s')
sys.setrecursionlimit(5000)
def start():
child.send('s')
time.sleep(0.2)
def teste():
child.send('teste')
##############################################################################
##############################################################################
# Histrogram
f = plt.figure()
f2 = plt.figure()
a = f.add_subplot(111)
Control = dict(t=1200, bmin=0, bmax=8192, bmaxold=512, j=0, filename='temp', count=0, paused=False, ROIctrl=list())
PlotLimControl = dict(limupdt=True, limctrl=False, x0=0, y0=0, x1=512, y1=0, pressx=0., pressy=0., limtrans=False, dx=0., dy=0., area=f.canvas.get_tk_widget().create_rectangle(0,0,0,0))
a2 = f2.add_subplot(111)
Control = dict(t=1200, bmin=0, bmax=8192, bmaxold=512, j=0, filename='temp', count=0, paused=True, ROIctrl=list(), start=False)
PlotLimControl = dict(limupdt=True, limctrl=False, x0=0, y0=0, x1=512, y1=0, pressx=0., pressy=0., limtrans=False, dx=0., dy=0.)
Data=list()
ROIs=list()
for j in range(8192):
......@@ -62,10 +73,10 @@ def beep():
##############################################################################
# Atualiza grade do plot de acordo com regiao escolhida
def grid(a, n):
a.xaxis.set_major_locator(MultipleLocator(n/8))
def grid(a, n , major,minor):
a.xaxis.set_major_locator(major)
if n > 64:
a.xaxis.set_minor_locator(MultipleLocator(n/64))
a.xaxis.set_minor_locator(minor)
a.xaxis.grid(True,'major',linewidth=2)
a.grid(True)
a.xaxis.grid(True,'minor')
......@@ -213,12 +224,23 @@ def testeerro(Data):
def graphic2(Data): #Plot
temp.set_xdata(range(int(Interface['spinboxes'][0].get())))
temp.set_ydata(Data)
if PlotLimControl['limupdt']:
plt.xlim(Control['bmin'], Control['bmax'])
plt.ylim(0, max(Data[int(Control['bmin']):int(Control['bmax'])])*1.2)
temp2.set_xdata(range(int(Interface['spinboxes'][0].get())))
temp2.set_ydata(Data)
#if PlotLimControl['limupdt']:
# plt.xlim(Control['bmin'], Control['bmax'])
# plt.ylim(0, max(Data[int(Control['bmin']):int(Control['bmax'])])*1.2)
a.relim()
a2.relim()
a.autoscale_view()
a2.autoscale_view()
major = MultipleLocator(int(Interface['spinboxes'][0].get())/8)
minor = MultipleLocator( int(Interface['spinboxes'][0].get())/64)
if PlotLimControl['limupdt'] == True:
grid(a, int(Interface['spinboxes'][0].get()))
grid(a, int(Interface['spinboxes'][0].get()),major,minor)
if PlotLimControl['limupdt'] == True:
grid(a2, int(Interface['spinboxes'][0].get()),major,minor)
f.canvas.draw()
f2.canvas.draw()
def graphic(): # Le os dados
global child, Data
......@@ -257,15 +279,23 @@ def reset(): # Zera o vetor de aquisicao
def pause(): # Para/Continua a aquisicao de dados
global child
Control['paused'] = not Control['paused']
child.send('p')
if Control['paused']:
Interface['buttons'][1]['text'] = 'Resume'
Interface['labels'][3]['text'] = 'Paused'
else:
if not Control['start']:
start()
Control['paused']= not Control['paused']
Control['start']= not Control['start']
Interface['buttons'][1]['text'] = 'Pause'
Interface['labels'][3]['text'] = 'Acquiring'
realtimeplot()
else:
Control['paused'] = not Control['paused']
child.send('p')
if Control['paused']:
Interface['buttons'][1]['text'] = 'Resume'
Interface['labels'][3]['text'] = 'Paused'
else:
Interface['buttons'][1]['text'] = 'Pause'
Interface['labels'][3]['text'] = 'Acquiring'
realtimeplot()
def save(): # Salva os dados no arquivo selecionado
global child, Data
......@@ -360,10 +390,11 @@ def shutdown():
# Interface elements
for i in range(4):
Interface['frames'].insert(i, tk.Frame(root))
if i == 2:
Interface['frames'].insert(i, tk.Frame(root, width=40))
Interface['frames'][i].pack(side='top',fill='both', expand=1)
else:
Interface['frames'].insert(i, tk.Frame(root))
Interface['frames'][i].pack(side='top',fill='x', expand=0)
Interface['labelframes'].insert(0,tk.LabelFrame(Interface['frames'][0], relief='raised', text='Bins', bd=2, pady=2, bg='grey'))
......@@ -401,26 +432,34 @@ menubar.add_cascade(label="Settings", menu=settings)
root.config(menu=menubar)
##############################################################################
Interface['buttons'].insert(0, tk.Button(Interface['frames'][0], text = 'Start', command = lambda i=i: realtimeplot(), bd=2, width=11, height=2, bg='grey'))
Interface['buttons'].insert(1, tk.Button(Interface['frames'][0], text = 'Pause', command = lambda i=i: pause(), bd=2, width=11, height=2, bg='grey'))
Interface['buttons'].insert(2, tk.Button(Interface['frames'][0], text = 'Clear', command = lambda i=i: reset(), bd=2, width=11, height=2, bg='grey'))
Interface['buttons'].insert(3, tk.Button(Interface['frames'][0], text = 'Save', command = lambda i=i: save(), bd=2, width=11, height=2, bg='grey'))
Interface['buttons'].insert(4, tk.Button(Interface['frames'][0], text = 'Save As', command = lambda i=i: saveas(), bd=2, width=11, height=2, bg='grey'))
Interface['buttons'].insert(0, tk.Button(Interface['frames'][0], text = 'Start', command = lambda i=i: realtimeplot(), bd=2, height=2, bg='grey'))
Interface['buttons'].insert(1, tk.Button(Interface['frames'][0], text = 'Start', command = lambda i=i: pause(), bd=2, height=2, bg='grey'))
Interface['buttons'].insert(2, tk.Button(Interface['frames'][0], text = 'Clear', command = lambda i=i: reset(), bd=2, height=2, bg='grey'))
Interface['buttons'].insert(3, tk.Button(Interface['frames'][0], text = 'Save', command = lambda i=i: save(), bd=2, height=2, bg='grey'))
Interface['buttons'].insert(4, tk.Button(Interface['frames'][0], text = 'Save As', command = lambda i=i: saveas(), bd=2, height=2, bg='grey'))
for i in range(4):
Interface['buttons'][i+1].pack(side = 'left', fill='both', expand=1)
#JULIO TESTE
Interface['buttons'].insert(5, tk.Button(Interface['frames'][0], text = 'Teste', command = lambda i=i: teste(), bd=2, height=2, bg='grey'))
Interface['buttons'][5].pack(side = 'left', fill='both', expand=1)
for i in range(3):
Interface['frames'].insert(i+7, tk.Frame(Interface['frames'][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(3,tk.Label(Interface['frames'][7], text='Waiting to Start', anchor='w'))
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):
Interface['labels'][n].pack(fill='x')
Interface['frames'].insert(10, tk.Frame(Interface['frames'][2], width=20)) #Plot Esquerdo
Interface['frames'].insert(11, tk.Frame(Interface['frames'][2], width=20)) #Plot Direito
Interface['frames'][10].pack(side='left',fill='both', expand=1)
Interface['frames'][11].pack(side='right',fill='both', expand=1)
##############################################################################
##############################################################################
# Key Bindings
......@@ -526,11 +565,14 @@ root.bind_all("<Alt-KeyPress-5>", saveas)
##############################################################################
# Plotting embedded
dataPlot = FigureCanvasTkAgg(f, master=Interface['frames'][2])
dataPlot = FigureCanvasTkAgg(f, master=Interface['frames'][10])
dataPlot.get_tk_widget().pack(side='top', fill='both', expand=1)
dataPlot2 = FigureCanvasTkAgg(f2, master=Interface['frames'][11])
dataPlot2.get_tk_widget().pack(side='top', fill='both', expand=1)
xx = arange(0, 8192)
temp, = a.plot(xx, xx*0, 'red', lw=0.9)
temp2, = a2.plot(xx, xx*0, 'red', lw=0.9)
xlabel('Channel')
ylabel('Counts')
cidclick = f.canvas.mpl_connect('button_press_event', key_4)
......@@ -543,7 +585,7 @@ cidrelease = f.canvas.mpl_connect('button_release_event', key_6)
for n in range(3):
Interface['spinboxes'][0].invoke('buttonup')
Interface['buttons'][0].invoke()
#Interface['buttons'][0].invoke()
root.mainloop()
##############################################################################
......
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