|
#include <utility.h>
|
|
#include "var.h"
|
|
/**
|
|
* @brief initialisation fichiers mesures
|
|
* @param aucun
|
|
* @return 0
|
|
* @date 25/02/2010
|
|
*
|
|
*/
|
|
int save_dir_init (void )
|
|
{
|
|
|
|
char chn_nom[MAX_PATHNAME_LEN];
|
|
|
|
char message_LOG[1024];
|
|
struct tm tm;
|
|
FILE *file;
|
|
sprintf(Ctrl.chemin_save_mesure,"");
|
|
if (DirSelectPopup (Ctrl.racine, "Save data", 1, 1, chn_nom))
|
|
{
|
|
GetSystemDate (&tm.tm_mon,&tm.tm_mday ,&tm.tm_year );
|
|
GetSystemTime (&tm.tm_hour, &tm.tm_min,&tm.tm_sec );
|
|
sprintf(Ctrl.chemin_save_mesure,"%s\\%s-%d_%2.2d_%2.2d-%2.2dh%2.2dm%2.2ds",chn_nom,Ctrl.name_Batt,tm.tm_year,tm.tm_mon,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
|
|
MakeDir (Ctrl.chemin_save_mesure);
|
|
sprintf (message_LOG,"SAVE DIR: %s",Ctrl.chemin_save_mesure);
|
|
save_LOG(message_LOG);
|
|
sprintf (chn_nom, "%s\\%s", Ctrl.chemin_save_mesure,"consigne.xml");
|
|
save_consigne_xml(chn_nom);
|
|
sprintf (chn_nom, "%s\\%s", Ctrl.chemin_save_mesure,"conf.ini");
|
|
file = fopen (chn_nom, "w");
|
|
fprintf (file,"MODE SMU\n");
|
|
fprintf (file,"%s\n",instrument[INST_SMU].constructeur);
|
|
fprintf (file,"%s\n",instrument[INST_SMU].model);
|
|
fprintf (file,"%s\n",instrument[INST_SMU].num_serie);
|
|
fprintf (file,"%s\n",instrument[INST_SMU].date_CAL);
|
|
fprintf (file,"%s\n",instrument[INST_TEMP].constructeur);
|
|
fclose(file);
|
|
save_LOG(" OK");
|
|
Ctrl.save=1;
|
|
Ctrl.file=NULL;
|
|
save_file_init();
|
|
return 0;
|
|
}
|
|
Ctrl.save=0;
|
|
Ctrl.file=NULL;
|
|
save_LOG("NOT SAVE");
|
|
return 1;
|
|
}
|
|
|
|
|
|
/**
|
|
* @brief initialisation fichiers mesures
|
|
* @param aucun
|
|
* @return 0
|
|
* @date 25/02/2010
|
|
*
|
|
*/
|
|
int save_file_init (void )
|
|
{
|
|
char chn_nom[MAX_PATHNAME_LEN];
|
|
//FERMETURE FICHIER
|
|
if(Ctrl.save)
|
|
{
|
|
if(Ctrl.file!=NULL)
|
|
{
|
|
fclose(Ctrl.file);
|
|
Ctrl.file=NULL;
|
|
}
|
|
//OUVERTURE FICHIER
|
|
if(Ctrl.mode_loop==0)
|
|
sprintf (chn_nom, "%s\\BATT-%s-cycle%d.dat", Ctrl.chemin_save_mesure,Ctrl.name_Batt,Ctrl.cycle);
|
|
else
|
|
sprintf (chn_nom, "%s\\BATT-%s-cycle%d-Loop%d.dat", Ctrl.chemin_save_mesure,Ctrl.name_Batt,Ctrl.cycle,Ctrl.loop);
|
|
Ctrl.file = fopen (chn_nom, "w");
|
|
fprintf (Ctrl.file,"Time(s)");
|
|
fprintf (Ctrl.file,"\tVBatt(V)\tIBatt(A)");
|
|
fprintf (Ctrl.file,"\tC(Ah)");
|
|
fprintf (Ctrl.file,"\tNRJ(Wh)");
|
|
if(instrument[INST_TEMP].present==1)
|
|
{
|
|
fprintf (Ctrl.file,"\tTemp_Batt(?C)");
|
|
fprintf (Ctrl.file,"\tTemp_Ext(?C)");
|
|
}
|
|
fprintf (Ctrl.file,"\n");
|
|
}
|
|
return 0;
|
|
}
|