Basic C Project

Basic C Project

Page 1
Project Title: “Energy Consumption Monitor”
CS 1325
Spring 2017
Deadline: April 23rd, 10:00 PM using e-Learning ONLY.
Every student is expected to submit their own, individual/original work, and should be able
to explain and answer questions regarding the code and the way the code was written.
If your submission contains, any file obtained from internet (except the files provided as
input files), or other person (class mates, tutors, etc.), your submission will be discarded
and the grade will be 0 automatically.
Ask if you have any question.
1. Project summary
Power consumption is a key parameter when designing new systems (software and hardware). In a single
system multiple modules may consume energy at a different rate, in different periods of time.
In this project, multiple modules (sensors) report the power consumption to a single server. The server
will read and process the information and obtain basic statistical parameters (min, max, average, etc.)
over a period of time.
In this project, all the sensor information is obtained through input files.
2. Input parameters
The user should enter:
? Number of sensors used,
? File location (full path),
? Time period (tinitial and tfinal).
After the previous information is provided, then the user can obtain the total power consumed between
tinitial and tfinal., as well as the sensor that consumed the most and the least amount of power.
3. Input Files
The filename includes the prefix SENSOR_ and the sensor number: SENSOR<sensor_id>.txt.
For example SENSOR_1.txt is the file that contains the data collected by sensor 1.
? Files have the following format:
<time_stamp> <value> <units>
For example:
4534 97.4 mW
4554 97.5 mW
4574 97.6 mW
Notice that each sensor may have a different sample rate (e.g. time in between measurements),
and different units (i.e. some sensor may measure in mW while some other may use µW)
CS 1325 – Project Description Fall 2014
Page 2
4. Power consumption per sensor
The power consumed by a sensor between [tinitial, tfinal] can be obtained by integrating the data as
follows. Assume that the sensor data is the one described in 3. Assume that the time interval is [4534,
4574].
Figure 1: Power consumption per sensor
The power consumed is computed as the sum of the A1 and A2. These areas can be obtained as A1 =
(4554-4534)*97.4 = 20*97.4 and A2= (4574-4554)*97.5 = 20*97.5 mW
Q: What if the time interval was [4540, 4570]?
A: Then A1 = (4554-4540)*97.4 = 14*97.4 and A2= (4570-4554)*97.5 = 16*97.5 mW
Q: OK, what if the time interval was [4530, 4580]?
A: In this case there is no value for 4530 nor 4580. But, we can use the last “known” value, such that
A1 = (4554-4530)*97.4 = 24*97.4 , A2= (4574-4554)*97.5 = 20*97.5 mW and A3 = (4580-
4574)*97.6=6*97.6 mW
5. Functional requirements
Roles:
User
USE CASE a: “[Enter the number of sensors]” (5 Points)
? The user selects option a from the menu
? The user is asked to enter the number of sensors
? The number should be an integer >0
? The program display the main menu
USE CASE b: “[Enter file location]” (5 Points)
? The user selects option b from the menu
? The user is asked to enter the file location (full path: folder and filename with file
extension)
? The program should warn the user if the file cannot be opened, or there is an error reading
the file(i.e. incomplete/ incorrect data in the file)
? The program displays the main menu
CS 1325 – Project Description Fall 2014
Page 3
USE CASE c: “[Time interval t0 and tf]” (5 Points)
? The user selects option c from the menu
? The user is asked to enter the values for tinitial and tfinal
? Both (initial and final time) should be integers > 0
? tinitial should be smaller than tfinal
? The program displays the main menu
USE CASE d: “[Get Statistics]” (40 Points)
? The user selects option d from the menu
? The program checks if the options a-c were already chosen.
? If all the input (a-c) is available, then computes and display the table with the values for
min, max and average power consumed per sensor.
? If (a-c) is not available the program should warn the user, indicating the missing
information and display the main menu.
? The last row shows the total power consumed. Normalize the units to W.
? The table indicates the sensor with the highest and lowest power consumption within
that period of time
? The program displays the main menu
USE CASE a-d: “[VALIDATION]” (20 Points)
? Input should be a valid data type:
o Integer, float, c-string, etc.
? Range should be valid
o Based on entered parameters
? If the input data is invalid, the user should be asked to enter the data again
? File name and location (path) should be valid, as well as the file data (i.e. corrupted files,
incorrect format, etc.)
? Option a to c can be selected on any order. Option d, can only be chosen once the user
entered all the information (a-c)
6. Output Examples
The program should display
1) A menu with the following options(a to e) ( 5 points )
a).- Enter the number of sensors
b).- Enter file location
c).- Time interval t0 and tf
d).- Get statistical values
e).- Exit
2) If option d) is chosen, the program displays a table with the statistical values. For example:
Sensor
—————-
Min
—————-
Max
—————-
Average
—————-
0 0.0954 W 0.0966 W 0.096 W
1 0.0554 W 0.106.3 W 0.0808 W
2 0.0689 W 0.1044 W 0.0866 W
3 0.0781 W 0.0926 W 0.0853 W
———————————————————————–
The total power consumption between [2301,5698] was = 1184.534 W
Sensor 0 consumed the highest amount of energy =326.112 W
CS 1325 – Project Description Fall 2014
Page 4
Sensor 1 consumed the lowest amount of energy =274.477 W
———————————————————————–
7. Environment
The computer program should comply with the commenting and formatting rules. For example, there
should be a header for the whole program that gives the author’s name, class name, date, and
description. End braces should be commented, and alignment and indenting requirements as
discussed. Please ask if you have any questions.
8. Test cases (10 Points)
For each USE CASE in 5, define a set of values as input data to test the correctness of your program.
9. Other requirements (non-functional and system) (10 points)
Report:
? Include requirements(this document)
? Flow chart for the complete program
? Test Cases
? Source code (.c files) with comments
? Assumptions clearly explained (i.e. time is always integer)
? Comments and future work (what would you do, should you have more time?)
10. Deliverables(Mandatory):
A zip file per team, with:
? Report document (with examples of the input/output data), either word file or pdf
? C source file
? Executable
11. Topics covered
? File Processing, Flow Control, Operators and Expressions, Pointers, Arrays and Functions.

find the cost of your paper