Project

General

Profile

Files » file.c

Frédéric Blanc, 2016-01-29 09:58

 
#include <utility.h>
#include "var.h"
/**
* @brief initialisation fichiers mesures
* @param aucun
* @return 0
* @date 25/02/2010
*
*/
int save_dir_init (void )
{
int i;
char chn_nom[MAX_PATHNAME_LEN];
char nom_fich[MAX_PATHNAME_LEN];
char message_LOG[1024];
struct tm tm;
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\\%d_%2.2d_%2.2d-%2.2dh%2.2dm%2.2ds",chn_nom,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 FILE: %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);
save_LOG(" OK");
sprintf (chn_nom, "%s\\log.txt", Ctrl.chemin_save_mesure);
file_LOG_mesure = fopen (chn_nom, "w");
return 0;
}
file_LOG_mesure =NULL;
save_LOG("NOT SAVE");
return 1;
}

/**
* @brief sauvegarde des mesures
* @param int cycle
* @return 0
* @date 30/11/2012
*
*/
int save_mesure_init (int cycle)
{
char message_LOG[1024];
char chn_nom[MAX_PATHNAME_LEN];
char nom_fich[MAX_PATHNAME_LEN];
if(Ctrl.chemin_save_mesure[0]!='\0')
{
if((Ctrl.Iout==MODE_POUT) || (Ctrl.Iout==MODE_IOUT))
sprintf (nom_fich, "Ph_%d_Vin%2.1f_Vout_%2.1f_C%d.dat",consigne[0].phase,consigne[0].Vin,consigne[0].Vout,cycle);
if(Ctrl.Iout==MODE_PWM)
sprintf (nom_fich, "Ph_%d_Vin%2.1f_ALPHA_%2.1f_C%d.dat",consigne[0].phase,consigne[0].Vin,consigne[0].Vout,cycle);
sprintf (chn_nom, "%s\\%s", Ctrl.chemin_save_mesure,nom_fich);
save_LOG("Save file data");
pf_mesure = fopen (chn_nom, "w");
sprintf (message_LOG," %s",nom_fich);
save_LOG(message_LOG);
if(pf_mesure==NULL)
{
save_LOG(" FAIL");
return -1;
}
fprintf (pf_mesure,"temps(s)");
fprintf (pf_mesure,"\tVin(V)");
fprintf (pf_mesure,"\tCalVin(V)");
fprintf (pf_mesure,"\tErrVin(V)");
fprintf (pf_mesure,"\tIin(A)");
fprintf (pf_mesure,"\tCalIin(A)");
fprintf (pf_mesure,"\tErrIin(A)");
fprintf (pf_mesure,"\tPin(W)");
fprintf (pf_mesure,"\tErrPin(W)");
fprintf (pf_mesure,"\tVout(V)");
fprintf (pf_mesure,"\tCalVout(V)");
fprintf (pf_mesure,"\tErrVout(V)");
fprintf (pf_mesure,"\tIout(A)");
fprintf (pf_mesure,"\tCalIout(A)");
fprintf (pf_mesure,"\tErrIout(A)");
fprintf (pf_mesure,"\tPout(W)");
fprintf (pf_mesure,"\tErrPout(W)");
fprintf (pf_mesure,"\tEfficiency (%%)");
fprintf (pf_mesure,"\tErrMinEfficiency (%%)");
fprintf (pf_mesure,"\tErrMaxEfficiency (%%)");
if(Ctrl.m_V3)
fprintf (pf_mesure,"\tV3 (V)");
if(Ctrl.m_V4)
fprintf (pf_mesure,"\tV4 (V)");
if(Ctrl.m_I3)
fprintf (pf_mesure,"\tI3 (A)");
if(Ctrl.m_I4)
fprintf (pf_mesure,"\tI4 (A)");
if(Ctrl.m_P3)
fprintf (pf_mesure,"\tP3 (W)");
if(Ctrl.m_P4)
fprintf (pf_mesure,"\tP4 (W)");
fprintf (pf_mesure,"\n");
}
return 0;
}
/**
* @brief sauvegarde des mesures
* @param aucun
* @return 0
* @date 30/11/2012
*
*/
int save_mesure (void)
{
if(pf_mesure!=NULL)
{
fnct_cal_err();
fprintf (pf_mesure,"%d",Ctrl.time_elapsed);
fprintf (pf_mesure,"\t%2.4E",measure[0].Vin );
fprintf (pf_mesure,"\t%2.4E",measure[0].CalVin );
fprintf (pf_mesure,"\t%2.4E",measure[0].ErrVin );
fprintf (pf_mesure,"\t%2.4E",measure[0].Iin );
fprintf (pf_mesure,"\t%2.4E",measure[0].CalIin );
fprintf (pf_mesure,"\t%2.4E",measure[0].ErrIin );
fprintf (pf_mesure,"\t%2.4E",measure[0].Pin );
fprintf (pf_mesure,"\t%2.4E",measure[0].ErrPin );
fprintf (pf_mesure,"\t%2.4E",measure[0].Vout );
fprintf (pf_mesure,"\t%2.4E",measure[0].CalVout );
fprintf (pf_mesure,"\t%2.4E",measure[0].ErrVout );
fprintf (pf_mesure,"\t%2.4E",measure[0].Iout );
fprintf (pf_mesure,"\t%2.4E",measure[0].CalIout );
fprintf (pf_mesure,"\t%2.4E",measure[0].ErrIout );
fprintf (pf_mesure,"\t%2.4E",measure[0].Pout );
fprintf (pf_mesure,"\t%2.4E",measure[0].ErrPout );
fprintf (pf_mesure,"\t%2.4E",measure[0].n );
fprintf (pf_mesure,"\t%2.4E",measure[0].Errnplus );
fprintf (pf_mesure,"\t%2.4E",measure[0].Errnmoins );
if(Ctrl.m_V3)
fprintf (pf_mesure,"\t%2.4E",measure[0].V3 );
if(Ctrl.m_V4)
fprintf (pf_mesure,"\t%2.4E",measure[0].V4 );
if(Ctrl.m_I3)
fprintf (pf_mesure,"\t%2.4E",measure[0].I3 );
if(Ctrl.m_I4)
fprintf (pf_mesure,"\t%2.4E",measure[0].I4 );
if(Ctrl.m_P3)
fprintf (pf_mesure,"\t%2.4E",measure[0].P3 );
if(Ctrl.m_P4)
fprintf (pf_mesure,"\t%2.4E",measure[0].P4 );
fprintf (pf_mesure,"\n");
}
return 0;
}
(11-11/25)