Hotfixes
Passing array of possible faulty sensors
This commit is contained in:
parent
767835c62c
commit
6aec8d0d45
@ -8,7 +8,7 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
float mean;
|
float mean;
|
||||||
float standardDeviation;
|
float standardDeviation;
|
||||||
bool *possibleFaultySensor;
|
int *possibleFaultySensor;
|
||||||
} Metrics;
|
} Metrics;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
@ -442,12 +442,10 @@ Metrics getMetrics(float **readings, int sensorNumber, int slidingWindow)
|
|||||||
float standardDeviation = 0;
|
float standardDeviation = 0;
|
||||||
int outlierCount = 0;
|
int outlierCount = 0;
|
||||||
int *faultySensors = (int *)malloc(sensorNumber * sizeof(int));
|
int *faultySensors = (int *)malloc(sensorNumber * sizeof(int));
|
||||||
bool *possiblyFaultySensors = (bool *)malloc(sensorNumber * sizeof(bool));
|
|
||||||
|
|
||||||
for (int i = 0; i < sensorNumber; i++)
|
for (int i = 0; i < sensorNumber; i++)
|
||||||
{
|
{
|
||||||
faultySensors[i] = 0;
|
faultySensors[i] = 0;
|
||||||
possiblyFaultySensors[i] = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float sum = 0;
|
float sum = 0;
|
||||||
@ -483,11 +481,23 @@ Metrics getMetrics(float **readings, int sensorNumber, int slidingWindow)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < sensorNumber; i++)
|
int faultySensorsCount = 0;
|
||||||
|
for(int i = 0; i < sensorNumber; i++)
|
||||||
|
{
|
||||||
|
if(faultySensors[i] >= 0.001 * slidingWindow)
|
||||||
|
{
|
||||||
|
faultySensorsCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int *possiblyFaultySensors = (int *)malloc(faultySensorsCount * sizeof(int));
|
||||||
|
|
||||||
|
int j = 0;
|
||||||
|
for (int i = 0; i < faultySensorsCount; i++)
|
||||||
{
|
{
|
||||||
if (faultySensors[i] >= 0.001 * slidingWindow)
|
if (faultySensors[i] >= 0.001 * slidingWindow)
|
||||||
{
|
{
|
||||||
possiblyFaultySensors[i] = true;
|
possiblyFaultySensors[j] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user