
Overview of the DP Base Interface
DP Base Programming Interface for CP 5613/CP 5614
62
C79000-G8976-C108-01
3.9.3 Typical Sequences with Semaphores on the slave Module
Definition
The polling mode described in Section 3.7.3 can also be replaced by operation with
semaphores. The initialization of this mode, the elements of continuous operation
and canceling the mode are described below.
Initializing the Semaphore
Before it is used, the semaphore must be created as follows:
Step Action Meaning
1 Initialize a semaphore for
asynchronous jobs
(function
DP_init_sema_object)
The DP Base Lib provides a
semaphore for all asynchronous jobs
(type DP_OBJECT_TYPE_ASYNC).
Using Semaphores for the Slave Module
Step Action Meaning
1 Wait for the semaphore
(for example,
WaitForMultipleObjects)
The user program or the thread waits
until an event occurs.
"WaitForMultipleObjects" is a Windows
32-bit API function.
2 DPS_get_ind Fetch arrived indications
3a If DPS_CHK_PRM:
DPS_set_resp
If a new parameter assignment has
arrived:
Check user parameter data and
acknowledge positively or negatively
3b If DPS_CHK_CFG:
DPS_set_resp
If a new configuration has arrived:
Check configuration data and
acknowledge positively or negatively
4 Go to Step 1.
Note
After positive confirmation of configuration data, the input data in the process
ima
e table of the slave module must be written at least once
initialization
, before
the slave module can change to data exchange.
Komentarze do niniejszej Instrukcji