116
K
A
DAK
AMX Message Exchange Manager
#include "amx831cf.h /* AMX C Interface Header */
#define UMS 12 /* User message size */
extern AMXID dactid; /* Data acquisition task id */
extern AMXID dbtid; /* Data base update task id */
static AMXID msgexch; /* Message exchange id */
struct appmsg { /* Message structure */
short int msgtype; /* Application message type */
short int rsv; /* Reserved for alignment */
long data; /* Data sample */
void *dbp; /* Pointer to data base */
};
union msgu {
long maxmsg[UMS/sizeof(long)]; /* Maximum message size */
struct appmsg umsg; /* User message */
};
/* Timer Procedure */
void cdecl tmrproc(AMXID tmrid, void *unused)
{union msgu msgbuf; /* Message buffer */
:
Construct message in msgbuf.umsg
:
ajmxsnd(msgexch, 0, &msgbuf); /* Send message at priority 0 */
ajtrig(dactid); /* Trigger data acquisition task*/
}
void cdecl rrmsg(void) /* Restart Procedure */
{AMXID tmrid; /* Timer id */
if (ajtmcre(&tmrid, /* Create periodic 1 sec timer */
ajtmcnv(1000),
(void (*)())tmrproc,
NULL, "TIMR") == AEROK)
ajtmwr(tmrid, 1); /* Start timer immediately */
/* Create message exchange */
ajmxcre(&msgexch, 10, 0, 10, 10, "MSGX");
}