Commit c050db25 authored by root's avatar root
Browse files

simplificações e detalhes na programação, commit feito antes de modificar a...

simplificações e detalhes na programação, commit feito antes de modificar a estrutura da comunicação
parent 786f9c9c
diff --git a/main.c b/main.c
index 24ffb4a..60d2bca 100755
--- a/main.c
+++ b/main.c
@@ -51,7 +51,7 @@ const char* HISTO_FILENAME= "histo.dat";
// ---------------------------------------------------------------------------
// get time in milliseconds since first procedure call
// ---------------------------------------------------------------------------
-long get_time()
+/*long get_time()
{
static long startup= 0;
long time_ms;
@@ -76,7 +76,7 @@ long get_time()
#endif
return time_ms;
-}
+}JULIO*/
/**************************************************
**************************************************/
@@ -110,7 +110,6 @@ int main(int argc, char **argv)
int ret_val= 0; // procedure exit value
N957ErrorCodes N957_error_code; // returned error code
user_setting_data user_setting; // user settings
- FILE* out_file= NULL; // output file
N957_UINT16 *data_buff= NULL; // read data buffer
unsigned long *histo_buff= NULL; // Histogram data buffer
int32_t tot_data_read= 0;
@@ -132,7 +131,7 @@ int main(int argc, char **argv)
// init user setting module
if( !user_settings_open( &user_setting))
{
- ret_val= -1;
+ TRACE("erro_1");
goto exit_point;
}
@@ -140,7 +139,7 @@ int main(int argc, char **argv)
// input parameter check
if( !user_settings_parse_input_param( &user_setting, argc, (char**)argv))
{
- ret_val= -2;
+ TRACE("erro_2");
goto exit_point;
}
@@ -156,7 +155,7 @@ int main(int argc, char **argv)
char fw_rev[10];
if( ( N957_error_code= N957_GetFWRelease( user_setting.m_N957_handle, fw_rev, 10))!= N957Success)
{
- ret_val= -3;
+ TRACE("erro_3");
goto exit_point;
}
}
@@ -166,7 +165,7 @@ int main(int argc, char **argv)
case 'S':
break;
default:
- ret_val= -4;
+ TRACE("erro_4");
goto exit_point;
}
@@ -220,154 +219,14 @@ int main(int argc, char **argv)
}
memset( histo_buff, 0, N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff));
- if( user_setting.m_log_to_file) {
+ /*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;
}
- }
-
- if( kbhit()) {
- switch( getch()) {
- case 'r':
- case 'R':
- // reset the histogram here
- //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))
- {
- ret_val= -25;
- goto exit_point;
- }
- tempo_pause = 0;
- nmr_ADC_pause=0;
- tempo_pause_vivo=0;
- break;
- case 'p':
- case 'P':
- if(!paused)
- {
-
- if( ( N957_error_code= N957_StopAcquire( user_setting.m_N957_handle))!= N957Success)
- {
- ret_val= -24;
- goto exit_point;
- }
-
- }
- 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)
- {
- ret_val= -8;
- 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;
-
- break;
- case 'a':
- fator = 1;
- break;
- case 'b':
- fator = 2;
- break;
- case 'c':
- fator = 4;
- break;
- case 'd':
- fator = 8;
- break;
- case 'e':
- fator = 16;
- break;
- case 'f':
- fator = 32;
- break;
- case 'g':
- fator = 64;
- break;
- case 'h':
- fator = 128;
- break;
- case 'i':
- TRACE("[");
- for(w=0; w<(8192-fator+1); w)
- {
- for(ii=w; ii<=(w+fator-1); ii++)
- temp = temp + histograma[ii];
- TRACE1("%i",temp);
- if (w!=(8192-fator))
- TRACE(",");
- temp = 0;
- w=w+fator;
- }
- TRACE("]\n");
- N957_GetScaler(user_setting.m_N957_handle, &data32);
- TRACE1("%d\n",data32 + nmr_ADC_pause);
- N957_GetTimer(user_setting.m_N957_handle, &data32);
- TRACE1("%d\n",data32 +tempo_pause);
- N957_GetLiveTime(user_setting.m_N957_handle, &data32);
- TRACE1("%d\n",data32 +tempo_pause_vivo);
- break;
- case 'j':
- lldt = lldt + 1;
- break;
- case 'l':
- N957_SetLLD( user_setting.m_N957_handle, lldt);
- lldt=0;
- break;
- case 'z':
- log = fopen("save.dat", "w+");
- for(w=0; w<8192; w++)
- fprintf(log, "%i\n", histograma[w]);
- fclose(log);
- break;
- case 'y':
- log = fopen("save.dat", "r");
- for(w=0; w<(8192-fator+1); w=w+fator)
- {
- fscanf(log, "%i", &temp);
- for(i=w; i<=(w+fator-1); i++)
- histograma[i] = temp/fator;
- }
- fclose(log);
- break;
- default:
- do_exit= TRUE;
- break;
- }
+ }*/
do_exit= FALSE;
@@ -519,6 +378,10 @@ dentro_for:
TRACE1("%d\n",data32 +tempo_pause);
N957_GetLiveTime(user_setting.m_N957_handle, &data32);
TRACE1("%d\n",data32 +tempo_pause_vivo);
+
+ /*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':
lldt = lldt + 1;
@@ -553,11 +416,10 @@ dentro_for:
// Calculate the histogram
++histo_buff[ data_buff[ i]& ( N957_MAX_HISTO_SAMPLES- 1)];
// Log to file (if enabled)
- if( out_file) {
- sprintf( aux_string, "%04d\n", data_buff[ i]);
- if (!paused)
- histograma[atoi(aux_string)+1] = histograma[atoi(aux_string)+1] +1;
- }
+ sprintf( aux_string, "%04d\n", data_buff[ i]);
+ if (!paused)
+ histograma[atoi(aux_string)+1] = histograma[atoi(aux_string)+1] +1;
+
}
}
diff --git a/user_settings.c b/user_settings.c
index 9e3fd69..f79a787 100755
--- a/user_settings.c
+++ b/user_settings.c
@@ -20,11 +20,11 @@
////////////////////////////////////////////
// File local defines
////////////////////////////////////////////
-#define DEF_LOG_FILENAME "data.log" /* read board values default filename */
+//JULIO#define DEF_LOG_FILENAME "data.log" /* read board values default filename */
#define DEF_CONFIG_FILENAME "N957Run.conf" /* configuration default filename */
-#define DEF_GNU_PLOT_PATH "../gnuplot/" /* GNUPLOT default path */
+//JULIO#define DEF_GNU_PLOT_PATH "../gnuplot/" /* GNUPLOT default path */
#define DEF_MAX_NUM_SAMPLES -1 /* default number of samples */
@@ -32,9 +32,9 @@
#define DEF_MODE N957ControlModeAuto /* default value for acquisition mode */
-#define DEF_GNU_PLOT_REFRESH 500 /* default gnu plot refresh rate (msec) */
+//JULIO#define DEF_GNU_PLOT_REFRESH 500 /* default gnu plot refresh rate (msec) */
-#define DEF_GNU_PLOT_X_SCALE 1.0 /* default gnu plot X conversion factor */
+//JULIO#define DEF_GNU_PLOT_X_SCALE 1.0 /* default gnu plot X conversion factor */
////////////////////////////////////////////
@@ -59,21 +59,21 @@ BOOL user_settings_open( user_setting_data* p_data)
p_data->m_log_filename= (char*)malloc( MAX_FILENAME_LENGHT);
p_data->m_config_filename= (char*)malloc( MAX_FILENAME_LENGHT);
// gnuplot path
- p_data->m_gnu_plot_path= (char*)malloc( MAX_FILENAME_LENGHT);;
+ // JULIO p_data->m_gnu_plot_path= (char*)malloc( MAX_FILENAME_LENGHT);;
// setting default values ...
- if( p_data->m_log_filename== NULL)
- TRACE("user setting module: insufficient memory !\n");
+ /*JULIOif( p_data->m_log_filename== NULL)
+ TRACE("ME11:user setting module: insufficient memory!\n");
else
- strcpy( p_data->m_log_filename, DEF_LOG_FILENAME);
+ strcpy( p_data->m_log_filename, DEF_LOG_FILENAME);*/
if( p_data->m_config_filename== NULL)
- TRACE("user setting module: insufficient memory !\n");
+ TRACE("ME12:user setting module: insufficient memory !\n");
else
strcpy( p_data->m_config_filename, DEF_CONFIG_FILENAME);
- if( p_data->m_gnu_plot_path== NULL)
- TRACE("user setting module: insufficient memory !\n");
- else
- strcpy( p_data->m_gnu_plot_path, DEF_GNU_PLOT_PATH);
+ // JULIO if( p_data->m_gnu_plot_path== NULL)
+ // JULIO TRACE("ME13user setting module: insufficient memory !\n");
+ // JULIO else
+ // JULIO strcpy( p_data->m_gnu_plot_path, DEF_GNU_PLOT_PATH);
p_data->m_max_num_samples= DEF_MAX_NUM_SAMPLES;
p_data->m_debug= N957_FALSE;
@@ -82,8 +82,8 @@ BOOL user_settings_open( user_setting_data* p_data)
p_data->m_N957_handle= N957_INVALID_HANDLE_VALUE;
p_data->m_log_to_file= N957_FALSE;
p_data->m_bd_num= 0;
- p_data->m_gnu_plot_refresh= DEF_GNU_PLOT_REFRESH;
- p_data->m_gnu_plot_x_scale= DEF_GNU_PLOT_X_SCALE;
+ // JULIO p_data->m_gnu_plot_refresh= DEF_GNU_PLOT_REFRESH;
+ // JULIO p_data->m_gnu_plot_x_scale= DEF_GNU_PLOT_X_SCALE;
return TRUE;
}
@@ -99,16 +99,16 @@ BOOL user_settings_close( user_setting_data* p_data) {
// module variable free
if( p_data->m_log_filename)
- free( p_data->m_log_filename);
+ free( p_data->m_log_filename);
if( p_data->m_config_filename)
free( p_data->m_config_filename);
- if( p_data->m_gnu_plot_path)
- free( p_data->m_gnu_plot_path);
+ // JULIO if( p_data->m_gnu_plot_path)
+ // JULIO free( p_data->m_gnu_plot_path);
// setting invalid values ...
p_data->m_log_filename= NULL;
p_data->m_config_filename= NULL;
- p_data->m_gnu_plot_path= NULL;
+ // JULIO p_data->m_gnu_plot_path= NULL;
return TRUE;
}
@@ -176,8 +176,8 @@ BOOL parse_config_file( user_setting_data* p_data) {
if( ( p_conf_file= fopen( p_data->m_config_filename, "r"))== NULL){
- TRACE1("Can't open configuration file %s\n", p_data->m_config_filename);
- return FALSE;
+ TRACE1("Can't open configuration file %s\n", p_data->m_config_filename);
+ return FALSE;
}
//TRACE1("Reading Configuration File %s\n", p_data->m_config_filename);
while(!feof( p_conf_file)) {
@@ -203,26 +203,26 @@ BOOL parse_config_file( user_setting_data* p_data) {
continue;
}
// GNUplot path
- if (strstr(str, "GNUPLOT_PATH")!=NULL) {
+ //JULIOif (strstr(str, "GNUPLOT_PATH")!=NULL) {
//fscanf( p_conf_file, "%s", p_data->m_gnu_plot_path);
- fscanf( p_conf_file, "%s", tmp_filename);
- strcpy( p_data->m_gnu_plot_path, trim( trim_text_charset, sizeof( trim_text_charset), tmp_filename));
- continue;
- }
+ //JULIO fscanf( p_conf_file, "%s", tmp_filename);
+ //JULIO strcpy( p_data->m_gnu_plot_path, trim( trim_text_charset, sizeof( trim_text_charset), tmp_filename));
+ //JULIO continue;
+ //JULIO }
// Write Data to output file
- if (strstr(str, "LOG_TO_FILE")!=NULL){
- int tmp= 0;
- fscanf(p_conf_file, "%d", &tmp);
- p_data->m_log_to_file= tmp!= 0;
- continue;
- }
+ //JULIO if (strstr(str, "LOG_TO_FILE")!=NULL){
+ //JULIO int tmp= 0;
+ //JULIO fscanf(p_conf_file, "%d", &tmp);
+ //JULIO p_data->m_log_to_file= tmp!= 0;
+ //JULIO continue;
+ //JULIO}
// log filename
- if (strstr(str, "LOG_FILENAME")!=NULL){
- //fscanf( p_conf_file, "%s", p_data->m_log_filename);
- fscanf( p_conf_file, "%s", tmp_filename);
- strcpy( p_data->m_log_filename, trim( trim_text_charset, sizeof( trim_text_charset), tmp_filename));
- continue;
- }
+ //JULIOif (strstr(str, "LOG_FILENAME")!=NULL){
+ //JULIO //fscanf( p_conf_file, "%s", p_data->m_log_filename);
+ //JULIO fscanf( p_conf_file, "%s", tmp_filename);
+ //JULIO strcpy( p_data->m_log_filename, trim( trim_text_charset, sizeof( trim_text_charset), tmp_filename));
+ //JULIO continue;
+ // JULIO }
// Number of samples to acquire
if (strstr(str, "MAX_NUM_SAMPLES")!=NULL) {
fscanf(p_conf_file, "%ld", &p_data->m_max_num_samples);
@@ -265,15 +265,15 @@ BOOL parse_config_file( user_setting_data* p_data) {
continue;
}
// Number of samples to acquire
- if (strstr(str, "GNU_PLOT_REFRESH")!=NULL) {
- fscanf(p_conf_file, "%d", &p_data->m_gnu_plot_refresh);
- continue;
- }
+ //JULIO if (strstr(str, "GNU_PLOT_REFRESH")!=NULL) {
+ //JULIO fscanf(p_conf_file, "%d", &p_data->m_gnu_plot_refresh);
+ //JULIO continue;
+ //JULIO}
// GnuPlot X conversion factor
- if (strstr(str, "GNU_PLOT_X_SCALE")!=NULL) {
- fscanf(p_conf_file, "%f", &p_data->m_gnu_plot_x_scale);
- continue;
- }
+ //JULIO if (strstr(str, "GNU_PLOT_X_SCALE")!=NULL) {
+ //JULIO fscanf(p_conf_file, "%f", &p_data->m_gnu_plot_x_scale);
+ //JULIO continue;
+ //JULIO}
// Generic Write
if (strstr(str, "WRITE_REGISTER")!=NULL) {
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