MAE App Architecture

Index Home MAE > MAE Architecture > MAE App Architecture

Applications

The main() File

Use your primary file that would typically contain main() to include this basic MAE code (changing usergw to your daemon's name; changing display to a different second channel for your daemon):

#include <MAEDaemon.h >

MAEDaemon usergw("usergw", "display");

/** Initialize the app.

 * At this point, messages can be sent and the database is available, but

 * the app is not considered ready.

 * @param argc - # of command line arguments

 * @param argv - the command line arguments

 */

void MAE::init(int argc, char ** argv)

{

   // Your initialization code here

}

/** This is the core functionality of your app.  If you app just listens for and

 * responds to events, then you can explicity call task.process() or do nothing.

 */

void MAE::main()

{

   /* wait for events */

//     task.process();

}

void MAE::quit (int rc, const string & msg)

/** This app is going down, whether initiated by the OS or MAE environment.

 * @param rc - the program's exit code (0 means normal exit, 1+ means err exit)

 * @param msg - an explanation why the app is shutting down

 */

{

   if (debug_on)

       fprintf (dbgf, "%s shutting down at %d\n", task.getName().c_str(), (int)time(0));

   signal (SIGALRM, SIG_IGN);  /* turn off alarms */

   if (debug_on)

       fprintf (dbgf, "%s exit at %d\n", task.getName().c_str(), (int)time(0));

   if (rc == 0)

       task.done("Done.");

   else

       task.failed(msg);

   exit (rc);

}

The .mreg File

Create a channel.mreg file for each message channel that your application uses. See genmae.

This file is used to create the msgChannel.cpp file, any ChannelAPI.h and ChannelAPI.cpp file, and wiki documentation of application events.

The msg''Channel''.cpp File

This file is generated from the .mreg file using

maegen channel.mreg -msg msgChannel.cpp

The mgmt''Channel''.cpp File

This file is used to handle supervisor calls to manage your application.

*.ui Files

If your application conditionally renders sections of the UI, you may create a .ui file for each rendered section (see UserDevice::record()).

Convert the .ui file into an HTML record using:

genformcode html recordname.ui /usr/mae/html/record/recordname.html

If there any any user controls in the record (e.g. buttons, text response boxes, etc.), see genformcode to encode them to generate events for your application. For each .ui file, you'll need a line like

#process "filename.ui"

in your .mreg file.

Starting the Applications

Applications are started along with the daemons.

Developing a New Application

See Developing a New App.