summaryrefslogtreecommitdiff
path: root/test.r
diff options
context:
space:
mode:
authorRandom Hacker <random_hacker@xapek.org>2010-08-29 23:16:50 +0200
committerRandom Hacker <random_hacker@xapek.org>2010-08-29 23:16:50 +0200
commit1e369ca9a29dec3f46d4cd50a7149c883be3f464 (patch)
tree33c33a9e7566409c4a2f1c82b0aa3482894a21b6 /test.r
parent5977f2abbf9cced7fb3db199a985ab7a3777ab4c (diff)
downloadebus-alt-1e369ca9a29dec3f46d4cd50a7149c883be3f464.tar.gz
ebus-alt-1e369ca9a29dec3f46d4cd50a7149c883be3f464.zip
bla
Diffstat (limited to 'test.r')
-rwxr-xr-xtest.r43
1 files changed, 29 insertions, 14 deletions
diff --git a/test.r b/test.r
index 4c5bda7..117e7b6 100755
--- a/test.r
+++ b/test.r
@@ -1,6 +1,6 @@
#!/usr/bin/Rscript --vanilla
require(RPostgreSQL)
-##nulltime <- strptime("01.01.1970", "%d.%m.%Y")
+nulltime <- strptime("01.01.1970", "%d.%m.%Y")
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, host="10.2.2.22", user="jack", password="jack", dbname="ebus")
@@ -11,17 +11,26 @@ png(file = "Rplots.png", width=1000, height=800)
cat("Starte Abfragen\n")
brenner <- dbGetQuery(con,
- paste("SELECT timestamp
+ paste("SELECT timestamp as \"time\"
, value_string
FROM value
WHERE sensor_id IN (select id from sensor where name = 'heizkreisregler1.betriebsdatenFeuerungsautomat.betriebszustand')
AND date_trunc('day',timestamp) = date_trunc('day',now())
- ORDER BY timestamp desc", sep=""))
-
-## Brennerstatus auf Brennerstatusänderungen reduzieren
-brenner <- aggregate(brenner$timestamp,
- list(value_string=brenner$value_string),
- min)
+ ORDER BY timestamp asc", sep=""))
+
+## Brennerstatus auf Brennerstaotusänderungen reduzieren
+
+brennerBla <- table(NULL,NULL)
+liste <- c()
+old_value_string <- "bla"
+for (i in seq(1,nrow(brenner))) {
+ if (brenner$value_string[i] != old_value_string) {
+ old_value_string <- brenner$value_string[i]
+ brennerBla <- rbind(brennerBla, data.frame(time=brenner$time[i], value_string=brenner$value_string[i]))
+ }
+}
+print(brennerBla)
+brenner <- brennerBla
readNumericSensorDay <- function (sensorName) {
d <- dbGetQuery(con,
@@ -45,9 +54,14 @@ mymerge <- function (a,...,all.x=TRUE) {
}
}
-kollektor <- readNumericSensorDay("heizkreisregler9.solarDaten.tempKollektor")
warmwasser <- readNumericSensorDay("heizkreisregler9.solarDaten.tempWarmwasserSolar")
kessel <- readNumericSensorDay("heizkreisregler10.betriebsdatenRegler1.kesselTemperatur")
+kollektor <- readNumericSensorDay("heizkreisregler9.solarDaten.tempKollektor")
+names_kollektor <- names(kollektor)
+kollektor <- supsmu(kollektor$time,kollektor$heizkreisregler9.solarDaten.tempKollektor)
+names(kollektor) <- names_kollektor
+print(kollektor$time)
+# -- TODO ausreißer als punkte darstellen
data <- mymerge(kollektor, kessel, warmwasser)
cat("Plotte\n")
@@ -63,19 +77,20 @@ lines(data$time, data$heizkreisregler9.solarDaten.tempKollektor, col="blue")
box()
-for (i in c(1:dim(brenner)[2])) {
- text(brenner$x[i], max(data[2:length(data)])/2, paste("ab hier", brenner$value_string[i]) ,srt=90)
+for (i in c(1:nrow(brenner))) {
+ print(brenner$time[i])
+ print(brenner$value_string[i])
+ text(as.numeric(brenner$time[i])+7200, max(data[2:length(data)],na.rm=TRUE)/2, paste("ab hier", brenner$value_string[i]) ,srt=90)
}
-
-r <- as.POSIXct(range(data$time),tz="GMT")
+r <- as.POSIXct(range(data$time))
s <- round.POSIXt(seq(r[1], r[2], by=60*60),"hour")
axis.POSIXct(1, at=s, format="%H:%M")
r <- range(data[2:length(data)], na.rm=TRUE)
s <- seq(r[1], r[2], by=(r[2]-r[1])/8)
axis(2, at=s, labels=paste(round(s,1),"°C"))
-legend('topleft', legend=c('Kollektor', 'Warmwasser', 'Kessel'), fill=c('red', 'orange', 'blue'))
+legend('topleft', legend=c('Kessel', 'Warmwasser', 'Kollektor'), fill=c('red', 'orange', 'blue'))
title("Temperaturen")
dev.off()