You are on page 1of 5

National University of Computer & Emerging Sciences

EE112: Programming for Engineers II

Sections A, B (Spring 2012)

P02

Monday 16 Apr 2012

Instructors: Aamer Munir

Lab Engineers: Hina Ashraf, Attique Dawood TA: Khalida Ambreen (Batch’10)

Saturday 5 May 2012

Additional Submission Requirements:

Please read Coding Guidelines (Prog2 - Coding guidelines v1.1.pdf) and General Assignment Guidelines (Prog2 - General Assignment Guidelines v1.1.pdf).

1. Submit one zip file. Multiple submissions allowed before the deadline.

2. The zip file must be named as Spr12_RollNo1_RollNo2_RollNo3_P02.zip; where RollNo1, RollNo2 and RollNo3 are the roll numbers of the group members. In case of two use only two.

3. There must be a readme.txt file (a text file which should open in notepad) in the package. Absence of this file means minus 1 absolute marks. This file should describe:

 

a. Describe the name of each file in the package and its purpose.

b. How to use your package and run the software to solve circuits. Include a sample

circuit description of 4 nodes different from any sample that I provide.

4. Every code file (.h or .cpp) must have the required header listing all the group members (names, roll numbers and section).

5. Submit on SLATE. Email submissions, attachment to messages on SLATE etc are not

 

accepted.

6.

Submit before 7:30 am on the due date.

7.

Demonstration and presentations will be held on Saturday, 5 th May, 2012. Timings will be announced later.

8.

Those groups who do not submit a working project which at least successfully achieves Target-1 (details below) will earn minus 3 absolute marks in the Class Participation (CP).

Putting concept to practice EWb (Electronic Workbench)

Task:

You are required to use OOP concepts learnt in class (using C++ programming language) to make a program which:

1. Allows the user to input a circuit from the Program Command Line (PCL) as text commands, and

2. Provides the required output (voltage or current) when asked to evaluate.

3.

Saves the entered circuit to a file (choice of text or binary mode is left to programmer although I recommend the use of a text file as this will allow you to modify its contents even without the use of the program and see whether the desired change reflects in output or not).

4. Load a circuit from a file.

The word circuitused here refers to DC-Resistive circuits with independent VS or CS only (i.e. the circuit can contain resistors, VS and CS only. The circuit can have a maximum of 4 essential nodes.

Targets and Marks distribution:

1.

Target-1: The program covers Points 1 & 2. Half marks (3 absolute).

2.

Target-2: The program covers all points (Points 1, 2, 3, 4). Full marks (6 absolute).

3.

Bonus: The program can solve circuits bigger than 4 essential nodes. (4 absolute marks)

Details:

A circuit is comprised of components and interconnections (what is this; aggregation or composition?). A

component creates a branch. A component is connected between two nodes. A node joins at least two

branches. An essential node is a node with at least 3 branches connected to it.

Let Nx refer to a node, Rx refer to a resistor, Ox refer to a VS and Ux refer to a CS. Trying to assign a unique unambiguous character to each.

Where x is a positive integer number, 1, 2, 3,

Remember a component for this project only means a Resistor, a VS or a CS.

A component is described by three things:

1.

2.

Label (e.g. resistor label may be R1, R2, , VS label as O1, O2, and CS label as U1, U2, )

Value (for resistors in Ohms (Ω), for VS in Volts (V) and for CS in Amperes (A))

3.

Two nodes between which it is connected.

Note:

Please report any mistake in this write-up as soon as possible so that any mistake and ambiguity be

cleared as soon as is possible.

Commands supported by PCL (Program Command Line):

Program Command Line should be EWB:\>. Various commands are:

1. circuit

tell the program that the user wishes to enter a new circuit from command line. Usage: circuit <circuit_label> circuit label can be any string without a whitespace. Multiple circuits can be loaded into the program. So every loaded circuit must have a unique name. Various commands to create a circuit:

n

r

cs

vs

o

done

See usage in the samples below.

2. load

tells the program that the user wishes to load circuits from a file. A single file can contain multiple circuits. Usage: load <filename> Filename should be a valid filename. The program displays error if the file does not exist or cann ot be opened.

3. save

tells the program that the user wishes to save a loaded circuit to a file. Usage: save <loaded_cir> <filename> loaded_cir should be the name of a loaded circuit. filename the name of the file to which to save. If the file already exists, it is appended with this new circuit. The programmer should intelligently handle the case where the new circuit to be saved has the same name as a circuit already in the file!

4. list

Lists the names of all the loaded circuits in the program.

5. run

runs a circuit to evaluate the specified output and display the result. Usage: run <loaded_cir> loaded_cir should be the name of a loaded circuit.

6. rename

renames the name of a loaded circuit. Usage: rename cir1 cir4 Can be useful when saving to an existing file with a circuit of same name.

Sample Run and Commands:

Sample Run #1: Entering a circuit from command line and saving to file.

C:\> ewb11 <enter> Welcome to Electronic Work Bench (Batch 11 EE) Type ‘help’ for command help; ‘circuit’ to enter a circuit; ‘run’ to find specified outputs.

EWB11:\> circuit cir1 <enter> n, N1, N2 cs, U1, 10m, N2 to N1 <enter> r, R1, 3k, N1 to N2 <enter> r, R2, 3000, N1 to N2 <enter> r, R3, 0.003M, N1 to N2 <enter> o, Vt, N1 to N2 done <enter> EWB11:\> run cir1 <enter> Vt = 10 V EWB11:\> save cir1 cir1.ewb <enter> Success: cir1 saved to file cir1.ewb.

EWB11:\>

Sample Run #2: Loading a circuit from file

C:\> ewb11 <enter> Welcome to Electronic Work Bench (Batch 11 EE) Type ‘help’ for command help; ‘circuit’ to enter a circuit; ‘run’ to find specified outputs. EWB11:\> load cir1.ewb <enter> Success: 1 circuit loaded

-------------------------------------------

Circuit:

-------------------------------------------

cir1

nodes:

N1, N2

currentsource:

S1 = 0.01,

N2 to N1

resistor:

R1 = 3k,

N1 to N2

resistor:

R2 = 3k,

N1 to N2

resistor:

R3 = 3k,

N1 to N2

output:

Vt,

N1 to N2

-------------------------------------------

EWB11:\> run cir1<enter> Vt = 10 V

EWB11:\>

Grading:

1. Code that does not compile and does not attempt the problem stated here will get ZERO marks.

2. Half of the marks will be allocated based on submitted material.

3. Half of the marks will be allocated based on demo/presentation.

4. If for some reason demo/presentation cannot be held, complete marks will be awarded based on submitted material.

REMEMBER the golden rule:

Divide and conquer

Read all the details once properly to understand everything. Then start from a basic point and decide an abstract overall design of the project. Slowly keep filling in details. If you have strong framework, adding a new functionality is trivial. Remember the code in the main() should be minimal merely showing how inputs are routed to appropriate part of the code. All implementation level details should be off-loaded to appropriate classes/functions.

Submission Schedule:

S#

Task Name

Deadline

Submission deadline

1

Design Report a CHART sized UML class diagram listing all the classes you will use in your project and their associated with one another.

   

27

Apr

Submission in class at the start of the class.

(50% Weightage of submitted material marks)

12

ZERO marks in the absence of a working code (point 2).

 

2

Final Submission On SLATE. The submission must include guidelines (readme.txt) on how to use your program plus working code.

05

May

 

12

Spr12_RollNo1_RollNo2_RollNo3_P02.zip

(50% Weightage of submitted material marks)