%
% The hardest version of problem3 that we have.
%

%%%%%%%%%%%%%%%%%%      Initial Situation       %%%%%%%%%%%%%%%%%%%% 
%%%%%%%%%%%%%%%%%% FAULTS and OTHER EXCEPTIONS  %%%%%%%%%%%%%%%%%%%% 

has_leak(ffm2).
has_leak(fom3).
has_leak(rfm3).
has_leak(rfm4).
has_leak(lom1).
has_leak(lfx345).

stuck(rfi345a,closed).
stuck(roi345b,closed).
stuck(rfi12,closed).
stuck(lx12,closed).

h(in_state(ffm2,open),0).
h(in_state(fom3,open),0).
h(in_state(lfx345,open),0).
h(in_state(lom1,open),0).
h(in_state(rfm3,open),0).
h(in_state(rfm4,open),0).


stuck_at(fhca_w99,fhca_g5,0).
 
%%%%%%%%%%%%%%%%%%%%%%%%     GOALS     %%%%%%%%%%%%%%%%%%%%%%%%%% 


% A goal must be specified for every subsystem of the RCS.
% If subsystem 's' is not involved in the goal use done(s).  

% Maneuver -Z 

goal(T,fwd_rcs) :- time(T),
                   pair_of_jets(J1,J2),
                   h(ready_to_fire(J1),T),
                   h(ready_to_fire(J2),T).

goal(T,left_rcs) :- time(T), 
                    jet_of(J,left_rcs),
                    direction(J,down),
                    h(ready_to_fire(J),T).
                    
goal(T,right_rcs) :- time(T), 
                     jet_of(J,right_rcs),
                     direction(J,up),
                     h(ready_to_fire(J),T).                    
                   



         

% Checking plan:

%:- not occurs(flip(fm2,closed),0).
%:- not occurs(flip(fm3,closed),1).
%:- not occurs(flip(fha,open),2).
%:- not occurs(flip(fi12,open),3).
%:- not occurs(flip(fi345,open),4).
%:- not occurs(flip(fm1,open),5).
%:- not occurs(flip(fm4,open),6).

%:- not occurs(flip(rm3,closed),0).
%:- not occurs(flip(rm4,closed),1).
%:- not occurs(flip(rha,open),2).
%:- not occurs(open_roi345a,3).
%:- not occurs(open_rfi345b,4).
%:- not occurs(flip(rx345,open),5).
%:- not occurs(flip(rx12,open),6).
%:- not occurs(flip(rm2,open),7).

%:- not occurs(opena_lfhb,0). 
%:- not occurs(open_loi345b,1). 
%:- not occurs(flip(lm3,open),2). 
%:- not occurs(flip(lm4,open),3). 
%:- not occurs(close_lfx345,4). 
%:- not occurs(flip(lm1,closed),5). 
%:- not occurs(flip(li12,open),6). 
%:- not occurs(flip(lm2,open),7).



%% Not generated by plan. But it was checked.
%occurs(flip(lm1,closed),0),
%occurs(flip(lx345,closed),1),
%occurs(flip(lha,open),2),
%occurs(flip(li12,open),3),
%occurs(flip(lm2,open),4).


