Application

The following commands can be transferred to the TcTouchLockCLI via parameters:

TcTouchLockCLI commands

Command

Function

-silent

Optional: the TcTouchLockCLI does not return any output.

-list

Lists all connected devices with name, ID and touch status.

-setID

Sets the entered ID. If only one device is connected, the entered ID is set automatically. If several devices are used, the desired device must be selected by touching the monitor.

-setFocus

Places the touch focus on the device specified with the ID. All other devices will be locked.

-unlockAll

Unlocks all devices.

-help/-?

Lists the functions of the TcTouchLockCLI.

Exit Codes

Meaning

Code

No error

0

Incorrect/no parameter input

1

Incorrect/no identification number

2

No device found

3

If all multi-touch panel devices are connected to the IPC, individual IDs can be assigned to the connected devices. The –setID command can be used to automatically set the ID of a connected device. If several devices are connected, you must touch the touch screen to be assigned after entering the command -setID.

You can now lock specific touch screens via TwinCAT or the command line application. A separate function block is available for use in the PLC for this purpose (see below).

In the command line application you can set the focus to an ID using the command -setFocus. Subsequently, input is only possible via the device that is in focus. If the –setFocus command is used to specify an unavailable ID, all connected touch screens are locked. With the command -unlockAll you can remove this focus.

FB_TcTouchLock_AquireFocus

Application 1:
FB_TcTouchLock_AquireFocus

You can alternatively request and release the focus on connected Panels with the function block FB_TcTouchLock_AcquireFocus. You must observe the following requirements:

If the focus is requested from a Panel when another Panel currently has the focus, the focus must first be released by this Panel. Once the release has taken place, the focus is automatically set to the device that is waiting for it.

The Panels accessed by the function block must be configured beforehand by the TcTouchLockCLI.exe command line application. You must assign a specific identification number to each device (see above).

VAR_INPUT

VAR_INPUT
    bEnable    : BOOL;
    sSetID     : STRING(32);
    tLEDTime   : TIME := 200;
END_VAR

bEnable: TRUE = request focus, FALSE = release focus

sSetID: ID of the device

tLEDTime: the output LED flashes at the specified interval (100 ms – 1 s) while the focus is requested

VAR_OUTPUT

VAR_OUTPUT
    bAcquired
  : BOOL := FALSE;(* Focus status information *)
    bLED
       : BOOL := FALSE;(* LED control output *)
    bBusy
      : BOOL;(* TRUE => function in progress *)
    bError:
    : BOOL;(* Error flag *)
    nErrID
     : UDINT;(* Error code *)
END_VAR

bAcquired: TRUE if the client has the focus; FALSE if the client loses the focus.

bLED: this output has the following meaning, depending on the mode:

Mode

Meaning

Constant TRUE

The Panel has the focus

Constant FALSE

The Panel does not have the focus

Toggeles

The Panel is waiting for the focus

bBusy: TRUE as long as the function block is active.

bError: TRUE if an ADS error occurs during transmission of the command. The bBusy output is reset beforehand.

nErrId: supplies the ADS error number or the command-specific error code (table) when the bError output is set.

Error Codes

Error description

0x0000

No error

0x0006

Target port not found

Example: control of touch focus via special key

For example, you can set the focus using a special key on the Panel. Since it must be possible to request the focus via the touch screen when the input is locked, an input option outside the lockable touchscreen must be provided. The special key is linked to the corresponding input variable in the PLC program through the TwinCAT System Manager. One FB_TcTouchLock_AquireFocus instance is created per Panel and configured with the Panel ID. After pressing the special key on a Panel, the function block R_TRIG detects the rising edge, and the PLC program tries to set the touch focus via the corresponding FB_TcTouchLock_AquireFocus instance. The function block can also control an output (e.g. an LED), which signals whether the touch focus has been set successfully or whether an attempt is still being made to obtain the focus. Pressing the special key again resets the touch focus, allowing the touch focus to be set to another Panel.

Application 2:
Panel example

For two Panels the PLC program looks like this:

PROGRAM MAIN
VAR
    button1 AT%IX0.0 : BOOL;
    button2 AT%IX0.1 : BOOL;

    led1 AT%QX0.0 : BOOL;
    led2 AT%QX0.1 : BOOL;

    fbPanel1 : FB_TcTouchLock_AcquireFocus := ( sSetID := 'A' );
    fbPanel2 : FB_TcTouchLock_AcquireFocus := ( sSetID := 'B' );

    trigger1 : R_TRIG;
    trigger2 : R_TRIG;
END_VAR
(* Panel 1 *)
trigger1( CLK := button1 );
IF trigger1.Q THEN
fbPanel1.bEnable := NOT fbPanel1.bEnable;
END_IF
fbPanel1(bLED=>LED1);

(* Panel 2 *)
trigger2( CLK := button2 );
IF trigger2.Q THEN
fbPanel2.bEnable := NOT fbPanel2.bEnable;
END_IF
fbPanel2(bLED=>LED2 );