/*2013-01-18T16:21:48-01:00*/

/********************************************************************
 * sfp.c
 * 
 * generated by: plcgen 2.3.253
 ********************************************************************/

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

#include "sfp.h"
#include "sfp/functional/manipulateur/manipulateur.h"
#include "sfp/functional/poste_sfp/poste_sfp.h"


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

CB_Index sfp__num = 0;
CB_Mem_Bool *sfp_Presence_piece;
CB_Mem_Bool *sfp_acq;
CB_Mem_Bool *sfp_au;
CB_Mem_Int *sfp_Pos_depart;
CB_Mem_Int *sfp_Pos_arrivee;
CB_Mem_Bool *sfp_DCY;
CB_Mem_Bool *sfp_Def_Manip;
CB_Mem_Bool *sfp_OKcycle;

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



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

static CB_Offset sfp__sfp_offset_manipulateur_poste_X;
static CB_Offset sfp__sfp_offset_poste_sfp1;
static CB_Offset sfp__sfp_offset__end = {0, 0, 0, 0};


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

int _sfp__sfp_init(void)
{
	CB_Object __start = self;
	(sfp_Presence_piece)->CB_current_value = 1; /*Presence_piece*/
	self.Bool+=18;

	/*initialize child manipulateur_poste_X (sfp.manipulateur):*/
	self_num++;
	sfp__sfp_offset_manipulateur_poste_X.Bool = self.Bool - __start.Bool;
	sfp__sfp_offset_manipulateur_poste_X.Int = self.Int - __start.Int;
	sfp__sfp_offset_manipulateur_poste_X.Float = self.Float - __start.Float;
	sfp__sfp_offset_manipulateur_poste_X.Char = self.Char - __start.Char;
	manipulateur_acq = sfp_acq;
	manipulateur_au = sfp_au;
	manipulateur_Pos_depart = sfp_Pos_depart;
	manipulateur_Pos_arrivee = sfp_Pos_arrivee;
	manipulateur_DCY = sfp_DCY;
	manipulateur_FCGXS = __start.Bool+0; /*sfp__cn_18*/
	manipulateur_FCGXR = __start.Bool+1; /*sfp__cn_17*/
	manipulateur_FCPXS = __start.Bool+2; /*sfp__cn_16*/
	manipulateur_FCPXR = __start.Bool+3; /*sfp__cn_15*/
	manipulateur_FCVRS = __start.Bool+4; /*sfp__cn_14*/
	manipulateur_FCVRR = __start.Bool+5; /*sfp__cn_13*/
	manipulateur_FCVZH = __start.Bool+6; /*sfp__cn_12*/
	manipulateur_FCVZB = __start.Bool+7; /*sfp__cn_11*/
	manipulateur_vacuostat = __start.Bool+8; /*sfp__cn_10*/
	manipulateur_Def_Manip = sfp_Def_Manip;
	manipulateur_OKcycle = sfp_OKcycle;
	manipulateur_EVGXR = __start.Bool+9; /*sfp__cn_9*/
	manipulateur_EVGXS = __start.Bool+10; /*sfp__cn_8*/
	manipulateur_EVPXR = __start.Bool+11; /*sfp__cn_7*/
	manipulateur_EVPXS = __start.Bool+12; /*sfp__cn_6*/
	manipulateur_EVVRR = __start.Bool+13; /*sfp__cn_5*/
	manipulateur_EVVRS = __start.Bool+14; /*sfp__cn_4*/
	manipulateur_EVVZ = __start.Bool+15; /*sfp__cn_3*/
	manipulateur_EVVTA = __start.Bool+16; /*sfp__cn_2*/
	manipulateur_EVVTM = __start.Bool+17; /*sfp__cn_1*/
	_sfp__manipulateur_init();

	/*initialize child poste_sfp1 (sfp.poste_sfp):*/
	self_num++;
	sfp__sfp_offset_poste_sfp1.Bool = self.Bool - __start.Bool;
	sfp__sfp_offset_poste_sfp1.Int = self.Int - __start.Int;
	sfp__sfp_offset_poste_sfp1.Float = self.Float - __start.Float;
	sfp__sfp_offset_poste_sfp1.Char = self.Char - __start.Char;
	poste_sfp_EVGXR = __start.Bool+9; /*sfp__cn_9*/
	poste_sfp_EVGXS = __start.Bool+10; /*sfp__cn_8*/
	poste_sfp_EVPXR = __start.Bool+11; /*sfp__cn_7*/
	poste_sfp_EVPXS = __start.Bool+12; /*sfp__cn_6*/
	poste_sfp_EVVRR = __start.Bool+13; /*sfp__cn_5*/
	poste_sfp_EVVRS = __start.Bool+14; /*sfp__cn_4*/
	poste_sfp_EVVZ = __start.Bool+15; /*sfp__cn_3*/
	poste_sfp_EVVTA = __start.Bool+16; /*sfp__cn_2*/
	poste_sfp_EVVTM = __start.Bool+17; /*sfp__cn_1*/
	poste_sfp_Presence_piece = sfp_Presence_piece;
	poste_sfp_FCGXS = __start.Bool+0; /*sfp__cn_18*/
	poste_sfp_FCGXR = __start.Bool+1; /*sfp__cn_17*/
	poste_sfp_FCPXS = __start.Bool+2; /*sfp__cn_16*/
	poste_sfp_FCPXR = __start.Bool+3; /*sfp__cn_15*/
	poste_sfp_FCVRS = __start.Bool+4; /*sfp__cn_14*/
	poste_sfp_FCVRR = __start.Bool+5; /*sfp__cn_13*/
	poste_sfp_FCVZH = __start.Bool+6; /*sfp__cn_12*/
	poste_sfp_FCVZB = __start.Bool+7; /*sfp__cn_11*/
	poste_sfp_Vacuostat = __start.Bool+8; /*sfp__cn_10*/
	_sfp__poste_sfp_init();

	sfp__sfp_offset__end.Bool = self.Bool - __start.Bool;
	sfp__sfp_offset__end.Int = self.Int - __start.Int;
	sfp__sfp_offset__end.Float = self.Float - __start.Float;
	sfp__sfp_offset__end.Char = self.Char - __start.Char;

	return 0;
}


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

int sfp__sfp(void)
{
	CB_Object __start = self;
	int __ret;
	if (exec_mac_node(self_num)) {

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

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

		/*no Pre-conditions*/

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

		{
			self.Bool = __start.Bool + sfp__sfp_offset_manipulateur_poste_X.Bool;
			self.Int = __start.Int + sfp__sfp_offset_manipulateur_poste_X.Int;
			self.Float = __start.Float + sfp__sfp_offset_manipulateur_poste_X.Float;
			self.Char = __start.Char + sfp__sfp_offset_manipulateur_poste_X.Char;

			/****************** manipulateur_poste_X execution ******************/

			self_num++;
			if (manipulateur__num != self_num) {
				manipulateur__num = self_num;
				manipulateur_acq = sfp_acq;
				manipulateur_au = sfp_au;
				manipulateur_Pos_depart = sfp_Pos_depart;
				manipulateur_Pos_arrivee = sfp_Pos_arrivee;
				manipulateur_DCY = sfp_DCY;
				manipulateur_FCGXS = __start.Bool+0; /*sfp__cn_18*/
				manipulateur_FCGXR = __start.Bool+1; /*sfp__cn_17*/
				manipulateur_FCPXS = __start.Bool+2; /*sfp__cn_16*/
				manipulateur_FCPXR = __start.Bool+3; /*sfp__cn_15*/
				manipulateur_FCVRS = __start.Bool+4; /*sfp__cn_14*/
				manipulateur_FCVRR = __start.Bool+5; /*sfp__cn_13*/
				manipulateur_FCVZH = __start.Bool+6; /*sfp__cn_12*/
				manipulateur_FCVZB = __start.Bool+7; /*sfp__cn_11*/
				manipulateur_vacuostat = __start.Bool+8; /*sfp__cn_10*/
				manipulateur_Def_Manip = sfp_Def_Manip;
				manipulateur_OKcycle = sfp_OKcycle;
				manipulateur_EVGXR = __start.Bool+9; /*sfp__cn_9*/
				manipulateur_EVGXS = __start.Bool+10; /*sfp__cn_8*/
				manipulateur_EVPXR = __start.Bool+11; /*sfp__cn_7*/
				manipulateur_EVPXS = __start.Bool+12; /*sfp__cn_6*/
				manipulateur_EVVRR = __start.Bool+13; /*sfp__cn_5*/
				manipulateur_EVVRS = __start.Bool+14; /*sfp__cn_4*/
				manipulateur_EVVZ = __start.Bool+15; /*sfp__cn_3*/
				manipulateur_EVVTA = __start.Bool+16; /*sfp__cn_2*/
				manipulateur_EVVTM = __start.Bool+17; /*sfp__cn_1*/
			}
			__ret = sfp__manipulateur();
			if (__ret != 0) {
				return __ret; /*child execution failure*/
			}

			/*********************** poste_sfp1 execution ***********************/

			self_num++;
			if (poste_sfp__num != self_num) {
				poste_sfp__num = self_num;
				poste_sfp_EVGXR = __start.Bool+9; /*sfp__cn_9*/
				poste_sfp_EVGXS = __start.Bool+10; /*sfp__cn_8*/
				poste_sfp_EVPXR = __start.Bool+11; /*sfp__cn_7*/
				poste_sfp_EVPXS = __start.Bool+12; /*sfp__cn_6*/
				poste_sfp_EVVRR = __start.Bool+13; /*sfp__cn_5*/
				poste_sfp_EVVRS = __start.Bool+14; /*sfp__cn_4*/
				poste_sfp_EVVZ = __start.Bool+15; /*sfp__cn_3*/
				poste_sfp_EVVTA = __start.Bool+16; /*sfp__cn_2*/
				poste_sfp_EVVTM = __start.Bool+17; /*sfp__cn_1*/
				poste_sfp_Presence_piece = sfp_Presence_piece;
				poste_sfp_FCGXS = __start.Bool+0; /*sfp__cn_18*/
				poste_sfp_FCGXR = __start.Bool+1; /*sfp__cn_17*/
				poste_sfp_FCPXS = __start.Bool+2; /*sfp__cn_16*/
				poste_sfp_FCPXR = __start.Bool+3; /*sfp__cn_15*/
				poste_sfp_FCVRS = __start.Bool+4; /*sfp__cn_14*/
				poste_sfp_FCVRR = __start.Bool+5; /*sfp__cn_13*/
				poste_sfp_FCVZH = __start.Bool+6; /*sfp__cn_12*/
				poste_sfp_FCVZB = __start.Bool+7; /*sfp__cn_11*/
				poste_sfp_Vacuostat = __start.Bool+8; /*sfp__cn_10*/
			}
			__ret = sfp__poste_sfp();
			if (__ret != 0) {
				return __ret; /*child execution failure*/
			}

		}


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

		/*no Post-conditions*/
	}

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

	self.Bool = __start.Bool + sfp__sfp_offset__end.Bool;
	self.Int = __start.Int + sfp__sfp_offset__end.Int;
	self.Float = __start.Float + sfp__sfp_offset__end.Float;
	self.Char = __start.Char + sfp__sfp_offset__end.Char;

	return 0;
}

