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

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

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

#include "mdl_deplacement.h"


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

CB_Index mdl_deplacement__num = 0;
CB_Mem_Int *mdl_deplacement_Dem_Pos;
CB_Mem_Bool *mdl_deplacement_GO;
CB_Mem_Bool *mdl_deplacement_acq;
CB_Mem_Bool *mdl_deplacement_AU;
CB_Mem_Bool *mdl_deplacement_CR_GXR;
CB_Mem_Bool *mdl_deplacement_CR_GXS;
CB_Mem_Bool *mdl_deplacement_def_GX;
CB_Mem_Bool *mdl_deplacement_CR_PXR;
CB_Mem_Bool *mdl_deplacement_CR_PXS;
CB_Mem_Bool *mdl_deplacement_def_PX;
CB_Mem_Bool *mdl_deplacement_CR_VRR;
CB_Mem_Bool *mdl_deplacement_CR_VRS;
CB_Mem_Bool *mdl_deplacement_def_VR;
CB_Mem_Int *mdl_deplacement_CR_Pos;
CB_Mem_Bool *mdl_deplacement_Def_Depl;
CB_Mem_Bool *mdl_deplacement_GXR;
CB_Mem_Bool *mdl_deplacement_GXS;
CB_Mem_Bool *mdl_deplacement_PXR;
CB_Mem_Bool *mdl_deplacement_PXS;
CB_Mem_Bool *mdl_deplacement_VRR;
CB_Mem_Bool *mdl_deplacement_VRS;

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

#define Dem_Pos (*((short *)&(mdl_deplacement_Dem_Pos->CB_current_value) + ALIGN_OFFSET_SHORT))
#define GO (mdl_deplacement_GO->CB_current_value)
#define acq (mdl_deplacement_acq->CB_current_value)
#define AU (mdl_deplacement_AU->CB_current_value)
#define CR_GXR (mdl_deplacement_CR_GXR->CB_current_value)
#define CR_GXS (mdl_deplacement_CR_GXS->CB_current_value)
#define def_GX (mdl_deplacement_def_GX->CB_current_value)
#define CR_PXR (mdl_deplacement_CR_PXR->CB_current_value)
#define CR_PXS (mdl_deplacement_CR_PXS->CB_current_value)
#define def_PX (mdl_deplacement_def_PX->CB_current_value)
#define CR_VRR (mdl_deplacement_CR_VRR->CB_current_value)
#define CR_VRS (mdl_deplacement_CR_VRS->CB_current_value)
#define def_VR (mdl_deplacement_def_VR->CB_current_value)
#define CR_Pos (*((short *)&(mdl_deplacement_CR_Pos->CB_current_value) + ALIGN_OFFSET_SHORT))
#define Def_Depl (mdl_deplacement_Def_Depl->CB_current_value)
#define GXR (mdl_deplacement_GXR->CB_current_value)
#define GXS (mdl_deplacement_GXS->CB_current_value)
#define PXR (mdl_deplacement_PXR->CB_current_value)
#define PXS (mdl_deplacement_PXS->CB_current_value)
#define VRR (mdl_deplacement_VRR->CB_current_value)
#define VRS (mdl_deplacement_VRS->CB_current_value)


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


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

int _sfp__mdl_deplacement_init(void)
{


	return 0;
}


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

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

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


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

		/*no Pre-conditions*/

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

		{
			if (((def_PX || def_GX) || def_VR) || AU) {
				cov_control_struct(__comp_name, self_num, INCODE, 3, IFTHEN);
				GXR = 0;
				GXS = 0;
				PXR = 0;
				PXS = 0;
				VRR = 0;
				VRS = 0;
				Def_Depl = 1;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 3, IFELSE);
			}
			if ((((acq && !def_PX) && !def_GX) && !def_VR) && !AU) {
				cov_control_struct(__comp_name, self_num, INCODE, 13, IFTHEN);
				Def_Depl = 0;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 13, IFELSE);
			}
			GXR = (((((Dem_Pos == 0) || (Dem_Pos == 1)) || (Dem_Pos == 2)) || (Dem_Pos == 3)) && !Def_Depl) && GO;
			GXS = (((((Dem_Pos == 4) || (Dem_Pos == 5)) || (Dem_Pos == 6)) || (Dem_Pos == 7)) && !Def_Depl) && GO;
			PXR = (((((Dem_Pos == 0) || (Dem_Pos == 1)) || (Dem_Pos == 4)) || (Dem_Pos == 5)) && !Def_Depl) && GO;
			PXS = (((((Dem_Pos == 2) || (Dem_Pos == 3)) || (Dem_Pos == 6)) || (Dem_Pos == 7)) && !Def_Depl) && GO;
			VRR = (((((Dem_Pos == 0) || (Dem_Pos == 3)) || (Dem_Pos == 4)) || (Dem_Pos == 7)) && !Def_Depl) && GO;
			VRS = (((((Dem_Pos == 1) || (Dem_Pos == 2)) || (Dem_Pos == 5)) || (Dem_Pos == 6)) && !Def_Depl) && GO;
			if ((CR_GXR && CR_PXR) && CR_VRR) {
				cov_control_struct(__comp_name, self_num, INCODE, 27, IFTHEN);
				CR_Pos = 0;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 27, IFELSE);
			}
			if ((CR_GXR && CR_PXR) && CR_VRS) {
				cov_control_struct(__comp_name, self_num, INCODE, 28, IFTHEN);
				CR_Pos = 1;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 28, IFELSE);
			}
			if ((CR_GXR && CR_PXS) && CR_VRS) {
				cov_control_struct(__comp_name, self_num, INCODE, 29, IFTHEN);
				CR_Pos = 2;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 29, IFELSE);
			}
			if ((CR_GXR && CR_PXS) && CR_VRR) {
				cov_control_struct(__comp_name, self_num, INCODE, 30, IFTHEN);
				CR_Pos = 3;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 30, IFELSE);
			}
			if ((CR_GXS && CR_PXR) && CR_VRR) {
				cov_control_struct(__comp_name, self_num, INCODE, 31, IFTHEN);
				CR_Pos = 4;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 31, IFELSE);
			}
			if ((CR_GXS && CR_PXR) && CR_VRS) {
				cov_control_struct(__comp_name, self_num, INCODE, 32, IFTHEN);
				CR_Pos = 5;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 32, IFELSE);
			}
			if ((CR_GXS && CR_PXS) && CR_VRS) {
				cov_control_struct(__comp_name, self_num, INCODE, 33, IFTHEN);
				CR_Pos = 6;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 33, IFELSE);
			}
			if ((CR_GXS && CR_PXS) && CR_VRR) {
				cov_control_struct(__comp_name, self_num, INCODE, 34, IFTHEN);
				CR_Pos = 7;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 34, IFELSE);
			}
			if (((!CR_GXS && !CR_GXR) || (!CR_PXS && !CR_PXR)) || (!CR_VRR && !CR_VRS)) {
				cov_control_struct(__comp_name, self_num, INCODE, 35, IFTHEN);
				CR_Pos = 99;
			}
			else {
				cov_control_struct(__comp_name, self_num, INCODE, 35, IFELSE);
			}
		}

		CB_post_int(mdl_deplacement_CR_Pos);
		CB_post_bool(mdl_deplacement_Def_Depl);
		CB_post_bool(mdl_deplacement_GXR);
		CB_post_bool(mdl_deplacement_GXS);
		CB_post_bool(mdl_deplacement_PXR);
		CB_post_bool(mdl_deplacement_PXS);
		CB_post_bool(mdl_deplacement_VRR);
		CB_post_bool(mdl_deplacement_VRS);

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

		/*no Post-conditions*/
	}

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


	return 0;
}

