Handout #13, Project 4 - ECE

advertisement
Department of Electrical and Computer Engineering, University of Maryland at College Park
ENEE 114: Programming Concepts for Engineers
Fall 2005, Prof. S. S. Bhattacharyya
Handout #13, Project 4
Tuesday, December 6, 2005, 6:00PM1.
Electronic submissions only.
In this continuation of Project 3, you will develop version 2 of the UMD Resistor Network Analysis
Tool (umdrnatV2).2
The features, input format, and output format for this version are the same as that of the first version,
except for the following changes:
• In umdrnatV2, multiple resistors can be connected across the same pair of nodes.
• Input to umdrnatV2 comes from an input file that is specified as a command line argument. Similarly, the
output of umdrnatV2 is written to a file that is specified as another command line argument.
As with project 3, a standard set of data structures and their explanations, along with other standard
definitions will be provided in the required header files rnat_standard.h, rnat_globals.h, and
rnat_prototypes.h. These files are modified versions of those that were used in Project 3. The versions
for project 4 will be available through the following project 4 resources page:
http://www.enee.umd.edu/~ssb/class/project4/enee114main.html
You are required to base your implementation of Project 4 on the data structures and other definitions
provided through this web page. Thus, you are not allowed to modify rnat_standard.h,
rnat_globlas.h, nor rnat_prototypes.h.
1. Source code organization
The overall organization of the source code files is the same as that used for Project 3. This
organization format is summarized again here.
A. umdrnat.c should contain (in this order):
#include "rnat_standard.h"
#include "rnat_globals.h"
#include "rnat_prototypes.h"
B. umdrnat_main.c should contain (in this order):
#include "rnat_standard.h"
#include "rnat_prototypes.h"
C. Any driver files that you write, such as initializeNetworkDriver.c, should contain (in
this order):
#include "rnat_standard.h"
#include "rnat_prototypes.h"
D. rnat_globals.h should be included ONLY in umdrnat.c.
1. Note that this deadline is one day later than the deadline specified in the course schedule handout.
2. The names of the source code and executable files are the same as in Project 3 (umdrnat.c, umdrnat_main.c,
umdrnat.exe, etc.). We use the term "umdrnatV2" simply to help distinguish between the two versions of the
project developed in Project 3 and Project4.
E. umdrnat.c should contain all of the required functions along with any other functions that you write,
except for the main function.
F. umdrnat_main.c should contain only one function, which is the main function of the program.
2. Changes to the standard data structures
This section provides a summary of major changes to the standard data structures. For full details, see the
new versions of rnat_globals.h and rnat_standard.h.
• Support for connecting multiple resistors in parallel (across the same pair of circuit nodes) is provided for by
modifying the data type of the entries in the network adjacency matrix so that each entry is a linked list.
• Furthermore, information about resistors is now maintained as a single array of structures rather than as
separate arrays for resistor names and resistance values. One consequence of this revision is that there is no need
to keep track of resistor identifiers, since correspondence of entries between multiple arrays need not be tracked
when looking up resistor information.
One way to start experimenting with the new standard header files is to study, compile, and run the new
companion program rntest.c, and examine the resulting output, which again consists of some basic diagnostic
information.
3. Required functions
The standard file rnat_prototypes.h provides prototypes for the required functions that must be
developed and applied in your implementation. Each of the required functions from Project 3 has a corresponding
function in Project 4. In each case, the corresponding function has the same name and provides an analogous
feature, but has a somewhat different prototype. The changes in the prototypes are due primarily to the
modifications to the standard data structures, and the use of files for program input and output. For example, the
readLine function now takes a file pointer for the input file as an argument, and the drawCircuit function now
takes a file pointer for the output file as an argument.
The complete specification of how the prototypes have changed is not part of this project specification
document; it is your job to review how the prototypes have been revised, and compare these revisions with the
revisions to the standard data structures to determine exactly what changes are necessary to the required functions.
Additionally, you will need to update the function header comments to reflect the revisions to the function
prototypes and implementations.
Note that there is one new required function that does not correspond to a function in Project 3. This is the
processArguments function. This function should perform the following sequence of steps:
• Extract the input file name and output file name from the command line arguments to the program. Print an
error message and exit if the number of program arguments is incorrect.
• Open the specified files for reading. and writing, respectively. Print an error message and exit if either of these
files cannot be opened.
• If the above steps succeed, then return the resulting file pointers through the variables pointed to by the first
and second FILE** arguments, respectively. These arguments must be “pointers to pointers” because the values
that are being returned are themselves pointers.
Note that the first FILE** argument is a pointer to the file pointer variable that is to store the input file pointer,
and the second FILE** argument is a pointer to the file pointer variable that is to store the output file pointer.
4. Putting it all Together
Under the new, file-based program interface, the general usage of the umdrnatV2 program is as follows:
umdrnat <network>.rnat <network>.dot
neato -Tps2 <network>.dot -o <network>.ps
ENEE 114, Fall 2005, Prof. S. S. Bhattacharyya, Project 4, page 2 of 4
Here, <network>.rnat represents the name of the file that contains the resistor network specification
that is to be processed, and <network>.dot represents the file in which the user wants to store the resulting dot
program.
Note that the "<" and ">" operators for input/output redirection should not be used for this version of the
project since the input and output are coming from files that are specified as command line arguments.
5. Example
Figure 1 gives an example that illustrates the new features in umdrnatV2.
Suppose that the text of Figure 1 is contained in a file called network2.rnat. Then we can generate the
corresponding dot output in a file called network2.dot by using the following command:
umdrnat network2.rnat network2.dot
Note that in this network, resistors R3 and R4 are connected in parallel, and so are the resistors R6, R7, and
R8. Such connections are not allowed in the version of umdrnat developed in Project 3, but are processed without
error in the version that your are developing in Project 4.
6. Grading
6.1 Grading Breakdown
1. Correctness of required functions, including any specified error handling: 6% each, for a total of 54%.
2. Correctness of the main function, and compliance with the overall functional specifications of the
project: 11%.
3. Documentation (comments): 10%.
4. Organization and clarity of code (apart from coding conventions): 10%.
5. Use of course coding conventions: 15%.
Network network2 of 4 nodes
resistor R1 20
resistor R2 43
resistor R3 100
resistor R4 100
resistor R5 23
resistor R6 6.5
resistor R7 44
resistor R8 1
connection R1 1 4
connection R2 1 2
connection R3 2 4
connection R4 2 4
connection R5 2 3
connection R6 3 4
connection R7 3 4
connection R8 3 4
Figure 1. An example of a network specification that cannot be handled by the version
of umdrnat developed in Project 3, but can be handled by umdrnat Version 2.
ENEE 114, Fall 2005, Prof. S. S. Bhattacharyya, Project 4, page 3 of 4
Note that correctness of functions and correctness of the overall project includes consistent and appropriate
use of the standard template files, rnat_standard.h, rnat_prototypes.h, and rnat_globals.h.
6.2 Potential for Improvements to Project 3 Score
For any required functions, including main, for which correctness points were deducted in Project 3, but
for which full credit is obtained in Project 4, 50% of the correctness points that were deducted for that function in
Project 3 will be added back to the Project 3 score. For example, if one receives 3% out of 6% for a particular
function in Project 3, and that function is extended in Project 4 into a fully functional implementation (full 6%
credit given), the Project 3 score for that function will be improved to 4.5% (in addition to the full 6% credit for the
function that is awarded for Project 4).
Note: this does not require re-implementing anything in Project 3 nor resubmitting Project 3. Any such
adjustments to the Project 3 grade will be determined entirely from the improvements observed in Project 4.
ENEE 114, Fall 2005, Prof. S. S. Bhattacharyya, Project 4, page 4 of 4
Download