CNET232 Week 1 Assignments TECH153 L10 – Alarms In this lab we look at greenhouse controller alarms. Alarms require an object to hold the alarm limits. We allow for limits on temperature, humidity,...

programming hellp


CNET232 Week 1 Assignments TECH153 L10 – Alarms In this lab we look at greenhouse controller alarms. Alarms require an object to hold the alarm limits. We allow for limits on temperature, humidity, and pressure. The alarm data is held in an alarm object that has an alarm code, a time, and the sensor value that triggered the alarm condition. We use an array of alarm_s structures to store the 6 possible alarms plus a no alarm state. References to this array will be used by the alarm functions GhSetAlarms, and GhDisplayAlarms. The alarms array use an enum type to describe the index for the various kinds of alarms.We also use a constant character array to hold the alarm names for use with the GhDisplayAlarms function. Task 1 –Using typedef with Alarm Structures. 1. A new constant NALARMS will be defined in ghcontrol.h with a value of 7. 2. The alarms will use the following enum type defined in the ghcontrol header file: // Enumerated Types typedefenum { NOALARM,HTEMP,LTEMP,HHUMID,LHUMID,HPRESS,LPRESS } alarm_e; 3. The alarms will also use the following structures to be defined in the ghcontrol header file: typedef struct alarmlimits { float hight; float lowt; float highh; float lowh; float highp; float lowp; }alarmlimit_s; typedef struct alarms { alarm_e code; time_t atime; float value; }alarm_s; 4. Create two functions in ghcontrol.c/h;GhSetAlarmLimits, which returns data of the alarmlimit_s type after assigning the alarm limit values to this object, and GhSetAlarms, which takes an array alarm_s calarm[NALARMS], an alarmlimit_s object, and a reading_s object. alarmlimit_s GhSetAlarmLimits(void); This function creates a local alarmlimit_s object called calarm then assigns the calarm fields to the appropriate alarm limit constant, and then returns the calarm object. For example: calarm.hight = UPPERATEMP; Create the constants for the alarm limits LOWERATEMP, UPPERATEMP, LOWERAHUMID, UPPERAHUMID, LOWERAPRESS, UPPERAPRESS with the values: Temperature: 10 and 30Humidity: 25 and 70Pressure: 985 and 1016. void GhSetAlarms(alarm_s calarm[NALARMS],alarmlimit_s alarmpt, reading_s rdata) This function declares a local counter i, and then sets all of the code values in the calarm array to NOALARM. Then it uses a series of if statements to check the values of various rdata readings against the alarm values. If an alarm condition is true it sets the alarm code field, the rdata reading time, and the appropriate reading value of the appropriate alarm_s object in the calarm array. For example: if(rdata.temperature >= alarmpt.hight) { calarm[HTEMP].code = HTEMP; calarm[HTEMP].atime = rdata.rtime; calarm[HTEMP].value = rdata.temperature; } 5. Create a new function in ghcontrol.c/h, GhDisplayAlarms,which takes an object of type alarm_s, and prints the current state of the alarms to the display, using the data in the alarm array. 6. This function requires a table of strings with the names of the alarms declared at the top of the ghcontrol.c file after the #include “ghcontrol.h” statement. It uses a new alarm name size constant called ALARMNMSZ that has a value of 18 and the constant NALARMS with a value of 7. // Alarm Message Array const char alarmnames[NALARMS][ALARMNMSZ] = {"No Alarms","HighTemperature","LowTemperature","High Humidity", "Low Humidity","HighPressure","Low Pressure"}; 7. Use a for loop starting at index 1, to test the code field for each alarm. If the code field is not equal to NOALARM print out the alarm name using a reference from the alarmnames array, and the date/time the alarm was set provided by the string ctime(&alrm[i].atime) 8. In ghc.c, two new objects will be created to hold limit and alarm data. alarmlimit_s alimits = { 0 }; alarm_s warn[NALARMS]; 9. The object alimits will be assigned the data returned from a call to GhSetAlarmLimits (after the call to GhSetSetpoints) 10. After calling GhSetControls, GhSetAlarms is called with the arguments warn, alimits, and creadings. 11. After calling GhDisplayControls, GhDisplayAlarms is called using the argument warn. 12. Build and run the program. Task 2 – Submitting Your Lab 1. Use WinSCP to transfer the makefile, .c, and .h files from your ghc folder on the RPI to your doxygen folder C:\Users\username\Documents\ceng153\labs\doxygen 2. Run doxygen using the supplied doxygen.bat file. 3. Edit the second page of refman.rtf to include the contents of the makefile and a sample output screen. 4. Save the refman.rtf file as a .docx file with the name your LastName153L10 and submit it to Blackboard.
Aug 07, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here