next up previous
Next: ASSI assigns values to Up: INSTRUCTIONS Previous: INSTRUCTIONS

ASSEMBLE assembles messages in a representative message

Syntax:

    ASSEMBLE( | ELIM | FIRST | NEW |, |<integer value> | ALL|, |<logic expression>
              | EQUFIELD(<field>) | ) <associated instruction>;
The ASSEMBLE instruction is used to join a set of messages that came to a node, maybe at different times, and to represent the set by only one message, named representant. The representant may be the first assembled or a new message. Represented messages may be deleted or maintained in a list for further disassembling. The associated instruction must contain a SENDTO instruction to dispose of the representant.
The instruction is suited to simulate loading and transportation of things, using the representant as the transporter.

ASSEMBLE can be used in a node with an EL that has the ability to send messages (nodes of G, L, D, and general type with EL).

When this instruction is executed, the EL is scanned from the beginning. Each message (comparing message) is compared with those (compared messages) that follow it. The first comparing message is the first one in the EL. The values of the fields of the comparing message are in the field variables. Those of the compared message are put in the O_<variables>. The comparison consists in the evaluation of the <logic expression> that may include field variables of the comparing messages, O_<variables> of the compared message, and any other type of variables and constants. If the expression is TRUE both, the comparing and compared messages, are candidates to be assembled. When all messages are compared, the second message in the EL is taken as the new comparing message, which is compared with those that follow it. The process is repeated so that all the possible comparisons are made. If at any point of the process a number of candidates reach the value expressed by <integer value>, the assemble is successful. Then, the assembled messages are taken out of the list and the <associated instruction> is executed. The whole process is then repeated to see if another successful assemble group of the required size is possible with the remaining messages.
If the parameter ALL is used, there is not limit for the assembled set.
If the <logical expression> is reduced to the constant TRUE, the messages are unconditionally assembled up to the specified number (or all the messages if ALL is used).
If there is not successful assemble at all, nothing is done and the <associated instruction> is not executed.
If the function EQUFIELD(<field>) is used instead of the <logical condition>, the messages, which have the same values on that field, are assembled.
In all cases, it is assumed that all the messages in the EL have the fields that are used by the assembling conditions.
Which message is the representant and the fate of the assembled messages depends on the first parameter:

The <associated instruction>, executed for each successful assemble, may have instructions to change the fields of the representant (assigning values to field variables) and must have a SENDTO instruction to dispose of the representant. Note that this <associated instruction> may change the values of variables in the <logical condition> and in the <integer value> so changing the assemble conditions for the next group or for a new execution of the ASSEMBLE instruction. Assembled messages cannot be changed. If there was some successful assemble the variable SYNC is put to TRUE, otherwise it is put to FALSE.
See the instruction SYNCHRONIZE (6.26).

Examples:

  1.     Unite_Parts :: ASSEMBLE(ELIM, 3, EQUFIELD(Typed))
                       BEGIN Status := Finished, SENDTO(Paint) END;

    Groups of three messages with equal values in the field Typed are sought for. When a group is found, the first message is marked as Finished in its field Status and sent to the EL of the node Paint. The other two messages of the group are deleted. The node Unite_Parts is of the common type.

  2.     FormGroups (G) :: ASSEMBLE(FIRST, N,(Age > 10) AND (O_Age > 10))
                          BEGIN Leader := TRUE; SENDTO(Tour) END;
                          IF NOT SYNC AND (N > 2) THEN N := N - 1;
    The process attempts to form groups of size N (whose value was defined elsewhere) of messages with the value of the field Age > 10. When a group is found, the first one is marked putting to TRUE its field Leader and sent to the node Tour, keeping a point to the assembled messages. All the possible groups of this size are formed by the ASSEMBLE instruction. When the instruction is finished, as the node is of G type, the process is repeated if the EL is not empty starting again for the first message of the EL. When an attempt to form groups is not successful, the variable SYNC is put to FALSE by the ASSEMBLE instruction and the size of the sought group is reduced by one. The process is repeated until groups of size two are sought for.

next up previous
Next: ASSI assigns values to Up: INSTRUCTIONS Previous: INSTRUCTIONS

domingo c
Mon Mar 20 17:36:19 PST 2000