add bool in code

This commit is contained in:
quentin.perret 2022-06-09 17:56:45 +02:00
parent 446d3b5fd7
commit 46e02c1d6d
9 changed files with 15 additions and 32 deletions

5
Code-C/.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,5 @@
{
"files.associations": {
"power.h": "c"
}
}

View file

@ -57,11 +57,11 @@ void printArrayData(long** p, int N, int M) {
* @param M * @param M
* @return int * @return int
*/ */
int checkArrayFullyFill(long **p, int N , int M){ bool checkArrayFullyFill(long **p, int N , int M){
for(int i = 0 ; i < N ; i++){ for(int i = 0 ; i < N ; i++){
if(p[i][0] == '\0'){ return 1; } if(p[i][0] == '\0'){ return false; }
} }
return 0; return true;
} }
void freeArray(long **p, int N) { void freeArray(long **p, int N) {

View file

@ -2,9 +2,10 @@
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <inttypes.h> #include <inttypes.h>
long **getRawDataArray(); long **getRawDataArray();
void printArrayData(long** p, int N, int M); void printArrayData(long** p, int N, int M);
void freeArray(long **p, int N); void freeArray(long **p, int N);
int checkArrayFullyFill(long **p, int N , int M); bool checkArrayFullyFill(long **p, int N , int M);

BIN
Code-C/main Executable file

Binary file not shown.

View file

@ -21,5 +21,5 @@ int main(int argc , char** argv){
pthread_t rawData; pthread_t rawData;
pthread_create(&rawData , NULL, simulateFlux, (void *)&rawData); pthread_create(&rawData , NULL, simulateFlux, (void *)&rawData);
pthread_exit(NULL); pthread_exit(NULL);
while(power(nRow,nCol,period,invTimeBandWidth)==0){} while(power(nRow,nCol,period,invTimeBandWidth)){}
} }

View file

@ -16,17 +16,16 @@ void powerCalculation(long **p, double powerArray[] , int N, int M , double peri
//printf("%f\n", powerArray[i]); //printf("%f\n", powerArray[i]);
} }
} }
int power(int N , int M, double periode , double invTimeBandwidth){ bool power(int N , int M, double periode , double invTimeBandwidth){
long **p = getRawDataArray(N, M); long **p = getRawDataArray(N, M);
//printArrayData(p,N,M);
double pw[8]; double pw[8];
if(p !=NULL){ if(p !=NULL){
powerCalculation(p,pw,N,M,periode,invTimeBandwidth); powerCalculation(p,pw,N,M,periode,invTimeBandwidth);
writePowerData(pw,8); writePowerData(pw,8);
freeArray(p,N); freeArray(p,N);
return 0; return true;
} }
else{ else{
return 1; return false;
} }
} }

View file

@ -1,3 +1,4 @@
#include <math.h> #include <math.h>
#include <stdbool.h>
int power(int N , int M, double periode , double timeBandwidth); int power(int N , int M, double periode , double timeBandwidth);

View file

@ -1,24 +1,8 @@
#include "simulateFlux.h" #include "simulateFlux.h"
#include "initialParameters.h" #include "initialParameters.h"
typedef struct {
char *fileName;
} nameFill;
typedef struct {
nameFill curentFile;
nameFill *nextFile;
}rawDataFile;
nameFill getNameFill(int N){
nameFill file;
file.fileName = (char *) malloc(N*sizeof(char *));
return file;
}
int cptData = 0; int cptData = 0;
int cptFile = 1; int cptFile = 1;
nameFill FirstFile;
char* convertIntegerToChar(int N) char* convertIntegerToChar(int N)
{ {

View file

@ -13,12 +13,5 @@ typedef struct {
uint8_t octet4; uint8_t octet4;
} quartet; } quartet;
extern struct nameFill;
extern struct rawDataFile;
nameFill getNameFill(int N);
bool writeOneRawData(FILE *f); bool writeOneRawData(FILE *f);
void *simulateFlux(void *vargp); void *simulateFlux(void *vargp);