%%%
  VERSION: 1
  LANGUAGE: ENGLISH
%%%

MODULE SWUSRF (SYSMODULE)

! ----------------
! $Revision: 1.5 $ 
! ----------------
!

!---------------------------------------
! G L O B A L  D A T A
!--------------------------------------- 

  CONST string Version_SWUSRF := "1.0.0";
! Description: 
! CONST string Version_XXXXXXXX := "1.2.3";
!
!          XXXXXXXX - Module name
!                 1 - version number  (changed of SEROP) 
!                 2 - revision number (changed of SEROP)
!                 3 - revision number (for external use)

PERS spotmdata spot1 := [1, 1, 1];

PERS bool sw_inpos  := FALSE;
VAR num sw_close_corr := 100;
VAR num sw_event2_time := 0;
VAR num sw_event3_time := 0;


!---------------------------------------
! E V E N T   T I M E   R O U T I N E S
!---------------------------------------

!sw_close_time:
!Calculates the gun close time (the event1 time).
FUNC num sw_close_time (num eqid)
  VAR num close_time;
  TEST sw_spot{eqid}.gun_pressure
    CASE 1:
      close_time := sw_gun{eqid}.close_time1;
    CASE 2:
      close_time := sw_gun{eqid}.close_time2;
    CASE 3:
      close_time := sw_gun{eqid}.close_time3;
    CASE 4:
      close_time := sw_gun{eqid}.close_time4;
    DEFAULT:
      close_time := 0;
  ENDTEST
  return close_time;  
ENDFUNC


!sw_ev2_time:
!Calculates the event2 time.
FUNC num sw_ev2_time (num eqid)
  VAR num event_time;  
  event_time := sw_event2_time;
  return event_time;  
ENDFUNC


!sw_ev3_time:
!Calculates the event3 time.
FUNC num sw_ev3_time (num eqid)
  VAR num event_time;  
  event_time := sw_event3_time;
  return event_time;  
ENDFUNC

!---------------------------------------
! S E R V I C E  R O U T I N E S
!---------------------------------------

PROC sw_service_cg(num eqid)
  VAR num input_key;

!User defined code:
! Service when pressure not reached.
  TPErase;
  TPWrite "Close gun error in gun equipment "\Num:=eqid;  
  TPReadFK input_key,"sw_service_cg not prepared.","","","","","Return";
  TEST input_key
  CASE 5:
  DEFAULT:
  ENDTEST
ENDPROC

PROC sw_service_og(num eqid)
  VAR num input_key;

!User defined code:
! Service after gun open timeout
  TPErase;
  TPWrite "Open gun error in gun equipment "\Num:=eqid;
  TPReadFK input_key,"sw_service_og not prepared.","","","","","Return";
  TEST input_key
  CASE 5:
  DEFAULT:
  ENDTEST
ENDPROC

PROC sw_service_wf(num eqid)
  VAR num input_key;

!User defined code:  
! Service after weld_ready timeout.
  TPErase;
  TPWrite "Weld error in gun equipment "\Num:=eqid;
  TPReadFK input_key,"sw_service_wf not prepared.","","","","","Return";
  TEST input_key     
  CASE 5:   
  DEFAULT:
  ENDTEST
ENDPROC

ENDMODULE
