0% found this document useful (0 votes)
9 views6 pages

Tutorial4 Exercise

Uploaded by

nadimapple1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views6 pages

Tutorial4 Exercise

Uploaded by

nadimapple1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Tutorial 4 Exercise

Microprocessor Systems 2 (CMPN211)


Mechatronics – Cairo University

1
Vehicle Maintenance Tracker with Sensors Data Analysis
This project is a comprehensive Vehicle Maintenance Tracker designed to help
users manage their vehicle's maintenance records and monitor various sensor
readings. The application provides a menu-driven interface for users to perform
tasks such as adding maintenance records, viewing service history, calculating the
next service due, inputting sensor data, and analyzing that data.

The project employs two main structures: MaintenanceRecord for keeping track
of maintenance activities, and SensorsData for recording sensor readings related
to the vehicle's performance.

Structures Declarations

1. MaintenanceRecord Structure
• This structure holds the details related to maintenance performed on the
vehicle.

• Members:
▪ char serviceType [30]: A string representing the type of service
performed (e.g., "Oil Change", "Brake Check").
▪ char date [15]: A string representing the date when the service was
performed in the format "DD/MM/YYYY".
▪ int mileage: An integer representing the vehicle's mileage in kilometers
at the time of service.
▪ int nextServiceMileage: An integer representing the mileage in
kilometers at which the next service is due.

2
2. SensorsData Structure
• This structure captures various sensor readings that reflect the vehicle's
current performance.

• Members:
▪ float engineTemperature: A floating-point value representing the engine
temperature in degrees Celsius.
▪ float oilPressure: A floating-point value representing the oil pressure in
PSI.
▪ float tirePressure: A floating-point value representing the tire pressure in
PSI.
▪ float batteryVoltage: A floating-point value representing the battery
voltage in volts.

Function Definitions
1. int main(void)
• Purpose: Serves as the entry point of the program. It continuously calls the
displayMenu function to keep printing the options for the user to choose
from them. It also takes a character from the user and depending on this
character it chooses which option to do from the menu options. The menu
loop continues until the user decides to exit the program.

2. void displayMenu (void)


• Purpose: Displays the main menu options to the user.
• Menu Options:

a ➔ Add Maintenance Record b ➔ Display Maintenance History

c ➔ Calculate Next Service d ➔ Input Sensor Data

f ➔ Analyze Sensor Data e ➔ Exit

3
3. void addMaintenanceRecord (struct MaintenanceRecord maintenances[], int*
numberOfMaintenanceRecords)
• Purpose: Allows users to add a new maintenance record to the system.
• Inputs:
▪ maintenances []: An array of MaintenanceRecord structures where the
new record structure will be stored.
▪ *numberOfMaintenanceRecords: A pointer to the integer tracking the
current count of maintenance records as it will edit in the original count
of maintenance records to keep track of them, so it needs to be passed
by reference.
• Outputs: Prompts the user for details of the new maintenance record as it
takes from the user:

serviceType: Can be Oil Change, Tire Rotation, Battery Check, General


Inspection, Air Filter Change, Brake Check, Engine Maintenance.

date: must be in the format of “DD/MM/YYYY”.

mileage: represents the kilometers recorded now at the time the


maintenance is finished.

nextServiceMileage: It is not taken from the user as input in this


function as it is calculated in a separate function according to each
serviceType.

After taking these inputs it stores the new record in the array and
displays a success message for adding a new maintenance record.

4. void displayMaintenanceHistory (struct MaintenanceRecord maintenances[],


int numberOfMaintenanceRecords)
• Purpose: Displays the history of maintenance records stored in the array of
structures of the MaintenanceRecord to the user.
• Inputs:
▪ maintenances []: An array of MaintenanceRecord structures.
▪ numberOfMaintenanceRecords: The current count of maintenance
records.
• Outputs: Prints each maintenance record's details after calculating the next
service mileage to the console or notifies the user if there are no records.

4
5. void calculateNextService (struct MaintenanceRecord maintenances[], int
numberOfMaintenanceRecords)
• Purpose: Calculates and displays the next service due for each maintenance
record based on predefined mileage intervals specifically for each
serviceType of Maintenance.
• Inputs:
▪ maintenances []: An array of MaintenanceRecord structures.
▪ numberOfMaintenanceRecords: The current count of maintenance
records.
• Outputs: Calculates and displays the next maintenance mileage for each
service type according to each allowed interval for each service type.
• Allowed Intervals:

Oil changes every 8000 km

Tire rotation every 10000 km

Battery checks every 15000 km

General inspection every 20000 km

Air filters change every 12000 km

Brake checks every 15000 km

Engine maintenance every 30000 km

6. void inputSensorData (struct SensorsData sensors[], int*


numberOfSensorReadings)
• Purpose: Allows users to input sensor readings for the vehicle.
• Inputs:
▪ sensors []: An array of SensorsData structures where the new readings
will be stored.
▪ *numberOfSensorReadings: A pointer to the integer tracking the
current count of number of sensor readings.
• Outputs: Prompts the user for sensor data as it takes from the user:
engineTemperature, oilPressure, tirePressure, batteryVoltage as if it has
read it from the vehicle sensors, stores them and displays a success
message that a new sensors readings is added.
5
7. void analyzeSensorData (struct SensorsData sensors[], int
numberOfSensorReadings)
• Purpose: This function analyzes the most recent sensor readings, which
include engine temperature, oil pressure, tire pressure, and battery voltage,
to identify any conditions that may require maintenance or attention.
• Inputs:
▪ sensors []: An array of SensorsData structures containing the sensor
readings.
▪ numberOfSensorReadings: The current count of sensor readings.
• Outputs: It first checks if there are any sensor readings to analyze. If not, it
notifies the user and exits. It iterates through the provided sensor readings
and displays each reading with formatted output. It checks for critical
thresholds for engine temperature, oil pressure, tire pressure, and battery
voltage, issuing warnings if any values exceed or fall below specified limits.
• Limits:

engineTemperature remains below 100

oilPressure remains above 20

tirePressure remains above 30

batteryVoltage remains above 12

Thank You
Edges For Training Team

You might also like