ALOGROTHM OF CLIMATE CONTROL SYSTEM IS THIS PLEASE GIVE ME ITS SIMPLE C PROGRAM

SOLUTION ASSIGNMENT 1 CMPT 128 October 2008
ALGORITHM
1. Prompt the user for the name of the output filename to hold the log of times 
when heating
and cooling were turned on or off
2. Read the filename
3. Open the indicated file and check that it opened correctly
a. If it did not open correctly print and error message and stop the program
4. Prompt the user for the name of the output filename to hold the table of 
data containing
results at every time step
5. Read the filename
6. Open the indicated file and check that it opened correctly
a. If it did not open correctly print and error message and stop the program
7. Prompt the user to enter the value of degreesPerSecondCooling, the amount of 
cooling
provided by the cooling system
8. Read degreesPerSecondCooling
a. If the value entered is not >0 prompt the user to enter a corrected value, 
then
reread the value
b. Repeat a until a valid value is read
9. Prompt the user to enter the value of degreesPerSecondHeating, the amount of 
heating
provided by the heating system
10. Read degreesPerSecondHeating
a. If the value entered is not >0 prompt the user to enter a corrected value, 
then
reread the value
b. Repeat a until a valid value is read
11. Prompt the user for the name of the input filename containing the data
12. Read the filename
13. Open the indicated file and check that it opened correctly
a. If it did not open correctly print and error message and stop the program
14. Read the value of the present temperature from the input file
a. If the value entered is not -10<temp<30 print an error message and terminate 
the
program
15. Read the value of the desired temperature from the input file
a. If the value entered is not -10<temp<30 print an error message and terminate 
the
program
16. Read the value of the time interval between calculations from the input file
a. If the value entered is < 0 print an error message and terminate the program
17. Read the number of degrees above or below the desired temperature that the 
present
temperature can vary before the heating or cooling are turned on (from the file)
a. If the value entered is not 0<toleranceOn<10 print error message and 
terminate
the program
18. Read the number of degrees above or below the desired temperature that the 
present
temperature can vary before the heating or cooling are turned off (from the 
file)
a. If the value entered is not 0<toleranceOff<5 print an error message and 
terminate
the progam
19. If toleranceOff > toleranceOn print an error message and terminate the 
program
20. Write the column header to the output file for the output results table
21. Set n=0
22. Read the amount of heat escaping from the building each second during the 
nth time interval
23. Until the end of file in the input file is reached repeat the following 
steps
a. Begin calculating the temperature at the end of the interval by adding the
temperature at the beginning of the interval to the amount of heat (temperature
decrease or increase) lost/gained from outside the building (amount of heat
escaping per second * number of seconds in interval)
b. If the heating is on add the temperature change due to the heating to the 
end of
interval temperature
c. If the cooling is on add the temperature change due to the cooling to the 
end of
interval temperature
d. Test to see if the cooling should be turned on (startIntervalTemp > 
desiredTemp +
toleranceOn && !coolingOn)
i. If so turn on the cooling (set coolingOn)
ii. Print a message to the log file and to the screen indicating when the
cooling was turned on
e. Test to see if the heating should be turned on (startIntervalTemp > 
desiredTemp -
toleranceOn && !heatingOn)
i. If so turn on the heating (set heatingOn)
ii. Print a message to the log file and to the screen indicating when the
heating was turned on
f. Test to see if the cooling should be turned off (endIntervalTemp > 
desiredTemp -
toleranceOff && coolingOn)
i. If so turn off the cooling (clear coolingOn)
ii. Print a message to the log file and the screen indicating when the cooling
was turned off
g. Test to see if the heating should be turned off (endIntervalTemp > 
desiredTemp +
toleranceOn && heatingOn)
i. If so turn off the heating (clear heatingOn)
ii. Print a message to the log file and the screen indicating when heating was
turned off
h. Print a line of output to the output table in the file containing the output 
table
i. Read another value of amount of heat escaping
J set the start of interval temperature to the end of interval temperature
24. Close all files and terminate program
TEST PLAN:
Case1: Input file does not exist
Input: Names of output file 1 and output file 2, Name of input file (a file 
that does not exist)
Output: Message indicating input file cannot be opened.
Case2: Output file 1 cannot be created
Input: Name of input file 1 (name is name of a read only file)
Output: Message indicating output file cannot be opened
Case3: Output file 2 cannot be created
Input: Name of input file 1, name of input file 2 (name is name of a read only 
file)
Output: Message indicating output file cannot be opened
Case4: Degrees per second heating/cooling out of range, present temperature out 
of range
Input shown in red, output shown in blue
Enter the name of the output data Stream 1 (on/off times): out1
Enter the name of the output data Stream 2 (table of results: out2
Enter the number of degrees Celsius per second that your heating system increase
s the temperature in the building: -.001
Enter the number of degrees Celsius per second that your heating system increase
s the temperature in the building: .003
Enter the number of degrees Celsius per second thay your cooling system decrease
s the temperature in the building: -.777
Enter the number of degrees Celsius per second that your cooling system decrease
s the temperature in the building: .002
Enter the name of the input file for the input data Stream: markIn.txt
The initial temperature indicated in your input file
is out of range, not between -10.0 and 30.0
Case5: Degrees per second heating/cooling out of range, desired temperature out 
of range
Input: output files out1 and out2 degrees per second heading -.001, degrees per 
second cooling,
Starting temperature 21.66, desired temperature -33.0
Output:
The desired temperature indicated in your input file
is out of range, not between -10.0 and 30.0
Case5: Degrees per second heating/cooling out of range, desired temperature out 
of range
Input: output files out1 and out2 degrees per second heading -.001, degrees per 
second cooling,
Starting temperature 21.66, desired temperature 19.5, time interval -1.0
Output:
The time interval indicated in your input file
is out of range, must be positive
Case6: Degrees per second heating/cooling out of range, desired temperature out 
of range
Input: output files out1 and out2 degrees per second heading -.001, degrees per 
second cooling,
Starting temperature 21.66, desired temperature 19.5, time interval 700, 
tolerance on 33
Output:
The temperature tolerance for turning on the climate control
is out of range (not between 0.0 and 10.0 degrees Celsius)
Case7: Degrees per second heating/cooling out of range, desired temperature out 
of range
Input: output files out1 and out2 degrees per second heading -.001, degrees per 
second cooling,
Starting temperature 21.66, desired temperature 19.5, time interval 700, 
tolerance on 1.,
tolerance off 55
Output:
The temperature tolerance for turning off the climate control
is out of range (not between 0.0 and 5.0 degrees Celsius)
Case8: Degrees per second heating/cooling out of range, desired temperature out 
of range
Input: output files out1 and out2 degrees per second heading -.001, degrees per 
second cooling,
Starting temperature 21.66, desired temperature 19.5, time interval 700, 
tolerance on 1.,
tolerance off 1.5
Output:
tolerance for turning off larger than
tolerance for turning on: Error
Case9: Degrees per second heating/cooling out of range, desired temperature out 
of range
Input: output files out1 and out2
Contents on input file
23.66
19.5
700
2.
0.5
3.021440e-005
8.858413e-004
-4.409170e-003
0.836466e-005
0.138610e-005
9.295011e-004
6.295011e-004
6.138610e-004
2.836466e-004
-9.409170e-004
8.858413e-003
5.991182e-003
Enter the name of the output data Stream 1 (on/off times): out1
Enter the name of the output data Stream 2 (table of results: out2
Enter the number of degrees Celsius per second that your heating system 
increases the
temperature in the building: .007
Enter the number of degrees Celsius per second that your cooling system 
decreases the
temperature in the building: .0045
Enter the name of the input file for the input data Stream: markIn.txt
The cooling was turned on after 700.00 seconds.
The heating was turned on after 2100.00 seconds.
The cooling was turned off after 2100.00 seconds.
The cooling was turned on after 3500.00 seconds.
The heating was turned off after 3500.00 seconds.
The heating was turned on after 5600.00 seconds.
The cooling was turned off after 5600.00 seconds.
The cooling was turned on after 6300.00 seconds.
The heating was turned off after 6300.00 seconds.
The cooling was turned off after 7000.00 seconds.
The cooling was turned on after 7700.00 seconds.
Contents of first output file
Starting Ending Starting Ending Starting Starting Ending Ending
Time Time Temperature Temperature Heating Cooling Heating Cooling
700. 1400. 23.66 23.68 Off Off Off On
1400. 2100. 23.68 21.15 Off On Off On
2100. 2800. 21.15 14.91 Off On On Off
2800. 3500. 14.91 19.82 On Off On Off
3500. 4200. 19.82 24.72 On Off Off On
4200. 4900. 24.72 22.22 Off On Off On
4900. 5600. 22.22 19.51 Off On Off On
5600. 6300. 19.51 16.79 Off On On Off
6300. 7000. 16.79 21.89 On Off Off On
7000. 7700. 21.89 18.08 Off On Off Off
7700. 8400. 18.08 24.28 Off Off Off On
Contents of second output file
The cooling was turned on after 700 seconds.
The heating was turned on after 2100 seconds.
The cooling was turned off after 2100 seconds.
The cooling was turned on after 3500 seconds.
The heating was turned off after 3500 seconds.
The heating was turned on after 5600 seconds.
The cooling was turned off after 5600 seconds.
The cooling was turned on after 6300 seconds.
The heating was turned off after 6300 seconds.
The cooling was turned off after 7000 seconds.
The cooling was turned on after 7700 seconds.


Reply via email to