-
Notifications
You must be signed in to change notification settings - Fork 0
/
engineTemperature.h
38 lines (37 loc) · 1.03 KB
/
engineTemperature.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdlib.h>
void *engineTemperatureThreadExecute(void *vargp)
{
int failureCount = 0;
_Bool success = 0;
while (1)
{
float prevEngineTemperature = 0;
success = simulateExecution(ENGINE_TEMPERATURE_SENSOR_EXECUTION, ENGINE_TEMPERATURE_FAILURE_CHANCE);
if (!success)
{
if (failureCount > 2)
{
systemStatus.lamp.engineTemperature = 1;
}
else
{
failureCount++;
}
}
else
{
failureCount = 0;
engineTemperatureSpeed = systemStatus.dial.engineTemperature - prevEngineTemperature;
if (systemStatus.dial.engineTemperature > MAX_ENGINE_TEMPERATURE)
{
systemStatus.lamp.engineTemperature = 1;
}
else
{
systemStatus.lamp.engineTemperature = 0;
}
}
prevEngineTemperature = systemStatus.dial.engineTemperature;
sleep(1);
}
}