Assignment 2 (100 Points) - Due Monday, October 08, 11:59PM

Announcements and Clarification

Oct 23: Assigment2 Public Testfile, Private Testfile and Outputfile. Assignment2_Testfile_Outputfile.tgz

Oct 07: Non truncated output file sample (using different trending extraction method): outputfile6_Non_truncated_2. Both files are correct. This is reference only, does not use the correct output format. (8:38pm Oct 8)

Oct 07: Non truncated output file sample: outputfile6_Non_truncated_1. This is reference only, does not use the correct output format. (1:32pm Oct 8)

Oct 07: For the AC status analysis, when detecting the sequence of three decreasing temperatures, the temperatures must be "less than the previous temperature", not "less than or equal to the previous temperature".

Oct 05: Sample output file: outputfile6. (1:32pm Oct 8)

Oct 04: For determining the AC status, the internal floating value results from the filtering step should be used. Thus, it is possible that a decrease in temperature is observed, even though the formatted output (with only two digits of precision) does not display this decrease.

Sep 3: The following test files can be used for testing the functionality of your program: Assignment2TestFiles.tgz.

September 19: A draft Assignment 2 Rubric is available. Please note that minor changes to the grading rubric may be made during the grading process.

September 19: Please use "NetID_tempfilter.tgz" as your submission file name. Remember to replace "spacer" in CMakeLists.txt to "tempfilter".

Temperature Filtering and Trend Extraction

Create a program that will filter a log of temperature data representing internal temperature values recorded within a home. Assuming the temperature data was collected during the summer, the program should determine when the air conditioner was operating by analyzing trends within the collected data.

Commandline Arguments

Your program must be capable of utilizing a commandline argument to specify the input log file and output file with the filter data and analysis results.

tempfilter inputFile outputFile


Your program must ensure the user has correctly provided the required commandline argument and display a usage statement if the provided arguments are incorrect.

Input Temperature Log Format

The input temperature log format will provide a log of recorded times and temperature readings, in which one reading will be specified per line, using the following format:

HH:MM TT.T


  • HH:MM represents the time at which the temperature was recorded and is specific in 24 hour format.
  • TT.T represents the recorded temperature reported in Fahrenheit as a floating point value.
  • The time and temperature will be separated by one or more whitespace characters.
  • The times within the input file will consists of one day's worth of temperature readings starting at 00:00 through 23:59.
  • The following is a simple example of the input file format:

    09:30 71.2
    09:31 71.0    
    09:32 70.8  
    09:33 70.4
    09:34 70.7
    09:35 70.6


Note: The temperature log may be missing data and not contain a complete log of temperature for all minutes within a day.

List Data Structure

For keeping track of the temperature data in your program, you must implement a doubly-linked list data structure. The struct and typedef definitions provide a template for the required structures that should be utilized within this assignment.

typedef struct ListData_ {
    // you will need to define the members for this structure
} ListData;

typedef struct ListElmt_ {
    ListData *data;
    struct ListElmt_ *next;
    struct ListElmt_ *prev;
} ListElmt;

typedef struct List_ {
    int size;
    ListElmt *head;
    ListElmt *tail;
} List;

The functionality specific to each of these structures should be implemented within their own set of C source and header files. Specifically, the functionality for ListData should be implemented within listdata.h and listdata.c files, the functionality for ListElmt should be implemented within listelmt.h and listelmt.c files, the functionality for List should be implemented within list.h and list.c files.

Note: Using a singly-linked list may use a singly-linked list to implement the assignment will result in a 5% reduction in your assignment grade.

Temperature Filtering Part A: Removing Erroneous Data

Your program should first remove any erroneous temperature readings. An error temperature reading is defined as a temperature reading that is either more than 5 degrees above or 5 below the temperature recorded in the previous minute. All erroneous temperature readings should be removed.

Temperature Filtering Part B: Simple Low-Pass Filter of Consecutive Samples

As temperature sensor readings may be noisy, we would like to apply a simple low-pass filter to filter any sequences of consecutive temperature readings. The following defines a simple low-pass filter that can be used for these purposes:

filtered_output(0) = unfiltered_input(0)

filtered_output(n) = 0.9375 * filtered_output(n–1) +
0.0625 * unfiltered_input(n)


After removing the erroneous data, your program should apply a low-pass filter to sequences of temperature readings for consecutive times. The filter should restart if any gaps are found within the recorded data.

Note: A good article on low-pass filter for embedded software can be found at: Link

Temperature Filtering Part C: Trend Extraction

Given the filtered data, your program should analyze the sequence of trends to automatically determine the state of the air conditioner. This analysis should operate as follows:

  1. Assume the air conditioned was initially Off.
  2. If a sequence of three consecutive, monotonically decreasing temperature readings are found, the first temperature reading's air conditioner state will switch to On. Note: In other words, the AC status will will chance to On starting with the first temperature reading in that sequence. This implies that all three temperature readings in that sequence will have an AC status of On.
  3. REVISED (to clarify): If any increase in consecutive temperature reading is found, for the first temperature reading with that increase, the state of the air conditioner will switch to Off.


Filtered Output File Format

The filtered output log should be formatted with one entry per line using the following format:

HH:MM TT.TT AC


  • HH:MM reports the time at which the temperature was recorded specified in 24 hour format.
  • TT.TT represents the filtered temperature value in Fahrenheit as a floating point value with two decimal digits of precision.
  • AC reports the determined status of the air conditioner, where a 0 represents the the air condition was Off and a 1 represents the air conditioner was On.
  • Each entry should be separate by a single tab character (\t).
  • The following provides an example of the output for input example provided above:


09:30 71.20 1
09:31 71.10 1
09:32 70.80 1
09:33 70.40 1
09:34 70.70 0
09:35 70.60 0

\\