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

MODULE BASE (SYSMODULE, NOSTEPIN, VIEWONLY)

 ! System module with basic predefined system data
 !************************************************


 ! System data tool0, wobj0 and load0
 ! Do not translate or delete tool0, wobj0, load0
 PERS tooldata tool0 := [TRUE, [[0, 0, 0], [1, 0, 0, 0]],
                        [0.001, [0, 0, 0.001],[1, 0, 0, 0], 0, 0, 0]];

 PERS wobjdata wobj0 := [FALSE, TRUE, "", [[0, 0, 0],[1, 0, 0, 0]],
                        [[0, 0, 0],[1, 0, 0, 0]]];

 PERS loaddata load0 := [0.001, [0, 0, 0.001],[1, 0, 0, 0], 0, 0, 0];

 ! Declaration of stoppoint types
 CONST stoppoint inpos := 1;
 CONST stoppoint stoptime := 2;
 CONST stoppoint fllwtime := 3;

 ! Declaration of stoppointdata
 CONST stoppointdata inpos20     := [inpos,    TRUE,  [ 20,  20, 0, 2],   0,   0, "", 0, 0];
 CONST stoppointdata inpos50     := [inpos,    TRUE,  [ 50,  50, 0, 2],   0,   0, "", 0, 0];
 CONST stoppointdata inpos100    := [inpos,    TRUE,  [100, 100, 0, 2],   0,   0, "", 0, 0];
 CONST stoppointdata stoptime0_5 := [stoptime, FALSE, [  0,   0, 0, 0], 0.5,   0, "", 0, 0];
 CONST stoppointdata stoptime1_0 := [stoptime, FALSE, [  0,   0, 0, 0], 1.0,   0, "", 0, 0];
 CONST stoppointdata stoptime1_5 := [stoptime, FALSE, [  0,   0, 0, 0], 1.5,   0, "", 0, 0];
 CONST stoppointdata fllwtime0_5 := [fllwtime, TRUE,  [  0,   0, 0, 0],   0, 0.5, "", 0, 0];
 CONST stoppointdata fllwtime1_0 := [fllwtime, TRUE,  [  0,   0, 0, 0],   0, 1.0, "", 0, 0];
 CONST stoppointdata fllwtime1_5 := [fllwtime, TRUE,  [  0,   0, 0, 0],   0, 1.5, "", 0, 0];

 ! Declaration of zonedata
 CONST zonedata fine := [TRUE,    0,   0,   0,    0,   0,    0];
 CONST zonedata z0   := [FALSE, 0.3, 0.3, 0.3, 0.03, 0.3, 0.03];
 CONST zonedata z1   := [FALSE,   1,   1,   1,  0.1,   1,  0.1];
 CONST zonedata z5   := [FALSE,   5,   8,   8,  0.8,   8,  0.8];
 CONST zonedata z10  := [FALSE,  10,  15,  15,  1.5,  15,  1.5];
 CONST zonedata z15  := [FALSE,  15,  23,  23,  2.3,  23,  2.3];
 CONST zonedata z20  := [FALSE,  20,  30,  30,    3,  30,    3];
 CONST zonedata z30  := [FALSE,  30,  45,  45,  4.5,  45,  4.5];
 CONST zonedata z40  := [FALSE,  40,  60,  60,    6,  60,    6];
 CONST zonedata z50  := [FALSE,  50,  75,  75,  7.5,  75,  7.5];
 CONST zonedata z60  := [FALSE,  60,  90,  90,    9,  90,    9];
 CONST zonedata z80  := [FALSE,  80, 120, 120,   12, 120,   12];
 CONST zonedata z100 := [FALSE, 100, 150, 150,   15, 150,   15];
 CONST zonedata z150 := [FALSE, 150, 225, 225,   23, 225,   23];
 CONST zonedata z200 := [FALSE, 200, 300, 300,   30, 300,   30];

 ! Declaration of speeddata
 CONST speeddata v5    := [   5, 500, 5000, 1000];
 CONST speeddata v10   := [  10, 500, 5000, 1000];
 CONST speeddata v20   := [  20, 500, 5000, 1000];
 CONST speeddata v30   := [  30, 500, 5000, 1000];
 CONST speeddata v40   := [  40, 500, 5000, 1000];
 CONST speeddata v50   := [  50, 500, 5000, 1000];
 CONST speeddata v60   := [  60, 500, 5000, 1000];
 CONST speeddata v80   := [  80, 500, 5000, 1000];
 CONST speeddata v100  := [ 100, 500, 5000, 1000];
 CONST speeddata v150  := [ 150, 500, 5000, 1000];
 CONST speeddata v200  := [ 200, 500, 5000, 1000];
 CONST speeddata v300  := [ 300, 500, 5000, 1000];
 CONST speeddata v400  := [ 400, 500, 5000, 1000];
 CONST speeddata v500  := [ 500, 500, 5000, 1000];
 CONST speeddata v600  := [ 600, 500, 5000, 1000];
 CONST speeddata v800  := [ 800, 500, 5000, 1000];
 CONST speeddata v1000 := [1000, 500, 5000, 1000];
 CONST speeddata v1500 := [1500, 500, 5000, 1000];
 CONST speeddata v2000 := [2000, 500, 5000, 1000];
 CONST speeddata v2500 := [2500, 500, 5000, 1000];  
 CONST speeddata v3000 := [3000, 500, 5000, 1000];
 CONST speeddata v4000 := [4000, 500, 5000, 1000]; 
 CONST speeddata v5000 := [5000, 500, 5000, 1000];  
 CONST speeddata v6000 := [6000, 500, 5000, 1000]; 
 CONST speeddata v7000 := [7000, 500, 5000, 1000];
 VAR   speeddata vmax  := [5000, 500, 5000, 1000];  
  
 ! Instruction Open parameter Object
 CONST string diskhome := "HOME:";
 CONST string disktemp := "TEMP:";   
 CONST string flp1 := "flp1:";
 ! Only for old program from S4C system
 CONST string ram1disk := "HOME:";

 
 ! Constant pi
 CONST num pi := 3.1415926;
 
 ! Constant empty string
 ! (stEmpty hard coded in MMC, do not change the name)
 CONST string stEmpty:="";
   

 ! Event routine for RESET and START
 ! Setup default motion settings
 ! Do not translate or delete SYS_RESET
 PROC SYS_RESET()
  VAR wztemporary wz_clear := [0];
  VelSet 100, MaxRobSpeed();
  vmax.v_tcp := MaxRobSpeed();
  AccSet 100,100;
  PathAccLim FALSE, FALSE;
  WorldAccLim \Off;
  CirPathReori TRUE;
  IF SingAreaWrist() THEN
    SingArea\Wrist;
  ELSE
    SingArea\Off;
  ENDIF
  ConfJ \On;
  ConfL \On;
  LimConfL 30, 45, 90;
  GripLoad load0;
  PDispOff;
  EOffsOff;
  TuneReset;
  SoftDeact;
  PathResol 100;
  WZTempFree;
  SetAllDataVal "wztemporary" \Hidden, wz_clear;
  SpeedPrioDeact;
  SysInit1 \On \TuneValue:=100;
  ProbeReset;
  DataLogReset;
  SpyStop;
  DitherDeact;
 ENDPROC
 
 ! Event routine for POWER ON 
 ! Restore motion settings 
 ! Do not translate or delete SYS_POWERON
 PROC SYS_POWERON()
   PathResol C_MOTSET.pathresol;
 ENDPROC 
  
 ! Event routine for POWER ON
 ! Restore the IO status from the time for power fail
 ! Do not translate or delete RESTORE_IO
 PROC RESTORE_IO()
  PFIOResto;
 ENDPROC
      
ENDMODULE
