Port-based Macros

One of the most powerful capabilities available in the PB3A architecture is the port-based macro. This capability allows us to group modules and agents together and handle them as a single unit. Once created, a macro can be treated exactly the same as any other module

I'll tell you a little secret: you already know how to create them. That's because EVERY configuration file can be used as a macro in another configuration.

Start a new configuration in ModuleManager.In the module browser, go to the directory where you saved waveform.cfg (you'll probably have to go back all the way to the beginning and switch from the Network to the Local file system because at this point in time we can't yet save configurations via the AgentServer). You'll see a green module named waveform. That's the macro formed from waveform.cfg. Place two of them into the configuration. Double click one of them. It'll open up a separate window showing PBASquareWave and PBAWaveDisplay. Set PBASquareWave to produce a 1Hz wave. Save and close that window. Open the other and set it to produce an 5 Hz wave. Save and close that window. Execute the configuration. Two displays should open up showing each of the two waveforms.

Configuration with two macros

Note: You need to save the window detailing the internals of a macro for those changes to be updated to the main configuration.

Note: Placing a macro in a configuration puts a copy of that macro in the configuration. It can be changed without affecting the original configuration that produced that macro, and vice versa.

Now let's try doing some macros that have input and output ports. Start a new configuration in Module Manager. Place two PBASquareWave modules in the configuration. Edit their states so that one runs at 1Hz with a duty cycle of 0.5 and the other at 5Hz with a duty cycle of 0.8. Save the configuration as twowaves.cfg.

Tip: Holding down CTRL while placing modules allows you to place more than one module at a time.

Start a second configuration in Module Manager. Place the macro twowaves. Place two PBAWaveDisplay modules in the configuration as well. Connect each of the outputs of the macro to one of the PBAWaveDisplay modules. Execute the system, and two displays will pop up showing the waveforms.

Configuration with one
macro and two modules

These have been only trivial examples of what a user can do with port-based macros. Macros can be as simple or as complex as desired, and they can be nested as deeply as required. They provide the ability to compose software with increasingly powerful capabilities while maintaining the simple interface of all port-based agents.

Prev Next


Copyright 2000, Carnegie Mellon University
This page written by Jonathan Jackson

Last modified: Thu May 18 19:14:59 EDT 2000