Declaration:
void WaitSendMessage(int id, unsigned int int_data, unsigned long long_data);
Description
The WaitSendMessage and WaitGetMessage functions provide a mechanism for message exchange between two copies of the ChipProg program (or other Phyton products) running simultaneously. These functions are used mostly for simulators and allow simulation of multi-processor systems that exchange data with each other.
To simulate, say, a two programmers system, you should launch two copies ChipProg and set up the exchange of data between them. You can start the second copy of ChipProg by copying the UprogNT2.EXE file to a file with another name and then starting it.
The WaitSendMessage function "sends a message" to another copy of ChipProg and waits until the message is "delivered", i.e. the receiver copy of ChipProg calls the WaitGetMessage function. If the receiver has already called WaitGetMessage and is waiting for an incoming message, the WaitSendMessage function returns immediately, otherwise it will return, when a period of model time is passed. The model time flows, when the simulated program runs.
When calling WaitSendMessage and WaitGetMessage, you supply the id parameter that identifies the message. The message will be delivered to the copy of ChipProg that is waiting for message with the same id.
The int_data and long_data parameters are the user data. You may set these parameters to any values you wish. When the receiver's WaitGetMessage returns the control, the transmitter's int_data value is copied to the receiver's LastMessageInt built-in variable and long_data is copied to LastMessageLong.
Note that ChipProg uses its own internal means for message exchange, not the message mechanism of Windows.
Example
#define SecondCopyMsg 0
#define InitExchange 0
#define InitExchangeOk 0
Run(); // start model time
WaitSendMessage(SecondCopyMsg, InitExchange, 0);
WaitGetMessage(SecondCopyMsg);
if (LastMessageInt != InitExchangeOk)
{
printf("Exchange failed");
return;
}
|