Commit 8f7cc0d6 authored by Julio Tambara's avatar Julio Tambara
Browse files

Teste do repositório git

parent c050db25
......@@ -100,12 +100,6 @@ int main(int argc, char **argv)
unsigned int tempo_pause_vivo=0;
FILE* log;
short int fator = 1;
for(w=0; w<8192; w++)
{
histograma[w] = 0;
}
N957_UINT32 data32;
int ret_val= 0; // procedure exit value
N957ErrorCodes N957_error_code; // returned error code
......@@ -118,6 +112,8 @@ int main(int argc, char **argv)
BOOL paused= FALSE;
BOOL do_exit= FALSE;
for(w=0; w<8192; w++)
histograma[w] = 0;
......@@ -153,7 +149,7 @@ int main(int argc, char **argv)
{
// Get firmware revision
char fw_rev[10];
if( ( N957_error_code= N957_GetFWRelease( user_setting.m_N957_handle, fw_rev, 10))!= N957Success)
if( ( N957_GetFWRelease( user_setting.m_N957_handle, fw_rev, 10)))
{
TRACE("erro_3");
goto exit_point;
......@@ -169,37 +165,37 @@ int main(int argc, char **argv)
goto exit_point;
}
if( ( N957_error_code=N957_GetScaler(user_setting.m_N957_handle, &data32)!= N957Success))
if( N957_GetScaler(user_setting.m_N957_handle, &data32))
{
ret_val= -5;
TRACE("erro_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;
goto exit_point;
}
if( ( N957_error_code=N957_GetLiveTime(user_setting.m_N957_handle, &data32)!= N957Success))
{
ret_val= -7;
goto exit_point;
}
if( ( N957_error_code= N957_StartAcquire( user_setting.m_N957_handle, user_setting.m_mode))!= N957Success)
//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))
{
ret_val= -8;
TRACE("erro_6");
goto exit_point;
}
if( user_setting.m_debug) {
if( ( N957_error_code= N957_SetSwConvFlag( user_setting.m_N957_handle, N957_TRUE))!= N957Success)
if( (N957_SetSwConvFlag( user_setting.m_N957_handle, N957_TRUE)))
{
ret_val= -9;
TRACE("erro_7");
goto exit_point;
}
}
......@@ -207,14 +203,13 @@ int main(int argc, char **argv)
data_buff= malloc( user_setting.m_bldim* sizeof( N957_UINT16));
if( data_buff== NULL)
{
ret_val= -10;
TRACE("erro_8");
goto exit_point;
}
histo_buff= malloc( N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff));
if( histo_buff== NULL)
{
ret_val= -11;
TRACE("erro_8");
goto exit_point;
}
memset( histo_buff, 0, N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff));
......@@ -251,8 +246,8 @@ int main(int argc, char **argv)
//
// ReadData
if( ( N957_error_code= N957_ReadData( user_setting.m_N957_handle, data_buff, &data_read))!= N957Success) {
ret_val= -15;
if( N957_ReadData( user_setting.m_N957_handle, data_buff, &data_read)) {
TRACE("erro_9");
goto exit_point;
}
tot_data_read+= data_read;
......@@ -261,10 +256,7 @@ int main(int argc, char **argv)
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
// Check for user commands
if( kbhit()) {
switch( getch()) {
case 'r':
......@@ -284,7 +276,7 @@ dentro_for:
break;
case 'p':
case 'P':
case 'P': // pausa
if(!paused)
{
......@@ -335,33 +327,33 @@ dentro_for:
paused= !paused;
break;
case 'a':
case 'a': // 8192 canais
fator = 1;
break;
case 'b':
case 'b':// 4096 canais
fator = 2;
break;
case 'c':
case 'c': // 2048 canais
fator = 4;
break;
case 'd':
case 'd': // 1024 canais
fator = 8;
break;
case 'e':
case 'e': // 512 canais
fator = 16;
break;
case 'f':
case 'f': // 256 canais
fator = 32;
break;
case 'g':
case 'g':// 128 canais
fator = 64;
break;
case 'h':
case 'h': // 64 canais
fator = 128;
break;
case 'i':
case 'i': // função que transmite a informação para o python
TRACE("[");
for(w=0; w<(8192-fator+1); w)
for(w=0; w<(8192-fator+1); w=w+fator)
{
for(ii=w; ii<=(w+fator-1); ii++)
temp = temp + histograma[ii];
......@@ -369,7 +361,7 @@ dentro_for:
if (w!=(8192-fator))
TRACE(",");
temp = 0;
w=w+fator;
//JULIO w=w+fator;
}
TRACE("]\n");
N957_GetScaler(user_setting.m_N957_handle, &data32);
......@@ -381,22 +373,24 @@ dentro_for:
/*N957_UINT16 tamanho;
N957_GetBufferOccupancy( user_setting.m_N957_handle, &tamanho);
TRACE1("%d\n",tamanho);*/ // mostra se quntas contagens tem no buffer
break;
case 'j':
case 'j': //
lldt = lldt + 1;
break;
case 'l':
N957_SetLLD( user_setting.m_N957_handle, lldt);
lldt=0;
break;
case 'z':
case 'z': // salva o arquivo em "save.dat" o qual vai ser renomeado pelo programa em python
log = fopen("save.dat", "w+");
for(w=0; w<8192; w++)
fprintf(log, "%i\n", histograma[w]);
fclose(log);
break;
case 'y':
case 'y': // abre o arquivo com o nome "save.dat"
log = fopen("save.dat", "r");
for(w=0; w<(8192-fator+1); w=w+fator)
{
......@@ -411,7 +405,8 @@ dentro_for:
break;
}
}
for( i= 0; i< data_read; i++) {
dentro_for:
// Calculate the histogram
++histo_buff[ data_buff[ i]& ( N957_MAX_HISTO_SAMPLES- 1)];
......@@ -427,9 +422,9 @@ dentro_for:
{
//
// clear software convertion
if( ( N957_error_code= N957_SetSwConvFlag( user_setting.m_N957_handle, N957_FALSE))!= N957Success)
if( N957_SetSwConvFlag( user_setting.m_N957_handle, N957_FALSE))
{
ret_val= -20;
TRACE("erro_20");
goto exit_point;
}
}
......@@ -448,13 +443,13 @@ exit_point:
// Stop acquisition
if( ( N957_error_code= N957_StopAcquire( user_setting.m_N957_handle))!= N957Success)
{
ret_val= -24;
TRACE("erro_24");
goto exit_point;
}
if( ( N957_error_code= N957_SwClear(user_setting.m_N957_handle)!= N957Success))
{
ret_val= -25;
TRACE("erro_25");
goto exit_point;
}
......
......@@ -14,11 +14,11 @@ from pylab import *
from clsbeep import *
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
from matplotlib import pyplot
##############################################################################
##############################################################################
# Subprocess variable
#def start()
child = pexpect.spawn('./N957Run')
time.sleep(3.3)
......@@ -32,10 +32,9 @@ sys.setrecursionlimit(5000)
f = 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), ctoe=False, a=0, b=0)
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))
Data=list()
ROIs=list()
LSvar = 0
for j in range(8192):
Data.insert(j, 0)
......@@ -142,7 +141,7 @@ def roiroi():
##############################################################################
##############################################################################
Interface = dict(frames=list(), buttons=list(), labels=list(), spinboxes=list(), entries=list(), labelframes=list(), checkboxes=list())
Interface = dict(frames=list(), buttons=list(), labels=list(), spinboxes=list(), entries=list(), labelframes=list())
Livetime = dict(ADC_Conversion=0 , Time=0. , LiveTime=0. )
def set_fator(canais): # Define o fator para conversao do numero de canais
......@@ -187,15 +186,33 @@ def settime():
Interface['labels'][0].configure(text='ADC Conversions: %s' %str(Livetime['ADC_Conversion']))
Interface['labels'][1].configure(text='Total Time: %ss' %str(Livetime['Time']/1000))
Interface['labels'][2].configure(text='Live Time: %ss' %str(Livetime['LiveTime']/1000))
def testeerro(Data):
if Data == 'error_1':
tkMessageBox.showinfo("Erro", "user_settings_open erro! ")
elif Data == 'erro_2':
tkMessageBox.showinfo("Erro", "user_settings_parse_input_param error!")
elif Data == 'erro_3':
tkMessageBox.showinfo("Erro", "N957_GetFWRelease error!")
elif Data == 'erro_4':
tkMessageBox.showinfo("Erro", "Problemas ao iniciar")
elif Data == 'erro_5':
tkMessageBox.showinfo("Erro", "N957_GetScaler")
elif Data == 'erro_6':
tkMessageBox.showinfo("Erro", "N957_StartAcquire")
elif Data == 'erro_7':
tkMessageBox.showinfo("Erro", "N957_SetSwConvFlag")
elif Data == 'erro_8':
tkMessageBox.showinfo("Erro", "Erro ao criar alocar memória ")
elif Data == 'erro_9':
tkMessageBox.showinfo("Erro", "N957_ReadData")
def graphic2(Data): #Plot
if PlotLimControl['ctoe'] == True:
temp.set_xdata(range(int(Interface['spinboxes'][0].get()))*PlotLimControl['a']+PlotLimControl['b'])
else:
temp.set_xdata(range(int(Interface['spinboxes'][0].get())))
temp.set_xdata(range(int(Interface['spinboxes'][0].get())))
temp.set_ydata(Data)
if LSvar == 1:
a.set_yscale('log')
if PlotLimControl['limupdt']:
plt.xlim(Control['bmin'], Control['bmax'])
plt.ylim(0, max(Data[int(Control['bmin']):int(Control['bmax'])])*1.2)
......@@ -206,6 +223,7 @@ def graphic2(Data): #Plot
def graphic(): # Le os dados
global child, Data
Data = eval(child.readline().strip("\r\n"))
testeerro(Data)
graphic2(Data)
settime()
......@@ -298,6 +316,7 @@ def refreshrate(): # Define a frequencia de atualizacao do grafico
rrwin.destroy()
else:
tkMessageBox.showinfo("Warning", "This refresh rate is likely to reach maximum recursion depht!")
Control['t'] = 99
else:
tkMessageBox.showinfo("Error", "Invalid value")
......@@ -329,39 +348,6 @@ def lldt():
lldtbut.pack(side='left')
lldtwin.mainloop()
def ctoe():
ctoewin = tk.Tk()
ctoewin.title('Channel to Energy')
ctoeent = tk.Entry(ctoewin)
ctoeent.pack(side='left')
ctoelab = tk.Label(ctoewin, text='ax')
ctoelab.pack(side='left')
ctoeent2 = tk.Entry(ctoewin)
ctoeent2.pack(side='left')
ctoelab = tk.Label(ctoewin, text='+b')
ctoelab.pack(side='left')
ctoeent2 = tk.Entry(ctoewin)
ctoeent2.pack(side='left')
ctoelab = tk.Label(ctoewin, text='Unit(Kev, MeV,...)')
ctoelab.pack(side='left')
def setlldt():
global child
if ctoeent.get().isdigit() and ctoeent2.get().isdigit() :
if int(ctoeent.get()) == 0 and int(ctoeent2.get()) == 0 :
PlotLimControl['ctoe']=False
else:
PlotLimControl['ctoe']=True
PlotLimControl['a']=int(ctoeent.get())
PlotLimControl['b']=int(ctoeent2.get())
ctoewin.destroy()
else:
tkMessageBox.showinfo("Error", "Invalid value")
ctoebut = tk.Button(ctoewin, text = 'Set', command = lambda i=i: setlldt(), bd=2, width=7, height=1)
ctoebut.pack(side='left')
ctoewin.mainloop()
##############################################################################
##############################################################################
# Safe Exit
......@@ -386,9 +372,9 @@ Interface['labelframes'].insert(1,tk.LabelFrame(Interface['frames'][0], relief='
for i in range(2):
Interface['labelframes'][i].pack(side='right')
Interface['labels'].insert(0,tk.Label(Interface['labelframes'][1], text='ADC Conversions: %s' %Livetime['ADC_Conversion'], width=19, height=2, bg='grey'))
Interface['labels'].insert(1,tk.Label(Interface['labelframes'][1], text='Total Time: %s' %Livetime['Time'], width=18, height=2, bg='grey'))
Interface['labels'].insert(2,tk.Label(Interface['labelframes'][1], text='Live Time: %s' %Livetime['LiveTime'], width=18, height=2, bg='grey'))
Interface['labels'].insert(0,tk.Label(Interface['labelframes'][1], text='ADC Conversions: %s' %Livetime['ADC_Conversion'], width=20, height=1, bg='grey'))
Interface['labels'].insert(1,tk.Label(Interface['labelframes'][1], text='Total Time: %s' %Livetime['Time'], width=18, height=1, bg='grey'))
Interface['labels'].insert(2,tk.Label(Interface['labelframes'][1], text='Live Time: %s' %Livetime['LiveTime'], width=18, height=1, bg='grey'))
for i in range(3):
Interface['frames'].insert((i+4), tk.Frame(Interface['labelframes'][0]))
......@@ -398,24 +384,14 @@ for i in range(3):
Interface['spinboxes'].insert(0, tk.Spinbox(Interface['labelframes'][0], command = lambda i=i: set_fator(Interface['spinboxes'][0].get()), values=[64,128,256,512,1024,2048,4096,8192], state = 'readonly', bg='grey'))
Interface['spinboxes'][0].pack()
def lsvartog():
global LSvar
if LSvar == 0:
LSvar = 1
else:
LSvar = 0
Interface['checkboxes'].insert(0, tk.Checkbutton(Interface['labelframes'][0], text='Log Scale', bg='grey', command= lambda i=i: lsvartog()))
Interface['checkboxes'][0].pack()
##############################################################################
# Menu
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="Exit", command = sys.exit)
settings = tk.Menu(menubar, tearoff=0)
settings.add_command(label="Channel to Energy conversion", command = lambda i=i:ctoe())
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())
......@@ -425,11 +401,11 @@ 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=8, height=1, bg='grey'))
Interface['buttons'].insert(1, tk.Button(Interface['frames'][0], text = 'Pause', command = lambda i=i: pause(), bd=2, width=8, height=1, bg='grey'))
Interface['buttons'].insert(2, tk.Button(Interface['frames'][0], text = 'Clear', command = lambda i=i: reset(), bd=2, width=8, height=1, bg='grey'))
Interface['buttons'].insert(3, tk.Button(Interface['frames'][0], text = 'Save', command = lambda i=i: save(), bd=2, width=8, height=1, bg='grey'))
Interface['buttons'].insert(4, tk.Button(Interface['frames'][0], text = 'Save As', command = lambda i=i: saveas(), bd=2, width=8, height=1, bg='grey'))
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'))
for i in range(4):
Interface['buttons'][i+1].pack(side = 'left', fill='both', expand=1)
......
......@@ -116,14 +116,14 @@ BOOL user_settings_close( user_setting_data* p_data) {
/**************************************************
**************************************************/
BOOL user_settings_parse_input_param( user_setting_data* p_data, int argc, char* argv[]) {
BOOL help_to_show= FALSE;
//BOOL help_to_show= FALSE;
int i;
for( i= 1; i< argc; i++)
{
if( !strcmp( argv[i], "-h")||
!strcmp( argv[i], "-H"))
{
help_to_show= TRUE;
//JULIOhelp_to_show= TRUE;
}
else if( !strncmp( argv[i], "-f", 2)||
!strncmp( argv[i], "-F", 2))
......@@ -131,16 +131,16 @@ BOOL user_settings_parse_input_param( user_setting_data* p_data, int argc, char*
// config filename
strcpy( p_data->m_config_filename, argv[i]+ 2);
}
else
/*JULIOelse
{
// Unknown parameter
TRACE1("\nuser settings: ignored command line parameter '%s'", argv[i]);
TRACE("\n restart with -h flag for help on usage\n");
help_to_show= TRUE;
}
}*/
}
if( help_to_show)
/*JULIOif( help_to_show)
{
// show help screen
TRACE ( "\n");
......@@ -157,7 +157,7 @@ BOOL user_settings_parse_input_param( user_setting_data* p_data, int argc, char*
TRACE ( "Hit a key to continue ... \n");
while( !kbhit());
return FALSE;
}
}*/
if( !parse_config_file( p_data))
return FALSE;
return TRUE;
......
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