****************************************
*	 Prozeßnummer = 1
*	 Delay = 1000
*	 Eventsource = 0
*	 Number of Loops = 0
*	 Priorität = 0
*	 Version = 1
*	 FastStop = 0
*	 AdbasicVersion = 4000001
*	 ATSRAM = 0
*	 OPT_LEVEL = 1
*	 SAVECOMPIL = 0
****************************************
#INCLUDE E:\DOCOMETRE2\Fonctions\Inf\DOCOLIB.INC

#DEFINE temps fpar_1

DIM FEG as INTEGER
DIM INDEX as INTEGER

REM ******** Dynamique Entrees analogiques
#DEFINE Analog_In_Max 10.0
#DEFINE Analog_In_Min -10.0

REM ******** Entree analogique : load
DIM load AS FLOAT
DIM Acquisition_load AS LONG
DIM Nouveau_load AS LONG

REM ******** Entree analogique : grip
DIM grip AS FLOAT
DIM Acquisition_grip AS LONG
DIM Nouveau_grip AS LONG

REM ******** Entree analogique : acc
DIM acc AS FLOAT
DIM Acquisition_acc AS LONG
DIM Nouveau_acc AS LONG

REM ******** Canal interne (scalaire) : curve
DIM curve AS FLOAT
DIM Acquisition_curve AS LONG
DIM Nouveau_curve AS LONG
REM ******** Canal interne (scalaire) : cursor
DIM cursor AS FLOAT
DIM Acquisition_cursor AS LONG
DIM Nouveau_cursor AS LONG
REM ******** Canal interne (scalaire) : curveOut
DIM curveOut AS FLOAT
DIM Acquisition_curveOut AS LONG
DIM Nouveau_curveOut AS LONG
REM ******** Canal interne (scalaire) : curve2
DIM curve2 AS FLOAT
DIM Acquisition_curve2 AS LONG
DIM Nouveau_curve2 AS LONG
REM ******** Canal interne (scalaire) : s
DIM s AS FLOAT
DIM Acquisition_s AS LONG
DIM Nouveau_s AS LONG
REM ******** Canal interne (scalaire) : q
DIM q AS LONG
DIM Acquisition_q AS LONG
DIM Nouveau_q AS LONG
REM ******** Canal interne (scalaire) : p
DIM p AS LONG
DIM Acquisition_p AS LONG
DIM Nouveau_p AS LONG
REM ******** Canal interne (scalaire) : l
DIM l AS LONG
DIM Acquisition_l AS LONG
DIM Nouveau_l AS LONG
REM ******** Canal interne (scalaire) : i
DIM i AS LONG
DIM Acquisition_i AS LONG
DIM Nouveau_i AS LONG
REM ******** Canal interne (tableau) : tab
DIM tab[200] AS FLOAT
DIM Acquisition_tab AS LONG
DIM Nouveau_tab AS LONG

REM ******** Variables pour génération de : curve 'Utilisé par G:\TrackingDelay\delay1.dat
#DEFINE curve_tab DATA_4 'Utilisé par G:\TrackingDelay\delay1.dat
DIM curve_tab[1000] AS FLOAT AS FIFO 'Utilisé par G:\TrackingDelay\delay1.dat
DIM Transfert_curve AS LONG 'Utilisé par G:\TrackingDelay\delay1.dat

REM ******** Variables pour transfert de : load 'Utilisé par Transfert
#DEFINE load_TAB DATA_1 'Utilisé par Transfert
DIM load_TAB[1000] AS FLOAT AS FIFO 'Utilisé par Transfert
DIM TRANSFERT_load AS LONG 'Utilisé par Transfert
REM ******** Variables pour transfert de : grip 'Utilisé par Transfert
#DEFINE grip_TAB DATA_2 'Utilisé par Transfert
DIM grip_TAB[1000] AS FLOAT AS FIFO 'Utilisé par Transfert
DIM TRANSFERT_grip AS LONG 'Utilisé par Transfert
REM ******** Variables pour transfert de : acc 'Utilisé par Transfert
#DEFINE acc_TAB DATA_3 'Utilisé par Transfert
DIM acc_TAB[1000] AS FLOAT AS FIFO 'Utilisé par Transfert
DIM TRANSFERT_acc AS LONG 'Utilisé par Transfert
REM ******** Variables pour transfert de : cursor 'Utilisé par Transfert
#DEFINE cursor_TAB DATA_5 'Utilisé par Transfert
DIM cursor_TAB[1000] AS FLOAT AS FIFO 'Utilisé par Transfert
DIM TRANSFERT_cursor AS LONG 'Utilisé par Transfert
REM ******** Variables pour transfert de : curveOut 'Utilisé par Transfert
#DEFINE curveOut_TAB DATA_6 'Utilisé par Transfert
DIM curveOut_TAB[1000] AS FLOAT AS FIFO 'Utilisé par Transfert
DIM TRANSFERT_curveOut AS LONG 'Utilisé par Transfert

DIM TERMINER_SEQUENCE_TYPE AS LONG

#INCLUDE E:\DOCOMETRE2\Fonctions\Inf\CALLANINGold.INC

LOWINIT :
FEG = 1000
GLOBALDELAY = 10^9/(FEG * 25)
INDEX = 0

Acquisition_load = 0 '******** init acquisition load
Acquisition_grip = 0 '******** init acquisition grip
Acquisition_acc = 0 '******** init acquisition acc

Acquisition_curve = 0 '******** init acquisition curve
Acquisition_cursor = 0 '******** init acquisition cursor
Acquisition_curveOut = 0 '******** init acquisition curveOut
Acquisition_curve2 = 0 '******** init acquisition curve2
Acquisition_s = 0 '******** init acquisition s
Acquisition_q = 0 '******** init acquisition q
Acquisition_p = 0 '******** init acquisition p
Acquisition_l = 0 '******** init acquisition l
Acquisition_i = 0 '******** init acquisition i
Acquisition_tab = 0 '******** init acquisition tab


q=400
p=90000
Transfert_curve = 1

TRANSFERT_load = 1
FIFO_CLEAR(1)
TRANSFERT_grip = 1
FIFO_CLEAR(2)
TRANSFERT_acc = 1
FIFO_CLEAR(3)
TRANSFERT_cursor = 1
FIFO_CLEAR(5)
TRANSFERT_curveOut = 1
FIFO_CLEAR(6)

TERMINER_SEQUENCE_TYPE = 0

EVENT : 
temps = INDEX/FEG

Nouveau_load = 0
IF (INDEX = Acquisition_load) THEN
   load = Call_AnIn(3,1,0.7143,1.6811,0,2)
   Acquisition_load = Acquisition_load + 1
   Nouveau_load = 1
ENDIF

Nouveau_grip = 0
IF (INDEX = Acquisition_grip) THEN
   grip = Call_AnIn(5,1,-0.0249,-0.5403,0,2)
   Acquisition_grip = Acquisition_grip + 1
   Nouveau_grip = 1
ENDIF

Nouveau_acc = 0
IF (INDEX = Acquisition_acc) THEN
   acc = Call_AnIn(6,1,0.136,3.9727,0,1)
   Acquisition_acc = Acquisition_acc + 1
   Nouveau_acc = 1
ENDIF


Nouveau_curve = 0
IF (INDEX = Acquisition_curve) THEN
   Acquisition_curve = Acquisition_curve + 1
   Nouveau_curve = 1
ENDIF

Nouveau_cursor = 0
IF (INDEX = Acquisition_cursor) THEN
   Acquisition_cursor = Acquisition_cursor + 1
   Nouveau_cursor = 1
ENDIF

Nouveau_curveOut = 0
IF (INDEX = Acquisition_curveOut) THEN
   Acquisition_curveOut = Acquisition_curveOut + 1
   Nouveau_curveOut = 1
ENDIF

Nouveau_curve2 = 0
IF (INDEX = Acquisition_curve2) THEN
   Acquisition_curve2 = Acquisition_curve2 + 1
   Nouveau_curve2 = 1
ENDIF

Nouveau_s = 0
IF (INDEX = Acquisition_s) THEN
   Acquisition_s = Acquisition_s + 1
   Nouveau_s = 1
ENDIF

Nouveau_q = 0
IF (INDEX = Acquisition_q) THEN
   Acquisition_q = Acquisition_q + 1
   Nouveau_q = 1
ENDIF

Nouveau_p = 0
IF (INDEX = Acquisition_p) THEN
   Acquisition_p = Acquisition_p + 1
   Nouveau_p = 1
ENDIF

Nouveau_l = 0
IF (INDEX = Acquisition_l) THEN
   Acquisition_l = Acquisition_l + 1
   Nouveau_l = 1
ENDIF

Nouveau_i = 0
IF (INDEX = Acquisition_i) THEN
   Acquisition_i = Acquisition_i + 1
   Nouveau_i = 1
ENDIF

Nouveau_tab = 0
IF (INDEX = Acquisition_tab) THEN
   Acquisition_tab = Acquisition_tab + 1
   Nouveau_tab = 1
ENDIF


FOR i = 1 TO (q-1)
   tab[q+1-i]=tab[q-i]
NEXT i


tab[1]=load


IF (temps<=(p/FEG)) THEN
   l=trunc(q/p*index) + 1
   s=tab[l]
ENDIF

IF (temps>=(p/FEG)) THEN
   l=q+1
   s=tab[q]
ENDIF


REM ******** Début recupération données du PC (Stimuli)
IF (Transfert_curve = 1) THEN
   Transfert_curve = 0
   IF (FIFO_FULL(4) = 0) THEN
      PAR_4 = PAR_4 + 1
      FIFO_CLEAR(4)
   ELSE
      curve = curve_tab
   ENDIF
ENDIF
INC(Transfert_curve)
REM ******** Fin recupération données du PC (Stimuli)

curve2=curve*2
curveOut=curve2+6
cursor=s



REM ******** Début transfert données vers PC
IF (TRANSFERT_load = 1) THEN
   TRANSFERT_load = 0
   IF (FIFO_EMPTY(1) = 0) THEN
      PAR_1 = PAR_1 + 1
      FIFO_CLEAR(1)
   ENDIF
   load_TAB =load
ENDIF
INC(TRANSFERT_load)
IF (TRANSFERT_grip = 1) THEN
   TRANSFERT_grip = 0
   IF (FIFO_EMPTY(2) = 0) THEN
      PAR_2 = PAR_2 + 1
      FIFO_CLEAR(2)
   ENDIF
   grip_TAB =grip
ENDIF
INC(TRANSFERT_grip)
IF (TRANSFERT_acc = 1) THEN
   TRANSFERT_acc = 0
   IF (FIFO_EMPTY(3) = 0) THEN
      PAR_3 = PAR_3 + 1
      FIFO_CLEAR(3)
   ENDIF
   acc_TAB =acc
ENDIF
INC(TRANSFERT_acc)
IF (TRANSFERT_cursor = 1) THEN
   TRANSFERT_cursor = 0
   IF (FIFO_EMPTY(5) = 0) THEN
      PAR_5 = PAR_5 + 1
      FIFO_CLEAR(5)
   ENDIF
   cursor_TAB =cursor
ENDIF
INC(TRANSFERT_cursor)
IF (TRANSFERT_curveOut = 1) THEN
   TRANSFERT_curveOut = 0
   IF (FIFO_EMPTY(6) = 0) THEN
      PAR_6 = PAR_6 + 1
      FIFO_CLEAR(6)
   ENDIF
   curveOut_TAB =curveOut
ENDIF
INC(TRANSFERT_curveOut)
REM ******** Fin transfert données vers PC

IF (temps >= 90) THEN
   TERMINER_SEQUENCE_TYPE = 1'END
ENDIF



IF (TERMINER_SEQUENCE_TYPE=1) THEN
    END
ENDIF

INC(index)

FINISH :

