Hotfixes
This commit is contained in:
parent
eb76c2e4c7
commit
4a97a81d7a
@ -5,25 +5,14 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
// Struttura per la gestione dei dati di acquisizione
|
|
||||||
typedef struct {
|
|
||||||
int sensorsNumber;
|
|
||||||
int slidingWindowSize;
|
|
||||||
} dataAcquisition;
|
|
||||||
|
|
||||||
// Funzioni per la gestione dei dati di acquisizione
|
|
||||||
void initializeReadings();
|
void initializeReadings();
|
||||||
void freeReadings();
|
void freeReadings();
|
||||||
|
|
||||||
// Funzioni getter
|
|
||||||
int getSensorsNumber();
|
int getSensorsNumber();
|
||||||
int getSlidingWindowSize();
|
int getSlidingWindowSize();
|
||||||
bool isFull(int sensorIndex);
|
bool isFull(int sensorIndex);
|
||||||
|
|
||||||
// Funzioni setter
|
|
||||||
void addReading(float value, int sensorIndex);
|
void addReading(float value, int sensorIndex);
|
||||||
void setSensorsNumber(int number);
|
|
||||||
void setSlidingWindowSize(int size);
|
|
||||||
|
|
||||||
float getAverageOnSensor(int sensorIndex);
|
float getAverageOnSensor(int sensorIndex);
|
||||||
float getAverageOnAllSensors();
|
float getAverageOnAllSensors();
|
||||||
|
|||||||
@ -4,11 +4,19 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
// Variable definition
|
// Variable definition
|
||||||
|
|
||||||
static float **readings;
|
static float **readings;
|
||||||
|
static int sensorsNumber;
|
||||||
|
static int slidingWindowSize;
|
||||||
|
|
||||||
|
|
||||||
|
static void setSensorsNumber(int number) {
|
||||||
|
sensorsNumber = number;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setSlidingWindowSize(int size) {
|
||||||
|
slidingWindowSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
int sensorsNumber;
|
|
||||||
int slidingWindowSize;
|
|
||||||
void initializeReadings(int numSensors, int windowSize) {
|
void initializeReadings(int numSensors, int windowSize) {
|
||||||
readings = (float **)malloc(numSensors * sizeof(float *));
|
readings = (float **)malloc(numSensors * sizeof(float *));
|
||||||
if (readings == NULL) {
|
if (readings == NULL) {
|
||||||
@ -22,7 +30,7 @@ void initializeReadings(int numSensors, int windowSize) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Assign sensorsNumber and slidingWindowSize
|
// Chiamate private ai setter
|
||||||
setSensorsNumber(numSensors);
|
setSensorsNumber(numSensors);
|
||||||
setSlidingWindowSize(windowSize);
|
setSlidingWindowSize(windowSize);
|
||||||
}
|
}
|
||||||
@ -34,13 +42,6 @@ void freeReadings() {
|
|||||||
free(readings);
|
free(readings);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int sensorsNumber;
|
|
||||||
int slidingWindowSize;
|
|
||||||
} dataAcquisition;
|
|
||||||
|
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
|
|
||||||
// Get the number of sensors
|
// Get the number of sensors
|
||||||
@ -53,16 +54,6 @@ int getSlidingWindowSize() {
|
|||||||
return slidingWindowSize;
|
return slidingWindowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the number of sensors
|
|
||||||
void setSensorsNumber(int number) {
|
|
||||||
sensorsNumber = number;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the sliding window size
|
|
||||||
void setSlidingWindowSize(int size) {
|
|
||||||
slidingWindowSize = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Control on the fullness of the sliding window
|
// Control on the fullness of the sliding window
|
||||||
bool isFull(int sensorIndex) {
|
bool isFull(int sensorIndex) {
|
||||||
for (int i = 0; i < slidingWindowSize; i++) {
|
for (int i = 0; i < slidingWindowSize; i++) {
|
||||||
|
|||||||
@ -11,7 +11,6 @@ void test_initializeReadings() {
|
|||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
printf("Running tests...\n");
|
|
||||||
test_initializeReadings();
|
test_initializeReadings();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user