-- Comment to force html into preformatted mode <pre>
Type
	pitch_modes: enum {vert_speed, ias, alt_cap, alt_hold};
Var
  pitch_mode: pitch_modes;
  capture_armed: boolean;
  ideal_capture: boolean;

startstate
begin
  clear pitch_mode;
  capture_armed := false;
  ideal_capture := false;
  Assert (ideal_capture = (capture_armed | pitch_mode = alt_cap));
end;

rule "ALT CAPTURE" pitch_mode != alt_cap ==>
begin
  ideal_capture := capture_armed;
  capture_armed := !capture_armed;
  ideal_capture := !ideal_capture;
  Assert (ideal_capture = (capture_armed | pitch_mode = alt_cap));
end;

rule "HLD" 
begin
  ideal_capture := capture_armed;
  pitch_mode := alt_hold;
--  capture_armed := false;
  Assert (ideal_capture = (capture_armed | pitch_mode = alt_cap));
end;

rule "IAS" 
begin
  ideal_capture := capture_armed;
  pitch_mode := ias; 
  Assert (ideal_capture = (capture_armed | pitch_mode = alt_cap));
end;

rule "VSPD" 
begin
  ideal_capture := capture_armed;
  pitch_mode := vert_speed; 
  Assert (ideal_capture = (capture_armed | pitch_mode = alt_cap));
end;

rule "near"
begin
  if capture_armed then
--    capture_armed := false;
    pitch_mode := alt_cap; 
  endif;
--  Assert (ideal_capture = (capture_armed | pitch_mode = alt_cap));
end;

rule "arrived"
begin
--  if pitch_mode = alt_cap then
--    pitch_mode := alt_hold;
--  endif;
  if capture_armed then
    pitch_mode := alt_hold;
    capture_armed := false;
  endif;
  if ideal_capture then
    ideal_capture := false;
  endif;
  Assert (ideal_capture = (capture_armed | pitch_mode = alt_cap));
end;

Rule "whoops"
Begin
  ideal_capture := !ideal_capture;
End;

-- invariant (ideal_capture = (capture_armed | pitch_mode = alt_cap));
