Commit 3d2d810d authored by Julio Tambara's avatar Julio Tambara
Browse files

LLDt refeito, começando a tratar os erros pelo programa em python

parent d00e9996
...@@ -135,15 +135,6 @@ int main(int argc, char **argv) ...@@ -135,15 +135,6 @@ int main(int argc, char **argv)
} }
memset( histo_buff, 0, N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff)); memset( histo_buff, 0, N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff));
/*JULIO if( user_setting.m_log_to_file) {
if( ( out_file= fopen( user_setting.m_log_filename, "wt"))== NULL)
{
ret_val= -12;
goto exit_point;
}
}*/
do_exit= FALSE; do_exit= FALSE;
while( !do_exit) { while( !do_exit) {
...@@ -181,7 +172,7 @@ int main(int argc, char **argv) ...@@ -181,7 +172,7 @@ int main(int argc, char **argv)
if( N957_GetScaler(user_setting.m_N957_handle, &data32)) if( N957_GetScaler(user_setting.m_N957_handle, &data32))
{ {
TRACE("erro_5"); TRACE("erro_5");
goto exit_point; //goto exit_point;
} }
...@@ -189,7 +180,7 @@ int main(int argc, char **argv) ...@@ -189,7 +180,7 @@ int main(int argc, char **argv)
if(N957_StartAcquire( user_setting.m_N957_handle, user_setting.m_mode)) if(N957_StartAcquire( user_setting.m_N957_handle, user_setting.m_mode))
{ {
TRACE("erro_6"); TRACE("erro_6");
goto exit_point; //goto exit_point;
} }
if( user_setting.m_debug) { if( user_setting.m_debug) {
...@@ -197,9 +188,10 @@ int main(int argc, char **argv) ...@@ -197,9 +188,10 @@ int main(int argc, char **argv)
{ {
TRACE("erro_7"); TRACE("erro_7");
goto exit_point; //goto exit_point;
} }
} }
TRACE("OK\n");
break; break;
case 'r': case 'r':
...@@ -241,26 +233,26 @@ int main(int argc, char **argv) ...@@ -241,26 +233,26 @@ int main(int argc, char **argv)
if((N957_StartAcquire(user_setting.m_N957_handle,user_setting.m_mode))) if((N957_StartAcquire(user_setting.m_N957_handle,user_setting.m_mode)))
{ {
TRACE("erro_6"); TRACE("erro_6\n");
goto exit_point; goto exit_point;
} }
if( user_setting.m_debug) { if( user_setting.m_debug) {
if((N957_SetSwConvFlag( user_setting.m_N957_handle, N957_TRUE))) if((N957_SetSwConvFlag( user_setting.m_N957_handle, N957_TRUE)))
{ {
TRACE("erro_7"); TRACE("erro_7\n");
goto exit_point; goto exit_point;
} }
} }
data_buff= malloc( user_setting.m_bldim* sizeof( N957_UINT16)); data_buff= malloc( user_setting.m_bldim* sizeof( N957_UINT16));
if( data_buff== NULL) if( data_buff== NULL)
{ {
TRACE("erro_8"); TRACE("erro_8\n");
goto exit_point; goto exit_point;
} }
histo_buff= malloc( N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff)); histo_buff= malloc( N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff));
if( histo_buff== NULL) if( histo_buff== NULL)
{ {
TRACE("erro_8"); TRACE("erro_8\n");
goto exit_point; goto exit_point;
} }
memset( histo_buff, 0, N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff)); memset( histo_buff, 0, N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff));
...@@ -318,13 +310,15 @@ int main(int argc, char **argv) ...@@ -318,13 +310,15 @@ int main(int argc, char **argv)
TRACE1("%d\n",tamanho);*/ // mostra se quntas contagens tem no buffer TRACE1("%d\n",tamanho);*/ // mostra se quntas contagens tem no buffer
break; break;
case 'j': // case 'j': // funcao testada
lldt = lldt + 1; lldt= ((getchar())*10 + getchar());
N957_SetLLD( user_setting.m_N957_handle, lldt);
break; break;
case 'l': case 'l':
N957_SetLLD( user_setting.m_N957_handle, lldt);
lldt=0; //N957_SetLLD( user_setting.m_N957_handle, lldt);
//lldt=0;
break; break;
case 'z': // salva o arquivo em "save.dat" o qual vai ser renomeado pelo programa em python case 'z': // salva o arquivo em "save.dat" o qual vai ser renomeado pelo programa em python
log = fopen("save.dat", "w+"); log = fopen("save.dat", "w+");
...@@ -366,7 +360,7 @@ int main(int argc, char **argv) ...@@ -366,7 +360,7 @@ int main(int argc, char **argv)
// clear software convertion // clear software convertion
if( N957_SetSwConvFlag( user_setting.m_N957_handle, N957_FALSE)) if( N957_SetSwConvFlag( user_setting.m_N957_handle, N957_FALSE))
{ {
TRACE("erro_20"); TRACE("erro_20\n");
goto exit_point; goto exit_point;
} }
} }
......
...@@ -26,9 +26,17 @@ sys.setrecursionlimit(5000) ...@@ -26,9 +26,17 @@ sys.setrecursionlimit(5000)
def start(): def start():
global child
print 'teste'
child.send('s') child.send('s')
time.sleep(0.2) time.sleep(0.2)
if testeerro(child.readline()):
print 'True'
return True
else:
print 'false'
return False
def teste(): def teste():
child.send('teste') child.send('teste')
...@@ -199,28 +207,44 @@ def settime(): ...@@ -199,28 +207,44 @@ def settime():
Interface['labels'][2].configure(text='Live Time: %ss' %str(Livetime['LiveTime']/1000)) Interface['labels'][2].configure(text='Live Time: %ss' %str(Livetime['LiveTime']/1000))
def testeerro(Data): def testeerro(Data):
if Data == 'error_1': if not Data == 'OK':
tkMessageBox.showinfo("Erro", "user_settings_open erro! ") if Data == 'error_1':
elif Data == 'erro_2': print 'erro_1'
tkMessageBox.showinfo("Erro", "user_settings_parse_input_param error!") tkMessageBox.showinfo("Erro", "user_settings_open erro! ")
elif Data == 'erro_3': return False
tkMessageBox.showinfo("Erro", "N957_GetFWRelease error!") elif Data == 'erro_2':
elif Data == 'erro_4': print 'erro_2'
tkMessageBox.showinfo("Erro", "Problemas ao iniciar") tkMessageBox.showinfo("Erro", "user_settings_parse_input_param error!")
elif Data == 'erro_5': return False
tkMessageBox.showinfo("Erro", "N957_GetScaler") elif Data == 'erro_3':
elif Data == 'erro_6': print 'erro_3'
tkMessageBox.showinfo("Erro", "N957_StartAcquire") tkMessageBox.showinfo("Erro", "N957_GetFWRelease error!")
elif Data == 'erro_7': return False
tkMessageBox.showinfo("Erro", "N957_SetSwConvFlag") elif Data == 'erro_4':
print 'erro_4'
tkMessageBox.showinfo("Erro", "Problemas ao iniciar")
return False
elif Data == 'erro_5':
print 'erro_5'
tkMessageBox.showinfo("Erro", "N957_GetScaler")
return False
elif Data == 'erro_6':
print 'erro_6'
tkMessageBox.showinfo("Erro", "N957_StartAcquire")
return False
elif Data == 'erro_7':
print 'erro_7'
tkMessageBox.showinfo("Erro", "N957_SetSwConvFlag")
return False
elif Data == 'erro_8': elif Data == 'erro_8':
tkMessageBox.showinfo("Erro", "Erro ao criar alocar memória ") tkMessageBox.showinfo("Erro", "Erro ao criar alocar memória ")
elif Data == 'erro_9': return False
tkMessageBox.showinfo("Erro", "N957_ReadData") elif Data == 'erro_9':
tkMessageBox.showinfo("Erro", "N957_ReadData")
return False
else:
return True
def graphic2(Data): #Plot def graphic2(Data): #Plot
temp.set_xdata(range(int(Interface['spinboxes'][0].get()))) temp.set_xdata(range(int(Interface['spinboxes'][0].get())))
temp.set_ydata(Data) temp.set_ydata(Data)
...@@ -245,7 +269,7 @@ def graphic2(Data): #Plot ...@@ -245,7 +269,7 @@ def graphic2(Data): #Plot
def graphic(): # Le os dados def graphic(): # Le os dados
global child, Data global child, Data
Data = eval(child.readline().strip("\r\n")) Data = eval(child.readline().strip("\r\n"))
testeerro(Data) #testeerro(Data)
graphic2(Data) graphic2(Data)
settime() settime()
...@@ -367,9 +391,9 @@ def lldt(): ...@@ -367,9 +391,9 @@ def lldt():
global child global child
if lldtent.get().isdigit(): if lldtent.get().isdigit():
if int(lldtent.get()) < 100: # Percentual if int(lldtent.get()) < 100: # Percentual
for k in arange(0, int(lldtent.get()), 1): child.send('j')
child.send('j') child.send(chr(int(lldtent.get())/10))
child.send('l') child.send(chr(int(lldtent.get())%10))
lldtwin.destroy() lldtwin.destroy()
else: else:
tkMessageBox.showinfo("Error", "Invalid value; Percent based") tkMessageBox.showinfo("Error", "Invalid value; Percent based")
......
...@@ -192,11 +192,8 @@ BOOL parse_config_file( user_setting_data* p_data) { ...@@ -192,11 +192,8 @@ BOOL parse_config_file( user_setting_data* p_data) {
fscanf(p_conf_file, "%d", &p_data->m_bd_num); fscanf(p_conf_file, "%d", &p_data->m_bd_num);
// //
// init caen N957 lib // init caen N957 lib
if( ( N957_error_code= N957_Init( (short)p_data->m_bd_num, &p_data->m_N957_handle))!= N957Success) if( (N957_Init( (short)p_data->m_bd_num, &p_data->m_N957_handle)))
{ {
TRACE( "N957 : N957_Init : ");
TRACE( N957_DecodeError( N957_error_code));
TRACE( "\n");
ret_val= FALSE; ret_val= FALSE;
goto exit_point; goto exit_point;
} }
......
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