23.11.2012 Views

2 Visual Components Manuals

2 Visual Components Manuals

2 Visual Components Manuals

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Introduction to <strong>Visual</strong> <strong>Components</strong> 2.3<br />

4.10.7.1.3 3. Creating the User Task for Key Matrix Operation<br />

The task must be created in the task class where key matrix handling also takes place. It is easiest to have key<br />

matrix acquisition retrieval and evaluation in the same task. In this way, the logic in the application always works<br />

with the most current key data and the highest possible performance can be achieved. 50 milliseconds is a<br />

recommendable task cycle time for key matrix operation.<br />

The following examples illustrate how such a task could look in the Automation Basic and ANSI C programming<br />

languages. These examples can be adapted to specific application needs.<br />

4.10.7.1.3.1 3.1 Automation Basic<br />

4.10.7.1.3.1.1 Init subprogram<br />

(* init program *)<br />

step = 0<br />

erase = 1<br />

4.10.7.1.3.1.2 Cyclic program<br />

(* cyclic program *)<br />

(* get handle for project "vga1" *)<br />

IF step = 0 THEN<br />

VC_HANDLE := VA_Setup(1, "vga1")<br />

IF VC_HANDLE 0 THEN<br />

step := 1<br />

ENDIF<br />

ENDIF<br />

(* try to read the current key matrix *)<br />

IF step = 1 THEN<br />

status := VA_GetKeyMatrix(1, VC_HANDLE, ADR(mtxKeys), 48, ADR(mtxSize))<br />

IF status 0 THEN<br />

(* could not read matrix *)<br />

erase = 1<br />

(* handle project overload, handle becomes invalid *)<br />

IF status = 100 THEN<br />

step := 0<br />

ENDIF<br />

ENDIF<br />

ENDIF<br />

(* erase the key matrix in case of error *)<br />

IF erase = 1 THEN<br />

LOOP i := 0 TO 47 DO<br />

mtxKeys[i] = 0<br />

ENDLOOP<br />

erase := 0<br />

ENDIF<br />

(* your key handling code goes here *)<br />

4.10.7.1.3.1.3 Declaration<br />

An array of USINT variables must be created using an appropriate length for the key matrix stored in the<br />

'mtxKeys' variable. If another length should be used, the VA_GetKeyMatrix function call must be adjusted<br />

4.10.7.1 Using the Key Matrix 395

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!