Project

General

Profile

Files » panel.c

Frédéric Blanc, 2016-01-29 10:31

 
#include "var.h"

/**
* @brief Set_panel_cycle
* @param
* @return 0
* @date 21/05/2014
*
*/
int Set_panel_cycle (int cycle)
{
SetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_H_CYCLE,cycle);
SetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_NB_CYCLE,Ctrl.nb_cycle);
SetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_RINGSLIDE,T_cycle[cycle].mode);
SetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_CURR,T_cycle[cycle].curr);
SetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_RINGSTOP,T_cycle[cycle].mode_stop);
SetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_CURR,T_cycle[cycle].curr);
SetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_VMAX,T_cycle[cycle].Vmax);
SetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_IMIN,T_cycle[cycle].Imin);
SetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_VMIN,T_cycle[cycle].Vmin);
SetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_CMAX,T_cycle[cycle].Cmax);
SetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_TIMER,T_cycle[Ctrl.cycle].Timermax);
Set_panel_cycle_mode ();
return 0;
}

/**
* @brief Set_panel_cycle
* @param
* @return 0
* @date 21/05/2014
*
*/
int Set_panel_cycle_mode ()
{
int mode,mode_stop;
GetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_RINGSLIDE,&mode);
GetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_RINGSTOP,&mode_stop);
if(Ctrl.vminstop==1)
{
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_VMINSTOP,ATTR_VISIBLE, 1);
} else{
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_VMINSTOP,ATTR_VISIBLE, 0);
}
if(mode==MODE_CHARGE)
{
SetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_TEXTMSG,"+");
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_VMAX,ATTR_DIMMED, 0);
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_VMIN,ATTR_DIMMED, 1);
switch(mode_stop)
{
case MODE_STOP_STD:
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_CMAX,ATTR_DIMMED, 1);
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_IMIN,ATTR_DIMMED, 0);
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_TIMER,ATTR_DIMMED, 1);
break;
case MODE_STOP_CMAX:
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_CMAX,ATTR_DIMMED, 0);
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_IMIN,ATTR_DIMMED, 1);
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_TIMER,ATTR_DIMMED, 1);
break;
case MODE_STOP_TIMER:
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_CMAX,ATTR_DIMMED, 1);
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_IMIN,ATTR_DIMMED, 1);
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_TIMER,ATTR_DIMMED, 0);
break;
}
}else
if(mode==MODE_DISCHARGE)
{
SetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_TEXTMSG,"-");
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_VMAX,ATTR_DIMMED, 0);
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_IMIN,ATTR_DIMMED, 1);
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_VMIN,ATTR_DIMMED, 0);
switch(mode_stop)
{
case MODE_STOP_STD:
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_CMAX,ATTR_DIMMED, 1);
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_TIMER,ATTR_DIMMED, 1);
break;
case MODE_STOP_CMAX:
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_CMAX,ATTR_DIMMED, 0);
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_TIMER,ATTR_DIMMED, 1);
break;
case MODE_STOP_TIMER:
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_CMAX,ATTR_DIMMED, 1);
SetCtrlAttribute (T_panel[PANEL_CYCLE].panel,P_CYCLE_TIMER,ATTR_DIMMED, 0);
break;
}
}
return 0;
}

/**
* @brief Get_panel_cycle
* @param
* @return 0
* @date 21/05/2014
*
*/
int Get_panel_cycle ()
{
char message[256];
char str1[256];
char str2[256];
GetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_RINGSLIDE,&T_cycle[Ctrl.cycle].mode);
GetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_RINGSTOP,&T_cycle[Ctrl.cycle].mode_stop);
GetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_CURR,&T_cycle[Ctrl.cycle].curr);
GetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_VMAX,&T_cycle[Ctrl.cycle].Vmax);
GetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_IMIN,&T_cycle[Ctrl.cycle].Imin);
GetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_VMIN,&T_cycle[Ctrl.cycle].Vmin);
GetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_CMAX,&T_cycle[Ctrl.cycle].Cmax);
GetCtrlVal (T_panel[PANEL_CYCLE].panel,P_CYCLE_TIMER,&T_cycle[Ctrl.cycle].Timermax);
if(Ctrl.verbose)
{
if(T_cycle[Ctrl.cycle].mode==0)
sprintf(str1,"Discharge");
else
sprintf(str1,"Charge");
if(T_cycle[Ctrl.cycle].mode_stop==MODE_STOP_STD)
sprintf(str2,"STD");
if(T_cycle[Ctrl.cycle].mode_stop==MODE_STOP_CMAX)
sprintf(str2,"CMAX");
if(T_cycle[Ctrl.cycle].mode_stop==MODE_STOP_TIMER)
sprintf(str2,"TIMER");
sprintf(message,"cycle :%d\n mode :%s mode stop :%s\n curr =%f A\nVmax =%f V Imin =%f A Vmin =%f V Cmax=%f Ah timermax=%ds"
,Ctrl.cycle,str1,str2,T_cycle[Ctrl.cycle].curr,T_cycle[Ctrl.cycle].Vmax,T_cycle[Ctrl.cycle].Imin,T_cycle[Ctrl.cycle].Vmin,T_cycle[Ctrl.cycle].Cmax,T_cycle[Ctrl.cycle].Timermax);
save_LOG(message);
}
return 0;
}
/**
* @brief fnct_ID_panel
* @return str panel
* @date 20/05/2015
*
*/
char * fnct_ID_panel(int i,char* str)
{
switch (i)
{
case PANEL_TOP :
sprintf(str,"TOP");
break;
case PANEL_ABOUT :
sprintf(str,"ABOUT");
break;
case PANEL_LOG :
sprintf(str,"LOG");
break;
case PANEL_PORT :
sprintf(str,"PORT");
break;
case PANEL_MEASURE :
sprintf(str,"MEASURE");
break;
case PANEL_CYCLE :
sprintf(str,"CYCLE");
break;
case PANEL_BATT :
sprintf(str,"BATT");
break;
case PANEL_GRAPH :
sprintf(str,"GRAPH");
break;
case PANEL_INFO :
sprintf(str,"INFO");
break;
}
return str;
}

/**
* @brief init panel
* @param
* @return 0
* @date 14/12/2010
*
*/
int init_reset_panel (void)
{
T_panel[PANEL_TOP].top=30;
T_panel[PANEL_TOP].left=15;
T_panel[PANEL_TOP].height=790;
T_panel[PANEL_TOP].width=940;
T_panel[PANEL_ABOUT].top=271;
T_panel[PANEL_ABOUT].left=413;
T_panel[PANEL_ABOUT].height=275;
T_panel[PANEL_ABOUT].width=375;
T_panel[PANEL_LOG].top=460;
T_panel[PANEL_LOG].left=5;
T_panel[PANEL_LOG].height=331;
T_panel[PANEL_LOG].width=930;
T_panel[PANEL_PORT].top=45;
T_panel[PANEL_PORT].left=93;
T_panel[PANEL_PORT].height=356;
T_panel[PANEL_PORT].width=755;
T_panel[PANEL_MEASURE].top=42;
T_panel[PANEL_MEASURE].left=5;
T_panel[PANEL_MEASURE].height=394;
T_panel[PANEL_MEASURE].width=930;
T_panel[PANEL_BATT].top=46;
T_panel[PANEL_BATT].left=3;
T_panel[PANEL_BATT].height=355;
T_panel[PANEL_BATT].width=407;
T_panel[PANEL_CYCLE].top=46;
T_panel[PANEL_CYCLE].left=3;
T_panel[PANEL_CYCLE].height=436;
T_panel[PANEL_CYCLE].width=410;
T_panel[PANEL_GRAPH].top=460;
T_panel[PANEL_GRAPH].left=5;
T_panel[PANEL_GRAPH].height=331;
T_panel[PANEL_GRAPH].width=930;
T_panel[PANEL_INFO].top=460;
T_panel[PANEL_INFO].left=5;
T_panel[PANEL_INFO].height=113;
T_panel[PANEL_INFO].width=913;

init_panel ();
return 0;
}

/**
* @brief init panel
* @param
* @return 0
* @date 14/12/2010
*
*/
int init_panel (void)
{
int i;
for(i=0;i<MAX_PANEL;i++)
{
SetPanelAttribute (T_panel[i].panel, ATTR_TOP, T_panel[i].top);
SetPanelAttribute (T_panel[i].panel, ATTR_LEFT,T_panel[i].left);
SetPanelAttribute (T_panel[i].panel, ATTR_HEIGHT, T_panel[i].height);
SetPanelAttribute (T_panel[i].panel, ATTR_WIDTH,T_panel[i].width);
}
return 0;
}
(14-14/25)