State Based
Abstraction
State functionality is provided within each of the three
computations: Inactive, Active, and Paused. States will remain active until
state data indicates that they should relinquish control to facilitate
the state transition. Each state component implements only state functionality.
State determination processing is performed by the State Manager component.
Both the Inactive & Paused components contain no processing. The Active component constantly calculates a throttle setting based upon current settings. The formula used to calculate the throttle setting is the same as in the Procedure Call system.
Implementation
Three components provide the functionality
for the Cruise Control system: Inactive, Active, and Paused. They are invoked
via a local procedure call by the State Manager component. Each component
remains in a loop until the system state is modified. The determination
of system state is the responsibility of the State Manager component. Bridge
constructs an alarm mechanism that periodically invokes the State Manager
function. The State Manager function reads the input streams, updates the
appropriate shared data values, and then determines the current proper
state for the system. The State Manager returns control to which ever state
component was active when the alarm interrupt occurred. If the state has
changed during am alarm interrupt, the active procedure returns control
to the state manager, and the state manager calls the appropriate procedure
based on the new state.