Commit 99ea628c authored by Matheus Müller's avatar Matheus Müller
Browse files

Zoom e translação gráfica otimizados. Beep implementado

parent e94529c3
...@@ -95,6 +95,9 @@ int main(int argc, char **argv) ...@@ -95,6 +95,9 @@ int main(int argc, char **argv)
int w; int w;
unsigned int histograma[8192]; unsigned int histograma[8192];
unsigned int temp = 0; unsigned int temp = 0;
unsigned int tempo_pause = 0;
unsigned int nmr_ADC_pause=0;
unsigned int tempo_pause_vivo=0;
FILE* log; FILE* log;
short int fator = 1; short int fator = 1;
for(w=0; w<8192; w++) for(w=0; w<8192; w++)
...@@ -227,18 +230,23 @@ int main(int argc, char **argv) ...@@ -227,18 +230,23 @@ int main(int argc, char **argv)
do_exit= FALSE; do_exit= FALSE;
while( !do_exit) { while( !do_exit) {
N957_UINT16 data_read; N957_UINT16 data_read;
data_read= user_setting.m_bldim; data_read= user_setting.m_bldim;
if( user_setting.m_max_num_samples> 0){ if( user_setting.m_max_num_samples> 0){
if( tot_data_read>= user_setting.m_max_num_samples) { if( tot_data_read>= user_setting.m_max_num_samples) {
ret_val= 0; ret_val= 0;
goto exit_point; goto exit_point;
} }
if( user_setting.m_max_num_samples- tot_data_read< user_setting.m_bldim) { if( user_setting.m_max_num_samples- tot_data_read< user_setting.m_bldim) {
data_read= ( N957_UINT16)(int32_t)(user_setting.m_max_num_samples - tot_data_read); data_read= ( N957_UINT16)(int32_t)(user_setting.m_max_num_samples - tot_data_read);
} }
} }
// //
// ReadData // ReadData
if( ( N957_error_code= N957_ReadData( user_setting.m_N957_handle, data_buff, &data_read))!= N957Success) { if( ( N957_error_code= N957_ReadData( user_setting.m_N957_handle, data_buff, &data_read))!= N957Success) {
...@@ -247,8 +255,10 @@ int main(int argc, char **argv) ...@@ -247,8 +255,10 @@ int main(int argc, char **argv)
} }
tot_data_read+= data_read; tot_data_read+= data_read;
if(paused)
goto dentro_for;
for( i= 0; i< data_read; i++) { for( i= 0; i< data_read; i++) {
dentro_for:
// Check for user commands // Check for user commands
if( kbhit()) { if( kbhit()) {
switch( getch()) { switch( getch()) {
...@@ -258,23 +268,64 @@ int main(int argc, char **argv) ...@@ -258,23 +268,64 @@ 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));
for(w=0; w<8192; w++) for(w=0; w<8192; w++)
histograma[w] = 0; histograma[w] = 0;
if( ( N957_error_code= N957_SwClear(user_setting.m_N957_handle)!= N957Success))
{
ret_val= -25;
goto exit_point;
}
tempo_pause = 0;
nmr_ADC_pause=0;
tempo_pause_vivo=0;
break; break;
case 'p': case 'p':
case 'P': case 'P':
/*if(!paused)
{ if(!paused)
{
if( ( N957_error_code= N957_StopAcquire( user_setting.m_N957_handle))!= N957Success) if( ( N957_error_code= N957_StopAcquire( user_setting.m_N957_handle))!= N957Success)
{ {
ret_val= -24; ret_val= -24;
goto exit_point; goto exit_point;
} }
} }
else if(paused)
{
N957_GetScaler(user_setting.m_N957_handle, &data32);
nmr_ADC_pause= nmr_ADC_pause + data32;
N957_GetTimer(user_setting.m_N957_handle, &data32);
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) if( ( N957_error_code= N957_StartAcquire( user_setting.m_N957_handle, user_setting.m_mode))!= N957Success)
{ {
ret_val= -8; ret_val= -8;
goto exit_point; goto exit_point;
}*/ }
if( user_setting.m_debug) {
if( ( N957_error_code= N957_SetSwConvFlag( user_setting.m_N957_handle, N957_TRUE))!= N957Success)
{
ret_val= -9;
goto exit_point;
}
}
data_buff= malloc( user_setting.m_bldim* sizeof( N957_UINT16));
if( data_buff== NULL)
{
ret_val= -10;
goto exit_point;
}
histo_buff= malloc( N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff));
if( histo_buff== NULL)
{
ret_val= -11;
goto exit_point;
}
memset( histo_buff, 0, N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff));
}
paused= !paused; paused= !paused;
break; break;
...@@ -316,11 +367,11 @@ int main(int argc, char **argv) ...@@ -316,11 +367,11 @@ int main(int argc, char **argv)
} }
TRACE("]\n"); TRACE("]\n");
N957_GetScaler(user_setting.m_N957_handle, &data32); N957_GetScaler(user_setting.m_N957_handle, &data32);
TRACE1("%d\n",data32); TRACE1("%d\n",data32 + nmr_ADC_pause);
N957_GetTimer(user_setting.m_N957_handle, &data32); N957_GetTimer(user_setting.m_N957_handle, &data32);
TRACE1("%d\n",data32); TRACE1("%d\n",data32 +tempo_pause);
N957_GetLiveTime(user_setting.m_N957_handle, &data32); N957_GetLiveTime(user_setting.m_N957_handle, &data32);
TRACE1("%d\n",data32); TRACE1("%d\n",data32 +tempo_pause_vivo);
break; break;
case 'z': case 'z':
log = fopen("save.dat", "w+"); log = fopen("save.dat", "w+");
...@@ -343,6 +394,7 @@ int main(int argc, char **argv) ...@@ -343,6 +394,7 @@ int main(int argc, char **argv)
break; break;
} }
} }
// Calculate the histogram // Calculate the histogram
++histo_buff[ data_buff[ i]& ( N957_MAX_HISTO_SAMPLES- 1)]; ++histo_buff[ data_buff[ i]& ( N957_MAX_HISTO_SAMPLES- 1)];
......
...@@ -29,7 +29,7 @@ sys.setrecursionlimit(5000) ...@@ -29,7 +29,7 @@ sys.setrecursionlimit(5000)
# Histrogram # Histrogram
Control = dict(t=1200, bmin=0, bmax=8192, bmaxold=512, j=0, filename='temp', count=0, paused=False, ROIctrl=list()) 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.) 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() Data=list()
ROIs=list() ROIs=list()
for a in range(8192): for a in range(8192):
...@@ -375,7 +375,7 @@ for n in arange(3,6): ...@@ -375,7 +375,7 @@ for n in arange(3,6):
def key_1(event): def key_1(event):
Interface['buttons'][1].invoke() Interface['buttons'][1].invoke()
#beep() root.bell()
def key_2(event): def key_2(event):
Interface['buttons'][2].invoke() Interface['buttons'][2].invoke()
def key_3(event): def key_3(event):
...@@ -394,6 +394,11 @@ def key_4(event): ...@@ -394,6 +394,11 @@ def key_4(event):
PlotLimControl['limupdt'] = True PlotLimControl['limupdt'] = True
PlotLimControl['limctrl'] = False PlotLimControl['limctrl'] = False
PlotLimControl['limtrans'] = False PlotLimControl['limtrans'] = False
PlotLimControl['x0'] = 0
PlotLimControl['x1'] = int(Interface['spinboxes'][0].get())
PlotLimControl['y0'] = 0
PlotLimControl['y1'] = max(Data)*1.2
f.canvas.draw()
elif event.button == 1: elif event.button == 1:
PlotLimControl['limupdt'] = False PlotLimControl['limupdt'] = False
PlotLimControl['limtrans'] = True PlotLimControl['limtrans'] = True
...@@ -403,22 +408,41 @@ def key_5(event): ...@@ -403,22 +408,41 @@ def key_5(event):
if PlotLimControl['limctrl'] == True: if PlotLimControl['limctrl'] == True:
PlotLimControl['dx'] = float(event.xdata) - PlotLimControl['pressx'] PlotLimControl['dx'] = float(event.xdata) - PlotLimControl['pressx']
PlotLimControl['dy'] = float(event.ydata) - PlotLimControl['pressy'] PlotLimControl['dy'] = float(event.ydata) - PlotLimControl['pressy']
plt.xlim(int(PlotLimControl['x0']+PlotLimControl['dx']), int(PlotLimControl['x1'])-PlotLimControl['dx']) plt.xlim(float(PlotLimControl['x0']+PlotLimControl['dx']), float(PlotLimControl['x1'])-PlotLimControl['dx'])
plt.ylim(int(PlotLimControl['y0']+PlotLimControl['dy']), int(PlotLimControl['y1'])-PlotLimControl['dy']) plt.ylim(float(PlotLimControl['y0']+PlotLimControl['dy']), float(PlotLimControl['y1'])-PlotLimControl['dy'])
if PlotLimControl['limtrans'] == True: f.canvas.draw()
PlotLimControl['dx'] = float(event.xdata) - PlotLimControl['pressx']
PlotLimControl['dy'] = float(event.ydata) - PlotLimControl['pressy'] def key_6(event):
plt.xlim(int(PlotLimControl['x0']-PlotLimControl['dx']), int(PlotLimControl['x1'])-PlotLimControl['dx']) if event.button is not 2:
plt.ylim(int(PlotLimControl['y0']-PlotLimControl['dy']), int(PlotLimControl['y1'])-PlotLimControl['dy']) (PlotLimControl['x0'] , PlotLimControl['x1']) = plt.xlim()
(PlotLimControl['y0'] , PlotLimControl['y1']) = plt.ylim()
def key_6(event):
(PlotLimControl['x0'] , PlotLimControl['x1']) = plt.xlim()
(PlotLimControl['y0'] , PlotLimControl['y1']) = plt.ylim()
if event.button == 3: if event.button == 3:
PlotLimControl['limctrl'] = False PlotLimControl['limctrl'] = False
if event.button == 1: if event.button == 1:
if PlotLimControl['limtrans'] == True:
if PlotLimControl['pressx'] >= event.xdata:
xx = event.xdata
xx2 = PlotLimControl['pressx']
else:
xx2 = event.xdata
xx = PlotLimControl['pressx']
if PlotLimControl['pressy'] >= event.ydata:
yy = event.ydata
yy2 = PlotLimControl['pressy']
else:
yy2 = event.ydata
yy = PlotLimControl['pressy']
if (xx2-xx)/(PlotLimControl['x1']-PlotLimControl['x0']) >= (yy2-yy)/(PlotLimControl['y1']-PlotLimControl['y0']) and (xx2-xx) > 0.01*(PlotLimControl['x1']-PlotLimControl['x0']):
plt.xlim(xx,xx2)
elif (yy2-yy) > 0.01*(PlotLimControl['y1']-PlotLimControl['y0']):
plt.ylim(yy,yy2)
f.canvas.draw()
grid(a, int(xx2-xx))
(PlotLimControl['x0'] , PlotLimControl['x1']) = plt.xlim()
(PlotLimControl['y0'] , PlotLimControl['y1']) = plt.ylim()
PlotLimControl['limtrans'] = False PlotLimControl['limtrans'] = False
root.bind_all("<Alt-KeyPress-1>", key_1) root.bind_all("<Alt-KeyPress-1>", key_1)
root.bind_all("<Alt-KeyPress-2>", key_1) root.bind_all("<Alt-KeyPress-2>", key_1)
root.bind_all("<Alt-KeyPress-3>", key_2) root.bind_all("<Alt-KeyPress-3>", key_2)
......
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