Implementing Custom Applications

27 April 2015

This chapter outlines the reasons one might need a custom application of the PLEXIL Executive, how to implement such an application, and considerations for the design of that application.

Overview

The PLEXIL Executive is a general purpose plan execution engine, with provisions for loading user-specified interfacing code at startup time. But some applications have requirements which the PLEXIL Executive cannot meet. Such requirements may include:

  • A need to launch the Exec as a subroutine of a larger program;

  • Lack of run-time facilities for loading interface shared libraries;

  • A need to “lock down” the application’s interface code for configuration control purposes;

  • Operation as a single thread (process) in a real-time operating system environment.

Anatomy of the universalExec Application

The universalExec main program simply does the following:

  1. Parse command line arguments.

  2. Construct the framework objects.

  3. Get interface configuration data.

  4. Construct interfaces.

  5. Initialize interfaces.

  6. (optional) Load the specified libraries.

  7. (optional) Load the specified plan.

  8. Start the interfaces.

  9. Start the top-level loop thread.

  10. Wait for execution to finish.

  11. Destroy interface objects.

  12. Destroy framework objects.

  13. Exit.

Embedded PLEXIL executive applications will need to perform many of these same steps.

PLEXIL Application Framework Lifecycle Model

For an overview of the lifecycle states, please see The Lifecycle Model.

Interface Setup

The PLEXIL application is responsible for setting up the AdapterConfiguration instance to route interface requests to the appropriate objects. AdapterConfiguration has the capability to read user-supplied XML, load the appropriate libraries, and construct the interface objects. However, if required AdapterConfiguration can simply route to interface objects explicitly constructed by the application, in ways explicitly directed by the application.

Interface Configuration via XML

The AdapterConfiguration member function AdapterConfiguration::constructInterfaces(pugi::xml_node const) parses configuration XML and constructs the interface adapters and exec listeners specified in it. The application developer only needs to open and read the file, e.g. via pugi::xml_document::load() or pugi::xml_document::load_file(), extract the top level element from the XML document via pugi::xml_document::document_element(), and call AdapterConfiguration::constructInterfaces() on the element.

Hard-Coding Interface Configuration

to be supplied

The Top-Level Loop

to be supplied

Multi-Threaded versus Single-Threaded Operation

The PLEXIL Application Framework can run as a multi-threaded application, or as a single thread.

more to be supplied