8 - 18 8 - 18
MELSEC-Q
8 MULTITASK PROCESSING
3) To write a message to the message port:
ZMESSAGE PUT <message port number>, <transmission data>, • • •
3)' To read a message from the message port:
ZMESSAGE GET <message port number>, <variable where the data read is stored>, • • •
• • • <timeout>
See 2) in (3) for the specification of <timeout>.
4) Close the message port to finish inputting/outputting the message.
ZMESSAGE CLOSE <message port number>
The closed message port can be opened again by the ZMESSAGE OPEN instruction.
5) Delete the message port when finishing using the message port.
ZMESSAGE KILL, <message port number>
Once the message port is deleted, the message port in the main memory is also deleted.
Therefore, it is necessary to define the message port in order to use the message
port specified by <message port number> again.
The deletion of a message port using the ZMESSAGE KILL
instruction should be performed in one of the programs
executed by multitasking.
(3) Execution order of instructions when using a message port
The following shows the execution order of instructions when programs are
exchanging messages and synchronizing their executions through message
ports:
1) The following occurs when program B reads a message after program A
writes the message.
A
A
B
A
B
B
Program B
Program A
1) ZMESSAGE to
ZMESSAGE OPEN to
Prepare and open the
message port.
2) ZMESSAGE PUT to
Write the message.
3) ZMESSAGE GET
Read the message.
ZMESSAGE OPEN to
Open the message
port.