Assignment 4: using sensors

This is an PAIRED assignment. Due: Wed, Nov 21. You must demo it to us in the oppen lab or make arrangements to show us beforehand.

Objective

In this assignment you will use inputs from sensors to draw a simple graph in your EnergyView window of your main (large screen) user interface. You will gain practice with taking input from simple sensors,computing the appropriate values, and updating graphics in real time.

Description

In this assignment, you will create an energy view that consists of 2 simple line graphs to replace your surrent static Energy View. We want these graphs to look like they are being updated in real time, but since you have not yet learned how to use "waiting", we will fake it. Each NEW input that comes in will advance the time by 1 unit. Your graph should be divided into 100 "ticks" representing time units. In other words, the x axis of your graphs is TIME. So, for exmaple, if you change the external temperature, you will recompute all your values, plot the new values for both graphs, set the appropriate highlighting (see below) and join the lines. Similarly, any change in the energy use from new sensor values will cause you to replot the lines. This means you need to keep the current state of all your variables as well as a list of all the points in each graph.

The values in the line graphs will be driven by input from 3 types of Arduino sensors:

  • slider: sets the external temperature : range is -10 to 35 degrees.
  • temperature: sets the internal temperature
  • light sensor: sets lights on or off

In addition, you will have a button on your window that will "turn on/off" appliances.

You will then calculate the energy values used as follows.

  1. External temperature will drawn as a line in a single upper graph. Use a slider to enter values between -10 to 35 degrees. As a change of temperature comes in, plot the new point on the graph and connect the line.
  2. Energy use (bottom graph) . Energy use is reported in kwH and is a sum of the following values:
    1. HVAC kwH = ABS(internal temp-ext temp)* 2.
      • Note: if the system is "heating", that is if the external temp < than the internal temperature, the line should be red and the H box below the graph should be "on". If the system is "cooling" (external > internal), then the line should be blue, and the AC box should be "on".
    2. LIGHTS kwH = one of FullOn (2 kwH) or off (0 kwH).
      • On turns on the Lights box, off turns it off.
    3. APPLIANCES kwH = on (3kwH) or off ( 0 kwH).
      • On turns on the Appliances box, off turns it off.

 

Hints

Remember to keep a list of all the points in each line graph so that your paintComponent() always draws a list of points.

ONLY draw the most recent 100 points.

Get this working as a standalone application first and then attach to your main energy journal if it is easier. This means asfter you get it working you MUST do the computation in the Model and NOT in the UI.

Deliverable

This assignment will probably be a bit easier for most people than the last one.

To turn in the assignment, please follow the same process as last time

If you do any extra credit work, be sure to let us know about it in the Design Document so that we don't miss it!!

Please take care to remove any platform dependencies, such as hardcoded Windows path names or dependence on a particular look-and-feel that may not exist on all platforms. Also, if you use any images in your application, please make sure that you include these in your ZIP file and that your code will refer to them and load them properly when from from inside the directory that's created when I unZIP your code.

Grading for this assignment, and future assignments, will roughly follow this breakdown:

Please let the TA or me know if you have any questions.