Architecture: the applicationtemplate in detail – Lenze PLC Designer ApplicationTemplate (PLC Designer R3-x) User Manual
Page 100
Architecture: The ApplicationTemplate in detail
Consistent data transfer
100
Lenze · ApplicationTemplate · 1.3 EN - 04/2013
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Reserving/inhibiting data areas of the AppChannelData(ACD) structure
The ACD structure contains an L_EATP_CriticalSection block which, by means of the following
methods, ensures the data consistency of real time-critical data.
• If several blocks are required, further instances of the block can be use in the ACD structure.
1. Before the data area to be transferred can be consistently accessed, the Lock() method has to be
called in a task.
• The Lock() method returns a BOOL value if...
...another task has already called the method ("TRUE").
...no task has called the method yet ("FALSE").
[9-1]
Example: The Lock() method inhibits real time-critical data of the ACD structure.
2. After the last exclusive access to the data area, a task must call the Unlock() method to enable
the data area.
[9-2]
Example: The UnLock() method enables a reserved data area der ACD structure.
Program in machine module 1 ( TaskMidPriority = 4 ms):
Method
Function
Lock()
Reserve data area of the ACD structure.
Unlock()
Enable reserved data of the ACD structure.
LockState()
Query locked status of a data area.
Note!
Avoiding performance loss
Avoid inhibiting real time-critical data of the ACD structure by several MAPs within the
same machine module by the CriticalSection.
• Reserve an individual area for every MAP for real time-critical data in the ACD
structure, in order to avoid that the module application (MAP) of a low-priority task
(Task_Mid) slows down the MAP of a higher-priority task (Task_High).
Note!
A task may only use the data area (reading or writing) if the appChannelLock() method
has returned the TRUE value.
IF Lock() THEN
For i:=0 TO 2000 by 1 DO
rACDOwn.aCAMData[i] := aCAMData[i];
END_FOR
IF Lock() THEN
For i:=0 TO 2000 by 1 DO
rACDOwn.aCAMData[i] := aCAMData[i];
END_FOR
Unlock()