Mine Pump
Code Generation Project

For this project you are designing the controller for a mine pump1. The main function for this controller is to turn on the pump so that the water level in the mine is kept within safe bounds.There are also safety concerns that the controller must address.

System Description

This section lists the characteristics of the mine pump system you are controlling. Figure 1 shows a diagram of the system.

Figure 1. Mine Pump System modified from [1].

Pump Control System Requirements

This section specifies the functional requirements for your system:

  1. The system shall maintain the water in the sump between the high and low levels when the methane level in the mine is in normal range.
    1. When the high water level detector indicates a high water level and the methane sensor indicates normal methane levels in the mine, the system shall turn the pump on.
    2. When the low water level detector indicates a low water level, the system shall turn the pump off.
  2. The system shall turn the pump off if the pump is running and the methane sensor indicates a high methane level in the mine.
  3. The system shall prevent the pump from starting if the methane sensor indicates a high methane level in the mine.
  4. The system shall allow the operator to manually control the pump.
    1. The system shall allow the operator to manually turn the pump on when the low water level detector indicates a water level above the low level and the methane sensor indicates a normal methane level in the mine.
    2. The system shall allow the operator to manually turn the pump off if the high water level detector indicates a water level below the high level.
  5. The system shall initialize with the pump off.

Implementation Requirements

Your team will capture the behavior of this pump control system via a statechart created in Rhapsody. By the appropriate use of guards, events and actions you may be able to define the operation of this controller as only a single state. Note: this is not considered the best design choice.

After capturing the system behavior in a statechart your team will then use the Rhapsody code generation feature to create an executable version of the program in C++. The goal is to work entirely within the Rhapsody environment. This requires you to insert lines of application code for some functioning of the controller in appropriate places within the statechart.

You will also model, as a statechart, a test fixture which allows both manual and automatic generation of signals to the pump control system. Provide a way to change the mode of the program. You can assume that events can be used as the interface between the test fixture and the pump control system. In manual mode, the user will control your program with keyboard input. Each input has a defined letter as follows:

  1. M, m - the methane sensor indicates a high (M) or low (m) methane level.
  2. O, o - the operator wants to turn the pump on (O) or off (o).
  3. L, l - the low water level detector indicates a water level above (l) or below (L) the low water level mark.
  4. H, h - the high water level detector indicates a water level above (H) or below (h) the high water level mark.

In automatic mode, your test fixture will simulate water filling the sump pump at a rate that will fill the tank from empty to low in 5 seconds, from low to high in 10 seconds, and from high to overflowing in 5 seconds. The pump can drain a full tank in 5 seconds.

Your program will use standard output to show its operation. The program should print a message whenever it changes state internally or changes the pump's running status. It should also indicate receiving input from the sensor and operator. In automatic mode, you should output information about the water level.

In a real controller, you would need to have an input scanner that scanned the digital inputs at a periodic rate. This can be modeled as an orthogonal region. In this project you need to read input values from the keyboard to determine which event is the next event. Since there is no timing stated in the requirements you should be able to code the keyboard input within Rhapsody even if the orthogonal region is not implemented by the Rhapsody framework as a separate thread of execution.

Tutorials and Help Files

Work through this code generation tutorial. There is also information available in Rhapsody documents which you can access from the Help menu. The Rhapsody in C++ User Guide is a good starting place.

Documentation Requirements

For your documentation of this project you will submit a single Word file that holds, at a minimum, the following information: (This list is not necessarily in the best order for presentation in your document.)

  1. A short introductory section.
  2. Statechart for your control system with a textual description of the interesting aspects of it.
  3. Description of issues you had to address to get the code generation to work including any rework that you had to do to your statechart.
  4. Estimate of how much code you had to manually add within the statechart and/or outside of Rhapsody to get your pump control system to function.
  5. General comments and impressions of using Rhapsody and statecharts to model a project and create machine generated code. Highlight with actual code segments the positive and negative aspects in the generated code. Comment on the code for Reuseable and Flat statechart implementations.

This paper should be 5 to 10 pages in length.

Presentation Requirements

There will be no formal presentation for this project. On the day the project is due we will have a class discussion of the project. Several teams will be asked to discuss their model. Other teams will then be asked to run their implementation. Finally, some teams will be asked to discuss their assessment of the generated code. This will include highlighting actual code sections that you thought were particularly good or bad. The team order for this discussion will be random.

Submission

Submit a single zip file that contains your project documentation, a project directory containing your Rhapsody project. Be sure to include an executable file in the submisson. Name the Rhapsody component, Pump, and the configuration, Submission. You may build it for either Microsoft or Cygwin C++.   Place the zip file in the Code Generation dropbox in myCourses.

References

1. A. Burns and A. M. Lister, A Framework for Building Dependable Systems, Computer Journal, Vol. 34(2), pp. 173-181 (1991).


Revision: $Revision: 1.1 $ $Date: 2007-02-12 03:37:23 $