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

mudanças feitas no pause(foi retirado o goto),se voltar o problema no

pause, analisar o i=0 do data_buff. Vou começar a modificar o programa
em python.
parent 8f7cc0d6
......@@ -11,19 +11,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#ifdef WIN32
#include <time.h>
#include <sys/timeb.h>
#include <conio.h>
#include <process.h>
#define popen _popen // redefine 'deprecated' popen as _popen
#define pclose _pclose // redefine 'deprecated' pclose as _pclose
#else
#include <unistd.h>
#include <sys/time.h>
#define Sleep(t) usleep((t)*1000)
#include <memory.h>
#endif
#include "common_defs.h"
#include "./include/N957Lib.h"
#include "user_settings.h"
......@@ -51,32 +42,7 @@ const char* HISTO_FILENAME= "histo.dat";
// ---------------------------------------------------------------------------
// get time in milliseconds since first procedure call
// ---------------------------------------------------------------------------
/*long get_time()
{
static long startup= 0;
long time_ms;
#ifdef WIN32
struct _timeb timebuffer;
_ftime( &timebuffer );
if( !startup) {
startup= (long)timebuffer.time;
}
time_ms = (long)( timebuffer.time- startup) * 1000 + (long)timebuffer.millitm;
#else
struct timeval t1;
struct timezone tz;
gettimeofday(&t1, &tz);
if( !startup) {
startup= (long)t1.tv_sec;
}
time_ms = (t1.tv_sec- startup) * 1000 + t1.tv_usec / 1000;
#endif
return time_ms;
}JULIO*/
/**************************************************
**************************************************/
......@@ -101,8 +67,8 @@ int main(int argc, char **argv)
FILE* log;
short int fator = 1;
N957_UINT32 data32;
int ret_val= 0; // procedure exit value
N957ErrorCodes N957_error_code; // returned error code
int ret_val= 0; // procedure exit value
//N957ErrorCodes N957_error_code; // returned error code
user_setting_data user_setting; // user settings
N957_UINT16 *data_buff= NULL; // read data buffer
unsigned long *histo_buff= NULL; // Histogram data buffer
......@@ -115,8 +81,6 @@ int main(int argc, char **argv)
for(w=0; w<8192; w++)
histograma[w] = 0;
/////////////////////////////////////////
// Demo application specific
/////////////////////////////////////////
......@@ -226,6 +190,7 @@ int main(int argc, char **argv)
do_exit= FALSE;
while( !do_exit) {
//TRACE("flag :1 \n");
N957_UINT16 data_read;
......@@ -237,7 +202,6 @@ int main(int argc, char **argv)
ret_val= 0;
goto exit_point;
}
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);
......@@ -251,11 +215,12 @@ int main(int argc, char **argv)
goto exit_point;
}
tot_data_read+= data_read;
if(paused) {
/*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()) {
......@@ -265,7 +230,7 @@ int main(int argc, char **argv)
//memset( histo_buff, 0, N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff));
for(w=0; w<8192; w++)
histograma[w] = 0;
if( ( N957_error_code= N957_SwClear(user_setting.m_N957_handle)!= N957Success))
if( N957_SwClear(user_setting.m_N957_handle))
{
ret_val= -25;
goto exit_point;
......@@ -277,18 +242,17 @@ int main(int argc, char **argv)
case 'p':
case 'P': // pausa
if(!paused)
{
if( ( N957_error_code= N957_StopAcquire( user_setting.m_N957_handle))!= N957Success)
if((N957_StopAcquire( user_setting.m_N957_handle)))
{
ret_val= -24;
TRACE("erro_24");
goto exit_point;
}
}
if(paused)
if(paused) // se esta pausado
{
N957_GetScaler(user_setting.m_N957_handle, &data32);
nmr_ADC_pause= nmr_ADC_pause + data32;
......@@ -297,28 +261,28 @@ int main(int argc, char **argv)
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_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;
}
}
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));
......@@ -405,15 +369,15 @@ int main(int argc, char **argv)
break;
}
}
for( i= 0; i< data_read; i++) {
dentro_for:
//TRACE("flag: 3 \n");
for( i= 0; i< data_read; i++) {
// Calculate the histogram
++histo_buff[ data_buff[ i]& ( N957_MAX_HISTO_SAMPLES- 1)];
// Log to file (if enabled)
sprintf( aux_string, "%04d\n", data_buff[ i]);
if (!paused)
histograma[atoi(aux_string)+1] = histograma[atoi(aux_string)+1] +1;
//TRACE("flag: 4 \n");
}
}
......@@ -429,25 +393,18 @@ dentro_for:
}
}
exit_point:
/////////////////////////////////////////
// Library specific
/////////////////////////////////////////
/////////////////////////////////////////
// Demo application specific
/////////////////////////////////////////
exit_point:
getch();
// Stop acquisition
if( ( N957_error_code= N957_StopAcquire( user_setting.m_N957_handle))!= N957Success)
if(N957_StopAcquire( user_setting.m_N957_handle))
{
TRACE("erro_24");
goto exit_point;
}
if( ( N957_error_code= N957_SwClear(user_setting.m_N957_handle)!= N957Success))
if(N957_SwClear(user_setting.m_N957_handle))
{
TRACE("erro_25");
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