Chare( chare_type )
type1 fieldname1;
type2 fieldname2;
. . /* declarations of the fields associated with
. . this chare */
. .
typeN fieldnameN;
Entries{ entry_name1, entry_name2, ..., entry_nameN };
Code( chare_type )
Entry( entry_name1, message_type )
C Code specific to this entry
EndEntry;
Entry( entry_name2, message_type )
C Code specific to this entry
EndEntry;
.
.
.
Entry( entry_nameN, message_type )
C Code specific to this entry
EndEntry;
EndChare;
chare_type: The name of the chare type to be defined. This name can then be
used to declare instances of the chare.
entry_name: The name used to identify an entry point of a chare.
message_type: The name of the type of message that can be received by an entry. Only one type of message can be received by any particular entry of a chare.
Note: Use 'chr' for referencing the chare within its own code and use 'msg' for
referencing the message received by an entry.
For example, the line 'chr->times = 3;' could be contained in one (or more) of
a particular chare's entries. This would set the times field of the chare equal
to 3. Likewise, the line 'chr->value = msg->count' would set the value field
of the chare equal to the count field of the received message.
Message( message_type )
type1 fieldname1;
type2 fieldname2;
. . /* declarations of the fields associated with
. . this message */
. .
typeN fieldnameN;
EndMessage;
message_type: The name of the message type to be defined.
CreateChare( chare_name, chare_type );
chare_name: The name of the chare instance to be created.
chare_type: The type of chare to create. Remember CreateChare is used to declare an instance of a chare. The actual chare type (chare class) is defined by the Chare...EndChare structure.
Note: The CreateChare macro causes a declaration, so it must occur at the beginning of any C code block.
CreateMsg( message_name, message_type );
message_name: The name of the message instance to be created.
chare_type: The type of message to create. Remember CreateMsg is used to declare an instance of a message. The actual message type (message class) is defined by the Message...EndMessage structure.
Note: The CreateMsg macro causes a declaration, so it must occur at the beginning of any C code block.
There are two Amulet macros used for sending a previously created message:
SendMsgNow and SendMsgLater. The SendMsgNow macro submits the given message to
be delivered as soon as possible. The SendMsgLater macro submits the message to
be delivered at a later time.
SendMsgNow( message_name, chare_name, entry, deadline_time );
SendMsgLater( message_name, chare_name, entry, begin_time, end_time );
message_name: The name of the message to send.
chare_name: The name of the chare the message is to be sent to.
entry: The entry of the specified chare that the message should be directed to.
deadline_time: The time the message must be sent by. This parameter must be of type timetyp.
begin_time: The earliest the message may be delivered. This parameter must be of type timetyp.
end_time: The latest the message may be delivered. This parameter must be of type timetyp.
If it is necessary to send a message not previously created, it is possible to create and send a message with one of two macros: SendNow and SendLater. The SendNow macro creates a message and submits it to be delivered as soon as possible. The SendLater macro also creates a message but submits it to be delivered at a later time.
SendNow( message_type, chare_name, entry, deadline_time )
C Code for setting message fields
EndSendNow;
SendLater( message_type, chare_name, entry, begin_time, end_time )
C Code for setting message fields
EndSendLater;
message_type: The type of message to create and send.
chare_name: The name of the chare the message is to be sent to.
entry: The entry of the specified chare that the message should be directed to.
deadline_time: The time the message must be sent by. This parameter must be of type timetyp.
begin_time: The earliest the message may be delivered. This parameter must be of type timetyp.
end_time: The latest the message may be delivered. This parameter must be of type timetyp.
Note: Use 'm' for referencing the message to be sent.
For example, the line 'm->total = 5;' could be contained in the C code
for setting the total field of the message that will be created and sent.
AmuletInit C Code for initializing the process EndAmuletInit;The AmuletInit block can be considered the main block of any Amulet program. Declaring instances of chares and messages, making assignments to basic chare and message fields, and sending the initial messages to start the program are all done here.