/*2013-01-18T16:22:27-01:00*/

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

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

#include "commut_3pos_2sorties.h"


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

CB_Index commut_3pos_2sorties__num = 0;
CB_Mem_Bool *commut_3pos_2sorties_variableGauche;
CB_Mem_Bool *commut_3pos_2sorties_variableDroite;
CB_Mem_Bool *commut_3pos_2sorties_posGauche;
CB_Mem_Bool *commut_3pos_2sorties_posMilieu;
CB_Mem_Bool *commut_3pos_2sorties_posDroite;

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

#define variableGauche (commut_3pos_2sorties_variableGauche->CB_current_value)
#define variableDroite (commut_3pos_2sorties_variableDroite->CB_current_value)
#define posGauche (commut_3pos_2sorties_posGauche->CB_current_value)
#define posMilieu (commut_3pos_2sorties_posMilieu->CB_current_value)
#define posDroite (commut_3pos_2sorties_posDroite->CB_current_value)


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


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

int _bibliotheque_epo__commut_3pos_2sorties_init(void)
{
	self.Bool+=3;


	return 0;
}


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

int bibliotheque_epo__commut_3pos_2sorties(void)
{
	if (exec_term_node(self_num)) {

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

		commut_3pos_2sorties_posGauche = self.Bool+0;
		commut_3pos_2sorties_posMilieu = self.Bool+1;
		commut_3pos_2sorties_posDroite = self.Bool+2;

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

		/*no Pre-conditions*/

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

		{
			if (posGauche) {
				variableGauche = 1;
				variableDroite = 0;
			}
			if (posMilieu) {
				variableGauche = 0;
				variableDroite = 0;
			}
			if (posDroite) {
				variableGauche = 0;
				variableDroite = 1;
			}
			posGauche = 0;
			posMilieu = 0;
			posDroite = 0;
		}

		CB_post_bool(commut_3pos_2sorties_variableGauche);
		CB_post_bool(commut_3pos_2sorties_variableDroite);

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

		/*no Post-conditions*/
	}

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

	self.Bool += 3;

	return 0;
}

