Embedded Real Time Systems
A Cardioverter/Defibrillator Simulator
Due: Tuesday, Oct. 31, 8am
12 points
This program is based on the excursion section from Chapter 5, but uses a modified heart class (and some other classes). The program is designed to simulate a cardioverter/defibrillator -- an electric device implanted in a person's heart to monitor heart rhythms and to administer an electric shock when those rhythms indicate that the heart is not functioning correctly. You should read the information in Section 5.14 to familiarize yourself with what a zero-crossing-count is.
In this program you will be modifying both the client program, cardiov.cc and the implementation of the Heart class in heart.cc.
The program is designed to enable you to get used to the idea of developing a program by a process of iterative enhancement --- of increasing the functionality of a program in steps rather than trying to develop it all at once.
1.1 Getting Started
You should create a subdirectory named assign5 in your cps6 directory.
cp ~ola/cps6/assign5/* .
This should copy the following file(s): Makefile, cardiov.cc, heart.cc, heart.h, monitor.cc, monitor.h, h1.dat.
You'll need to link to an animator by typing the following command:
ln -s ~rodger/bin/animator anim
Verify that these file(s) have been copied and linked by typing ls to see all the files in the current directory. In particular, the Makefile for this assignment is different than makefiles from previous assignments.
We'll be using the Xtango animator to display the monitor and heartbeats. The animator will only work under X windows; any of the Sparc 5's should work fine. Each time you login to work on this program, you'll need to type the following command once:
xrdb -merge ~rodger/bin/xtango.res
Now to use the animator, first compile cardiov.cc by typing make cardiov. The monitor class outputs animator commands that are understood by the Xtango animator. To run your program, all output will be piped into the animator by typing:
cardiov | anim
An Xtango window should appear (if it doesn't, did you type the xrdb command above?). You might need to move the Xtango window so you can see it and the xterm window at the same time. The column on the right edge of the Xtango window is a speed control bar which is currently set on the highest speed. Move the rectangle in this column to midway to slow the animation down. To start the animation, click on the button run animation. In the xterm window, you are asked to type in the name of an input file. Type h1.dat and press return. You should see the monitor warm up, and then display heart beats. To quit at any time, click on the quit button.
IMPORTANT NOTE: All output is being sent to the animator. If you want to print anything to the screen (for debugging purposes or otherwise) you'll need to print the word comment at the begining of each output line). That is, each cout statement in your program should start with:
cout << "comment " << ....
You will first modify cardiov.cc so that zero-crossing-counts are determined and the heart shocked. Then you will modify the implementation of the Heart class in heart.cc.
In this simulation, all heart beats are integer voltages in the range of -15 to +15. A file of numbers can be used to simulate a heart or the heart can generate its own voltages. To debug your program, you should use the file of voltages since this is predictable. After your program works with the file of voltages you'll be able to change it so that the heart generates its own voltages.
One file of voltages, h1.dat, is provided to you. This file is barely adequate for testing your program, you should create your own file of voltages (using emacs or some other editor) so that you can be sure that your program works
(Based on exercise 5.8 on page 262)
heart.Shock(Heart::SpeedUp);
to speed the heart up, or you'll write
heart.Shock(Heart::SlowDown);
to slow the heart down.
Be sure to test your program completely by developing good test files. Your grade for this part of the assignment will be based on whether your program correctly computes zero-crossings (70\%) and on style (30\%).
Once your program calculates zero-crossing counts, you'll change the definition of the variable theHeart in cardiov.cc so that no data file is used. Instead, use the default constructor as shown below.
Heart theHeart; // heart will 'sense itself'
Remake the program (make cardiov) and run it. It will ``beat forever'', so to stop it you should type control-C (hold the control key down and press C).
You'll make several changes to the heart.cc program. Be sure that each change works before proceeding to the next change.
Heart::Heart(int maxbeats)
Be sure to make cardiov to check your work.
Be sure to check that this works.
You can be creative, if you want to add other functionality to either cardiov.cc or to the Heart class be sure to document what you've done in both your README file and in the appropriate .cc and .h files.
You should submit all programs that you modified as part of this assignment. This should include cardiov.cc, heart.cc, heart.h, and a data file that you think is a good test of the program (a sequence of values to be read) called heart.dat. As always, submit a README file indicating about how long it took for this assignment, who (if anyone) you worked with, and any comments you have about the assignment.
submit6 assign5 README cardiov.cc heart.dat heart.cc heart.h