/*2011-01-03T15:22:32-01:00*/

/********************************************************************
 * vacuostat_cov.c
 * 
 * generated by: plcgen 2.1.201
 ********************************************************************/

#include "cb_comp.h"
#include "cb_covs.h"
#include "iec_1131.h"

#include "vacuostat.h"


/**************************** Variables *****************************/

CB_Index vacuostat__num = 0;
CB_Mem_Bool *vacuostat_VZB;
CB_Mem_Bool *vacuostat_VTM;
CB_Mem_Bool *vacuostat_VTA;
CB_Mem_Bool *vacuostat_Presence_piece;
CB_Mem_Bool *vacuostat_Vacuostat;
CB_Mem_Bool *vacuostat_Ventouse_marche;

/**************************** Variables *****************************/

#define VZB (vacuostat_VZB->CB_current_value)
#define VTM (vacuostat_VTM->CB_current_value)
#define VTA (vacuostat_VTA->CB_current_value)
#define Presence_piece (vacuostat_Presence_piece->CB_current_value)
#define Vacuostat (vacuostat_Vacuostat->CB_current_value)
#define Ventouse_marche (vacuostat_Ventouse_marche->CB_current_value)


/************************ Components offsets ************************/


/********************* Initialization function **********************/

int _sfp__vacuostat_init(void)
{
	(vacuostat_Presence_piece)->CB_current_value = 1; /*Presence_piece*/
	self.Bool+=1;


	return 0;
}


/************************ Behavior function *************************/

int sfp__vacuostat(void)
{
	static char *__comp_name = "sfp.vacuostat";
	if (exec_term_node(self_num)) {

		/*********************** Internals variables ************************/

		vacuostat_Ventouse_marche = self.Bool+0;

		/********************* Pre-conditions execution *********************/

		/*no Pre-conditions*/

		/************************ Behavior execution ************************/

		{
			if (VTM && !VTA) {
				cov_control_struct(__comp_name, self_num, INCODE, 1, IFTHEN);
				Ventouse_marche = 1;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 1, IFELSE);
			}
			if (VTA && !VTM) {
				cov_control_struct(__comp_name, self_num, INCODE, 2, IFTHEN);
				Ventouse_marche = 0;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 2, IFELSE);
			}
			if ((VZB && Ventouse_marche) && Presence_piece) {
				cov_control_struct(__comp_name, self_num, INCODE, 4, IFTHEN);
				Vacuostat = 1;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 4, IFELSE);
			}
			if (!Ventouse_marche) {
				cov_control_struct(__comp_name, self_num, INCODE, 5, IFTHEN);
				Vacuostat = 0;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 5, IFELSE);
			}
		}

		CB_post_bool(vacuostat_Vacuostat);

		/******************** Post-conditions execution *********************/

		/*no Post-conditions*/
	}

	/*************************** self update ****************************/

	self.Bool += 1;

	return 0;
}

