Abilitare JavaScript per vedere questo sito.

Esempio

int esitoGv

U32 locInt

real locReal

struct structValori

    int nValori

    real valore[10]

end_struct

structValori raised

structValori somme

int GVInterf_int

int GVInterf_real

int GVInterf_raised

int GVInterf_sum

int nVal

string gvname

...

...

...

locInt = 3

locReal = 7.23

raised.nValori = 0

somme.nValori   = 0

...

...

...

gvname = "Global Integer 1"

IF (GV_EXIST(gvname))

    esitoGV = GV_LINK  (gvname,  sizeof(int), "", GVInterf_int, locInt)

ELSE

    esitoGV = GV_CREATE (gvname, "int",  sizeof(int),  "", 0x8, GVInterf_int, locInt)

ENDIF

SELECT (esitoGV)

    CASE 0      ; link connection done

        BREAK

    CASE 1      ; link done but the variable was locked, so we want to wait until we are able to read  ...

        WHILE (true)

            IF (GV_READ(GVInterf_int) = 0)

                BREAK   ; ok th e local copy ahs benn updated.

            ENDIF

        END_WHILE

        BREAK

    DEFAULT

        ALARM_SET (5000, 0, 1, esitoGV )

END_SELECT

gvname = "Global Real 1"        ; variabile persistente

IF (GV_EXIST(gvname))

    esitoGV = GV_LINK   (gvname,  sizeof(real),  "", GVInterf_real, locReal)

ELSE

    esitoGV = GV_CREATE (gvname, "real",  sizeof(real), "", 0x1, GVInterf_real, locReal)

ENDIF

SELECT (esitoGV)

    CASE 0      ; link connection done

        BREAK

    CASE 1      ; link done but the variable was locked, so we want to wait until we are able to read  ...

        WHILE (true)

            IF (GV_READ(GVInterf_real) = 0)

                BREAK   ; ok th e local copy has been updated.

            ENDIF

        END_WHILE

        BREAK

    DEFAULT

        ALARM_SET (5000, 0, 2, esitoGV )

END_SELECT

gvname = "Global structValori raised"    ; variabile persistente

IF (GV_EXIST(gvname))

    esitoGV = GV_LINK   (gvname,  sizeof(structValori), "", GVInterf_raised, raised)

ELSE

    esitoGV = GV_CREATE (gvname, "struct structValori RAISED", sizeof(structValori), "",  0x1, GVInterf_raised, raised)

ENDIF

SELECT (esitoGV)

    CASE 0      ; link connection done

        BREAK

    CASE 1      ; link done but the variable was locked, so we want to wait until we are able to read  ...

        WHILE (true)

            IF (GV_READ(GVInterf_raised) = 0)

                BREAK   ; ok th e local copy has been updated.

            ENDIF

        END_WHILE

        BREAK

    DEFAULT

        ALARM_SET (5000, 0, 3, esitoGV )

END_SELECT

gvname = "Global structValori sum"  ; variabile persistente

IF (GV_EXIST(gvname))

    esitoGV = GV_LINK   (gvname,  sizeof(structValori), "", GVInterf_sum, somme)

ELSE

    esitoGV = GV_CREATE (gvname, "struct structValori SUM", sizeof(structValori), "", 0x1, GVInterf_sum, somme)

ENDIF

SELECT (esitoGV)

    CASE 0      ; link connection done

        BREAK

    CASE 1      ; link done but the variable was locked, so we want to wait until we are able to read  ...

        WHILE (true)

            IF (GV_READ(GVInterf_sum) = 0)

                BREAK   ; ok th e local copy has been updated.

            ENDIF

        END_WHILE

        BREAK

    DEFAULT

        ALARM_SET (5000, 0, 3, esitoGV )

END_SELECT

    ; lock the access to the varaible to the other tasks

WHILE (NOT GV_LOCK(GVInterf_raised))

END_WHILE

    ; this structure is used to hold the power of the number hold in RR(23) ,  number of raise is specidied in RR(22)

    esitoGV = GV_READ (GVInterf_raised)      ; update the structure

    IF (esitoGV = 0)    

        raised.nValori = IN_RANGE (RR(22), 1.0, 10.0)     ; number of desired power  (1 up to ten)

        raised.valore[0] = RR(23)    

        FOR (nVal = 1 , nVal < raised.nValori, INC(nVAL))

            raised.valore[nVal] = raised.valore[nVal-1] * raised.valore[0];        ; compute new power

        ENDFOR

                ; update the structure

        esitoGV = GV_WRITE (GVInterf_raised)     ; update the structure

        IF (esitoGV < 0)    

            ALARM_SET (5000, 0, 4, esitoGV )

        ENDIF

    ENDIF   ; IF (esitoGV > 0)  

GV_UNLOCK (GVInterf_raised)

; the same structure is used in different way,   the nValori is used to specify which element we have to use

esitoGV = GV_PARTIAL_READ (GVInterf_sum, 0, sizeof(somme.nValori))      ; update the structure element nValori

IF (esitoGV = 0)

    if (RANGE(somme.nValori , 0, 10-1))

        nVal = somme.nValori

        somme.valore[nVal] = RR (23) + nVal

        esitoGV = GV_WRITE_PARTIAL (GVInterf_sum, sizeof(somme.nValori)+ sizeof(real)*nVal, sizeof(real))     ; update only the desired informatiion

        IF (esitoGV < 0)    

            ALARM_SET (5000, 0, 5, esitoGV )

        ENDIF

        somme.nValori = -1;

        esitoGV = GV_WRITE_PARTIAL (GVInterf_sum, 0, sizeof(somme.nValori))                                   ; reset update only one information

        IF (esitoGV < 0)    

            ALARM_SET (5000, 0, 5, esitoGV )

        ENDIF

    ENDIF

ENDIF

...

...

 

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Contents: ALT+c
Search: ALT+s
Exit Menu/Up: ESC