Commit df83be7a authored by jlopez's avatar jlopez
Browse files

Fix parsing and plot

parent 2050ffee
......@@ -129,6 +129,10 @@ void CPPparseAcceleration(std::string data_path, std::string output_path, String
}
}
if(size == 1) {
exact = false;
}
if(exact) {
//Parse date
......@@ -153,6 +157,12 @@ void CPPparseAcceleration(std::string data_path, std::string output_path, String
}
}
if(mandrill_uuid.size() == 1) {
if(mandrill_uuid[0] == "") {
find = true;
}
}
int sizeAcceleration = std::stoi(vline[19]);
if(sizeAcceleration <= 100) {
......@@ -245,6 +255,10 @@ void CPPparseMouvement(std::string data_path, std::string output_path, StringVec
}
}
if(size == 1) {
exact = false;
}
if(exact) {
//Parse date
......@@ -269,6 +283,12 @@ void CPPparseMouvement(std::string data_path, std::string output_path, StringVec
}
}
if(mandrill_uuid.size() == 1) {
if(mandrill_uuid[0] == "") {
find = true;
}
}
int sizeMouvement = std::stoi(vline[19]);
if(sizeMouvement <= 100) {
......@@ -351,9 +371,15 @@ void CPPparseTemperature(std::string data_path, std::string output_path, StringV
}
}
if(size == 1) {
exact = false;
}
if(exact) {
//std::cout << "ok" << std::endl;
//Parse date
std::string sdate = vline[0];
std::vector<string> dline = split(line, " ");
......@@ -368,6 +394,8 @@ void CPPparseTemperature(std::string data_path, std::string output_path, StringV
//Parse uuid
std::string uuid = vline[3];
//std::cout << uuid << std::endl;
bool find = false;
for(int i=0; i < mandrill_uuid.size(); i++){
......@@ -376,7 +404,15 @@ void CPPparseTemperature(std::string data_path, std::string output_path, StringV
}
}
if(mandrill_uuid.size() == 1) {
if(mandrill_uuid[0] == "") {
find = true;
}
}
if(find) {
//std::cout << "find" << std::endl;
//Parse temperature
int df1 = std::stoi(vline[22]);
......
......@@ -11,7 +11,7 @@ sourceCpp("exstract.cpp")
# GLOBAL VARIABLE
#--------------------------------------------------
root_path <- "./data/2018-11-26au02"
root_path <- "./data/2018-11-26au02/"
# Le range de départ de la période à extraire
timeS <- "2018-11-26 12:00:00"
......@@ -20,18 +20,19 @@ timeS <- "2018-11-26 12:00:00"
timeE <- "2018-11-27 11:59:59"
# Si vide alors pas de range
# timeS <- ""
# timeE <- ""
#timeS <- ""
#timeE <- ""
# Les uuid des mandrill ici 1 mandrill
#mandrill_uuid <- c("32-38-31-39-58-36-8e-0c")
mandrill_uuid <- c("32-38-31-39-58-36-8e-0c")
# ici avec 2 mandrills
#mandrill_uuid <- c("32-38-31-39-58-36-8e-0c", "32-38-31-39-62-36-8f-0c")
mandrill_uuid <- c("32-38-31-39-62-36-8f-0c")
# Si le vecteur est vide cela signifie qu'on ne prend aucun mandrills
#mandrill_uuid <- c("32-38-31-39-62-36-8f-0c")
# Si le vecteur est vide comme ceci cela signifie qu'on ne prend aucun mandrills
#mandrill_uuid <- c("32-38-31-39-5e-36-8d-0c", "32-38-31-39-66-36-73-0c","32-38-31-39-66-36-7f-0c")
#mandrill_uuid <- c("")
#--------------------------------------------------
# Temperature mandrill
......@@ -40,6 +41,9 @@ path_temperature <- paste0(root_path, "/logLoRaTemp.csv")
preTraitementTemperature(root_path, path_temperature, mandrill_uuid, timeS, timeE)
mandrill_temperature <- readCSVTemperature(paste0(root_path, "/temperature.csv"))
#if you don't have extern temp
#extTemperature <- data.frame(date=as.character(), uuid=as.character(), temperature=as.numeric())
extTemperature <- extractExtTemperature(paste0(root_path, "/temperature_ext.xlsx"), timeS, timeE)
......@@ -47,26 +51,33 @@ minT <- min(mandrill_temperature$temperature, extTemperature$temperature)
maxT <- max(mandrill_temperature$temperature, extTemperature$temperature)
minD <- min(mandrill_temperature$date)
maxD <- max(mandrill_temperature$date)
uuid <- unique(mandrill_temperature$uuid)
color_mandrill <- distinctColorPalette(length(uuid)+1)
color_mandrill <- distinctColorPalette(length(uuid))
if(length(uuid) == 1) {
color_mandrill[1] <- "blue"
}
color_mandrill[1] <- "blue"
mandrill <- filter(mandrill_temperature, uuid == uuid[1])
plot(mandrill$date,mandrill$temperature,type="l", col="blue", ylim=c(minT, maxT), main="Temperature")
plot(mandrill$date,mandrill$temperature,type="l", col=color_mandrill[1], xlim = c(minD, maxD), ylim=c(minT, maxT), main="Temperature",lwd = 2)
if(length(uuid) > 1) {
for(index in c(2:length(uuid))) {
mandrill <- filter(mandrill_temperature, uuid == uuid[index])
lines(mandrill$date,mandrill$temperature, col=color_mandrill[index])
lines(mandrill$date,mandrill$temperature, col=color_mandrill[index],lwd = 2)
}
}
lines(extTemperature$date,extTemperature$temperature, col="red")
#legend("topleft", legend = uuid, col = color_mandrill, lty = 1, cex = 0.8)
#lines(extTemperature$date,extTemperature$temperature, col="red")
#abline(h=mean(mandrill_temperature$temperature), col="blue")
#abline(h=mean(extTemperature$temperature), col="red")
#--------------------------------------------------
# Mouvement & Acceleration mandrill
......@@ -86,6 +97,10 @@ minMA <- 0
maxMA <- 255
minD <- min(mandrill_mouvement$date, mandrill_acceleration$date)
maxD <- max(mandrill_mouvement$date, mandrill_acceleration$date)
color_mandrill <- distinctColorPalette(length(uuid)+1)
# Position X
......@@ -93,9 +108,9 @@ color_mandrill <- distinctColorPalette(length(uuid)+1)
mandrillM <- filter(mandrill_mouvement, uuid == uuid[1])
mandrillA <- filter(mandrill_acceleration, uuid == uuid[1])
par(mfrow=c(2,1))
plot(mandrillM$date,mandrillM$mouvement,type="l", col="purple", ylim=c(minMA, maxMA), main="Mouvement")
plot(mandrillM$date,mandrillM$mouvement,type="l", col="purple", xlim = c(minD, maxD), ylim=c(minMA, maxMA), main="Mouvement")
if(nrow(mandrill_acceleration) > 0) {
plot(mandrillA$date,mandrillA$x,type="l", col="blue", ylim=c(minMA, maxMA), main="Acceleration X")
plot(mandrillA$date,mandrillA$x,type="l", col="blue", xlim = c(minD, maxD), ylim=c(minMA, maxMA), main="Acceleration X")
}
# Position Y
......@@ -103,9 +118,9 @@ if(nrow(mandrill_acceleration) > 0) {
mandrillM <- filter(mandrill_mouvement, uuid == uuid[1])
mandrillA <- filter(mandrill_acceleration, uuid == uuid[1])
par(mfrow=c(2,1))
plot(mandrillM$date,mandrillM$mouvement,type="l", col="purple", ylim=c(minMA, maxMA), main="Mouvement")
plot(mandrillM$date,mandrillM$mouvement,type="l", col="purple", xlim = c(minD, maxD), ylim=c(minMA, maxMA), main="Mouvement")
if(nrow(mandrill_acceleration) > 0) {
plot(mandrillA$date,mandrillA$y,type="l", col="red", ylim=c(minMA, maxMA), main="Acceleration Y")
plot(mandrillA$date,mandrillA$y,type="l", col="red", xlim = c(minD, maxD), ylim=c(minMA, maxMA), main="Acceleration Y")
}
# Position Z
......@@ -113,8 +128,8 @@ if(nrow(mandrill_acceleration) > 0) {
mandrillM <- filter(mandrill_mouvement, uuid == uuid[1])
mandrillA <- filter(mandrill_acceleration, uuid == uuid[1])
par(mfrow=c(2,1))
plot(mandrillM$date,mandrillM$mouvement,type="l", col="purple", ylim=c(minMA, maxMA), main="Mouvement")
plot(mandrillM$date,mandrillM$mouvement,type="l", col="purple", xlim = c(minD, maxD), ylim=c(minMA, maxMA), main="Mouvement")
if(nrow(mandrill_acceleration) > 0) {
plot(mandrillA$date,mandrillA$z,type="l", col="green", ylim=c(minMA, maxMA), main="Acceleration Z")
plot(mandrillA$date,mandrillA$z,type="l", col="green", xlim = c(minD, maxD), ylim=c(minMA, maxMA), main="Acceleration Z")
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment