23.11.2012 Views

2 Visual Components Manuals

2 Visual Components Manuals

2 Visual Components Manuals

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

accordingly in the cyclic program.<br />

4.10.7.1.3.2 3.2 ANSI C<br />

4.10.7.1.3.2.1 Source code<br />

#include<br />

#include #include "visapi.h" _LOCAL UDINT VC_HANDLE; _LOCAL UINT<br />

status; _LOCAL USINT step; _LOCAL USINT erase; _LOCAL USINT mtxKeys[48]; _LOCAL UDINT mtxSize;<br />

_INIT void SetupKeyMatrix(void) { step = 0; erase = 1; } _CYCLIC void RunKeyMatrix(void) { int i; /*<br />

get handle for project "vga1" */ if (step == 0) { VC_HANDLE = VA_Setup(1, "vga1"); if (VC_HANDLE)<br />

step = 1; } /* try to get the key matrix */ if (step == 1) { status = VA_GetKeyMatrix(1, VC_HANDLE,<br />

(UDINT) &mtxKeys[0], sizeof(mtxKeys) / sizeof(mtxKeys[0]), (UDINT) &mtxSize); if (status) { /* cannot<br />

read the matrix */ erase = 1; /* handle project overload, handle becomes invalid */ if (status ==<br />

100) step = 0; } } if (erase == 1) { /* reset all key information to unpressed on error */ for (i =<br />

0; i < (sizeof(mtxKeys) /sizeof(mtxKeys[0])); i++) { mtxKeys[i] = 0; } erase = 0; } /* your key<br />

handling code goes here */ }<br />

4.10.7.1.3.3 3.3 Example Description<br />

In the Init subprogram, the 'init' and 'erase' variables are both preset so that a connection is established first with<br />

the respective project and the key matrix is started at 0. In this way, no key strokes can remain in the matrix if<br />

the visualization project has not yet been started.<br />

In the cyclic program, a connection is established with the current <strong>Visual</strong> <strong>Components</strong> project using the<br />

VA_Setup function. This is valid until a hardware is restarted or the visualization is overloaded.<br />

If successful, the key matrix is read with VA_GetKeyMatrix in the next code section. The size of the connected<br />

key matrix is specified here. The actual number of keys which were copied is returned in the mtxSize parameter.<br />

More keys than actually exist on the panel can also be requested. When touch keys are used, the number of<br />

keys changes depending on the currently displayed picture. The user should ignore keys which do not exist in<br />

the matrix or delete them. This is not included in the examples.<br />

If the error code determines that the handle has become invalid in the project, a new handle is requested and<br />

the matrix is deleted.<br />

The last part of the cyclic program deletes the key matrix at the beginning and if an error occurs.<br />

4.10.7.1.4 4. Adding the Application Logic<br />

The key matrix is ready to be used by the application when the application logic is added. The corresponding<br />

links can be placed in the the cyclic program right after the example code.<br />

4.10.7.2 Key Matrix from <strong>Visual</strong> <strong>Components</strong> Version 2.0<br />

For compatibility reasons, the key matrix from <strong>Visual</strong> <strong>Components</strong> Version 2.0 is still supported. However, using<br />

the new key matrix function is recommended. Future versions of <strong>Visual</strong> <strong>Components</strong> may not support the old<br />

key matrix.<br />

In order to replace the old key matrix with the new one, the old one must first be deactivated using the <strong>Visual</strong><br />

<strong>Components</strong> global options. The new function is then used to acquire the new key matrix.<br />

4.11 Alarm System<br />

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

Alarms are used to record certain conditions and occurrences in a machine. These can include passing a<br />

threshold limit, an absence of a resource, unauthorized use of a component, or any other machine specific<br />

situation.<br />

<strong>Visual</strong> <strong>Components</strong> provides an integrated alarm system for managing and visualizing these alarms. The alarm<br />

396 4.10.7.1 Using the Key Matrix

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

Saved successfully!

Ooh no, something went wrong!