domain T1_Interval_1_10 = [1,10];
domain T2_ok_hs = {ok, hs};
func O2_op_5_sur_12
	flow
		op_5_sur_12 : bool : out ;
		o1 : T2_ok_hs : in;
		o2 : T2_ok_hs : in;
		o3 : T2_ok_hs : in;
		o4 : T2_ok_hs : in;
		o5 : T2_ok_hs : in;
		o6 : T2_ok_hs : in;
		o7 : T2_ok_hs : in;
		o8 : T2_ok_hs : in;
		o9 : T2_ok_hs : in;
		o10 : T2_ok_hs : in;
		o11 : T2_ok_hs : in;
		o12 : T2_ok_hs : in;
		
	assert
		op_5_sur_12 = case{((o1=hs and o2=hs and o3=hs and o4=hs and o5=hs) or 
(o1=hs and o2=hs and o3=hs and o4=hs and o6=hs) or
(o1=hs and o2=hs and o3=hs and o4=hs and o7=hs) or 
(o1=hs and o2=hs and o3=hs and o4=hs and o8=hs) or
(o1=hs and o2=hs and o3=hs and o4=hs and o9=hs) or 
(o1=hs and o2=hs and o3=hs and o4=hs and o10=hs) or
(o1=hs and o2=hs and o3=hs and o4=hs and o11=hs) or 
(o1=hs and o2=hs and o3=hs and o4=hs and o12=hs) or
(o2=hs and o3=hs and o4=hs and o5=hs and o6=hs) or 
(o2=hs and o3=hs and o4=hs and o5=hs and o7=hs) or 
(o2=hs and o3=hs and o4=hs and o5=hs and o8=hs) or 
(o2=hs and o3=hs and o4=hs and o5=hs and o9=hs) or 
(o2=hs and o3=hs and o4=hs and o5=hs and o10=hs) or 
(o2=hs and o3=hs and o4=hs and o5=hs and o11=hs) or 
(o2=hs and o3=hs and o4=hs and o5=hs and o12=hs) or 
(o3=hs and o4=hs and o5=hs and o6=hs and o7=hs) or 
(o3=hs and o4=hs and o5=hs and o6=hs and o8=hs) or 
(o3=hs and o4=hs and o5=hs and o6=hs and o9=hs) or 
(o3=hs and o4=hs and o5=hs and o6=hs and o10=hs) or 
(o3=hs and o4=hs and o5=hs and o6=hs and o11=hs) or 
(o3=hs and o4=hs and o5=hs and o6=hs and o12=hs) or 
(o3=hs and o4=hs and o5=hs and o6=hs and o1=hs) or 
(o4=hs and o5=hs and o6=hs and o7=hs and o8=hs) or 
(o4=hs and o5=hs and o6=hs and o7=hs and o9=hs) or 
(o4=hs and o5=hs and o6=hs and o7=hs and o10=hs) or 
(o4=hs and o5=hs and o6=hs and o7=hs and o11=hs) or 
(o4=hs and o5=hs and o6=hs and o7=hs and o12=hs) or 
(o4=hs and o5=hs and o6=hs and o7=hs and o1=hs) or 
(o4=hs and o5=hs and o6=hs and o7=hs and o2=hs) or 
(o5=hs and o6=hs and o7=hs and o8=hs and o9=hs) or 
(o5=hs and o6=hs and o7=hs and o8=hs and o10=hs) or 
(o5=hs and o6=hs and o7=hs and o8=hs and o11=hs) or 
(o5=hs and o6=hs and o7=hs and o8=hs and o12=hs) or 
(o5=hs and o6=hs and o7=hs and o8=hs and o1=hs) or 
(o5=hs and o6=hs and o7=hs and o8=hs and o2=hs) or 
(o5=hs and o6=hs and o7=hs and o8=hs and o3=hs) or 
(o6=hs and o7=hs and o8=hs and o9=hs and o10=hs) or 
(o6=hs and o7=hs and o8=hs and o9=hs and o11=hs) or 
(o6=hs and o7=hs and o8=hs and o9=hs and o12=hs) or 
(o6=hs and o7=hs and o8=hs and o9=hs and o1=hs) or 
(o6=hs and o7=hs and o8=hs and o9=hs and o2=hs) or 
(o6=hs and o7=hs and o8=hs and o9=hs and o3=hs) or 
(o6=hs and o7=hs and o8=hs and o9=hs and o4=hs) or 
(o7=hs and o8=hs and o9=hs and o10=hs and o11=hs) or 
(o7=hs and o8=hs and o9=hs and o10=hs and o12=hs) or 
(o7=hs and o8=hs and o9=hs and o10=hs and o1=hs) or 
(o7=hs and o8=hs and o9=hs and o10=hs and o2=hs) or 
(o7=hs and o8=hs and o9=hs and o10=hs and o3=hs) or 
(o7=hs and o8=hs and o9=hs and o10=hs and o4=hs) or 
(o7=hs and o8=hs and o9=hs and o10=hs and o5=hs) or 
(o8=hs and o9=hs and o10=hs and o11=hs and o12=hs) or 
(o8=hs and o9=hs and o10=hs and o11=hs and o1=hs) or 
(o8=hs and o9=hs and o10=hs and o11=hs and o2=hs) or 
(o8=hs and o9=hs and o10=hs and o11=hs and o3=hs) or 
(o8=hs and o9=hs and o10=hs and o11=hs and o4=hs) or 
(o8=hs and o9=hs and o10=hs and o11=hs and o5=hs) or 
(o8=hs and o9=hs and o10=hs and o11=hs and o6=hs) or 
(o9=hs and o10=hs and o11=hs and o12=hs and o1=hs) or 
(o9=hs and o10=hs and o11=hs and o12=hs and o2=hs) or 
(o9=hs and o10=hs and o11=hs and o12=hs and o3=hs) or 
(o9=hs and o10=hs and o11=hs and o12=hs and o4=hs) or 
(o9=hs and o10=hs and o11=hs and o12=hs and o5=hs) or 
(o9=hs and o10=hs and o11=hs and o12=hs and o6=hs) or 
(o9=hs and o10=hs and o11=hs and o12=hs and o7=hs) or 
(o10=hs and o11=hs and o12=hs and o1=hs and o2=hs) or 
(o10=hs and o11=hs and o12=hs and o1=hs and o3=hs) or 
(o10=hs and o11=hs and o12=hs and o1=hs and o4=hs) or 
(o10=hs and o11=hs and o12=hs and o1=hs and o5=hs) or 
(o10=hs and o11=hs and o12=hs and o1=hs and o6=hs) or 
(o10=hs and o11=hs and o12=hs and o1=hs and o7=hs) or 
(o10=hs and o11=hs and o12=hs and o1=hs and o8=hs) or 
(o11=hs and o12=hs and o1=hs and o2=hs and o3=hs) or 
(o11=hs and o12=hs and o1=hs and o2=hs and o4=hs) or 
(o11=hs and o12=hs and o1=hs and o2=hs and o5=hs) or 
(o11=hs and o12=hs and o1=hs and o2=hs and o6=hs) or 
(o11=hs and o12=hs and o1=hs and o2=hs and o7=hs) or 
(o11=hs and o12=hs and o1=hs and o2=hs and o8=hs) or 
(o11=hs and o12=hs and o1=hs and o2=hs and o9=hs) or 
(o12=hs and o1=hs and o2=hs and o3=hs and o4=hs) or 
(o12=hs and o1=hs and o2=hs and o3=hs and o5=hs) or 
(o12=hs and o1=hs and o2=hs and o3=hs and o6=hs) or 
(o12=hs and o1=hs and o2=hs and o3=hs and o7=hs) or 
(o12=hs and o1=hs and o2=hs and o3=hs and o8=hs) or 
(o12=hs and o1=hs and o2=hs and o3=hs and o9=hs) or 
(o12=hs and o1=hs and o2=hs and o3=hs and o10=hs)) : true,else false};
		
cnuf
node A8_Hydraulics
	flow
		output : T1_Interval_1_10 : out;
		Icon : {I34eau, I42hydraulics_rouge, I41hydraulics_orange} : out;

	state
		ok : bool;
		low_level : bool;
	
	event
		failure;
		level_loss;
		
	trans
		ok = true |-failure->ok:=false, low_level:=false;
		ok = true and low_level = false |-level_loss->ok:=true, low_level:=true;
		
	assert
		output = case{(ok = true and low_level = false) : 1,(ok = false) : 10,else 5};
		Icon = case{(ok = true and low_level = false) : I34eau,(ok = false) : I42hydraulics_rouge,else I41hydraulics_orange};
		
	init
		ok := true;
		low_level := false;
	
	extern
		law <event failure> = exponential(1e-5);
		law <event level_loss> = exponential(1e-2);
		
edon
node A7_Electrical
	flow
		output : T1_Interval_1_10 : out;
		Icon : {I38electric_vert, I39electric_rouge, I40electric_orange} : out;

	state
		ok : bool;
		low_level : bool;
	
	event
		failure;
		level_loss;
		
	trans
		ok = true  |-failure->ok:=false, low_level:=false;
		ok = true and low_level = false |-level_loss->ok:=true, low_level:=true;
		
	assert
		output = case{(ok = true and low_level = false) : 1,(ok = false) : 10,else 5};
		Icon = case{(ok =true and low_level =false) : I38electric_vert,(ok = false) : I39electric_rouge,else I40electric_orange};
		
	init
		ok := true;
		low_level := false;
	
	extern
		law <event failure> = exponential(1e-1);
		law <event level_loss> = exponential(1e-2);
		
edon
node A4_moteur
	flow
		output : T2_ok_hs : out;
		electric : T1_Interval_1_10 : in;
		hydraulics : T1_Interval_1_10 : in;
		Icon : {I29pompe_verte, I30pompe_rouge} : out;

	state
		power : T2_ok_hs;
	
	event
		failure;
		
	trans
		power = ok |-failure->power:=hs;
		
	assert
		output = case{(power = ok and electric = 1 and hydraulics = 1) : ok,(power = ok and ((electric = 10 or hydraulics = 10) or (electric = 5 and  hydraulics = 5))) : hs,(power = hs) : hs,else ok};
		Icon = case{(power = ok and electric = 1 and hydraulics = 1) : I29pompe_verte,(power = ok and ((electric = 10 or hydraulics = 10) or (electric = 5 and  hydraulics = 5))) : I30pompe_rouge,(power = hs) : I30pompe_rouge,else I29pompe_verte};
		
	init
		power := ok;
	
	extern
		law <event failure> = exponential(1e-5);
		
edon
node A5_Calculateur
	flow
		c1 : T2_ok_hs : in;
		c2 : T2_ok_hs : in;
		c3 : T2_ok_hs : in;
		c4 : T2_ok_hs : in;
		c5 : T2_ok_hs : in;
		c6 : T2_ok_hs : in;
		c7 : T2_ok_hs : in;
		c8 : T2_ok_hs : in;
		c9 : T2_ok_hs : in;
		c10 : T2_ok_hs : in;
		c11 : T2_ok_hs : in;
		c12 : T2_ok_hs : in;
		Icon : {I17calculateur_vert, I16calculateur_rouge} : out;

	state
		power : T2_ok_hs;
	
	event
		failure;
		
	trans
		power = ok |-failure->power:=hs;
		
	assert
		Icon = case{(c1=ok and c2=ok and c3=ok and c4=ok and c5=ok and c6=ok and c7=ok and c8=ok and c9=ok and c10=ok and c11=ok and c12=ok) : I17calculateur_vert,(O2_op_5_sur_12(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12) = true) : I16calculateur_rouge,else I17calculateur_vert};
		
	init
		power := ok;
	
	extern
		law <event failure> = exponential(1e-2);
		
edon
node main
	sub
		Hydraulics : A8_Hydraulics;
		Hydraulics_copy : A8_Hydraulics;
		Hydraulics_copy2 : A8_Hydraulics;
		Hydraulics_copy3 : A8_Hydraulics;
		Hydraulics_copy4 : A8_Hydraulics;
		Hydraulics_copy5 : A8_Hydraulics;
		Hydraulics_copy6 : A8_Hydraulics;
		Hydraulics_copy7 : A8_Hydraulics;
		Electrical : A7_Electrical;
		Electrical_copy : A7_Electrical;
		Electrical_copy2 : A7_Electrical;
		Electrical_copy3 : A7_Electrical;
		Electrical_copy4 : A7_Electrical;
		Electrical_copy5 : A7_Electrical;
		Electrical_copy6 : A7_Electrical;
		Electrical_copy7 : A7_Electrical;
		engine0 : A4_moteur;
		engine1 : A4_moteur;
		engine2 : A4_moteur;
		engine3 : A4_moteur;
		engine4 : A4_moteur;
		engine5 : A4_moteur;
		engine_6 : A4_moteur;
		engine7 : A4_moteur;
		engine8 : A4_moteur;
		engine9 : A4_moteur;
		engine10 : A4_moteur;
		engine11 : A4_moteur;
		Hydraulics_copy8 : A8_Hydraulics;
		Electrical_copy8 : A7_Electrical;
		Electrical_copy9 : A7_Electrical;
		Electrical_copy10 : A7_Electrical;
		Hydraulics_copy9 : A8_Hydraulics;
		Hydraulics_copy10 : A8_Hydraulics;
		Hydraulics_copy11 : A8_Hydraulics;
		Electrical_copy11 : A7_Electrical;
		Calculateur : A5_Calculateur;
		
	assert
		//Icon = case{};
		Hydraulics.output=engine0.hydraulics;
		Electrical.output=engine0.electric;
		Hydraulics_copy.output=engine1.hydraulics;
		Electrical_copy.output=engine1.electric;
		Hydraulics_copy2.output=engine2.hydraulics;
		Electrical_copy2.output=engine2.electric;
		Hydraulics_copy3.output=engine3.hydraulics;
		Hydraulics_copy4.output=engine4.hydraulics;
		Electrical_copy4.output=engine4.electric;
		Electrical_copy5.output=engine5.electric;
		Hydraulics_copy5.output=engine5.hydraulics;
		Electrical_copy3.output=engine3.electric;
		Hydraulics_copy11.output=engine_6.hydraulics;
		Electrical_copy11.output=engine_6.electric;
		Hydraulics_copy6.output=engine7.hydraulics;
		Electrical_copy6.output=engine7.electric;
		Hydraulics_copy7.output=engine8.hydraulics;
		Electrical_copy7.output=engine8.electric;
		Hydraulics_copy8.output=engine9.hydraulics;
		Hydraulics_copy10.output=engine10.hydraulics;
		Electrical_copy8.output=engine9.electric;
		Electrical_copy9.output=engine10.electric;
		Hydraulics_copy9.output=engine11.hydraulics;
		Electrical_copy10.output=engine11.electric;
		engine0.output=Calculateur.c1;
		engine_6.output=Calculateur.c2;
		engine7.output=Calculateur.c3;
		engine8.output=Calculateur.c4;
		engine9.output=Calculateur.c5;
		engine10.output=Calculateur.c6;
		engine11.output=Calculateur.c7;
		engine5.output=Calculateur.c8;
		engine4.output=Calculateur.c9;
		engine3.output=Calculateur.c10;
		engine2.output=Calculateur.c11;
		engine1.output=Calculateur.c12;
		
	extern
		predicate dreaded_event = <term (Calculateur.c2 = hs)>;
edon
