summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandom Hacker <random_hacker@xapek.org>2010-08-31 23:53:21 +0200
committerRandom Hacker <random_hacker@xapek.org>2010-08-31 23:53:21 +0200
commit228431a46a863c104b5603a498665b012e9ea6c5 (patch)
tree44532e8af37cc4ff29ac6e8cd38f033dae4edfae
parent409b35be5310eb96d4364ba2bf5836661f9724c6 (diff)
downloadebus-alt-228431a46a863c104b5603a498665b012e9ea6c5.tar.gz
ebus-alt-228431a46a863c104b5603a498665b012e9ea6c5.zip
added Solar Pumpe, fix false values in read numeric by -50 < x < 200
-rwxr-xr-xtest.r32
1 files changed, 32 insertions, 0 deletions
diff --git a/test.r b/test.r
index 41a4b85..303a71f 100755
--- a/test.r
+++ b/test.r
@@ -32,6 +32,30 @@ for (i in seq(1,nrow(brenner))) {
}
brenner <- brennerBla
+# Solar Pumpe
+solarEngine <- dbGetQuery(con,
+ paste("SELECT timestamp as \"time\",
+ value_int
+ FROM value
+ WHERE sensor_id IN (select id from sensor where name = 'heizkreisregler9.solarDaten.solarPumpe')
+ AND timestamp > now() - interval '1 day'
+ AND value_int IS NOT NULL
+ ORDER BY timestamp asc", sep=""))
+# reduzieren
+solarEngineNew <- table(NULL,NULL)
+emptyList <- c()
+old_value_int <- "blub"
+for (i in seq(1,nrow(solarEngine))) {
+ if (solarEngine$value_int[i] != old_value_int) {
+ old_value_int <- solarEngine$value_int[i]
+ solarEngineNew <- rbind(solarEngineNew, data.frame(time=solarEngine$time[i], value_int=solarEngine$value_int[i]))
+ }
+}
+solarEngine <- solarEngineNew
+
+print(solarEngine)
+
+# Numerische Sensoren Lesen
readNumericSensorDay <- function (sensorName) {
d <- dbGetQuery(con,
paste("SELECT timestamp",
@@ -39,6 +63,9 @@ readNumericSensorDay <- function (sensorName) {
" FROM value",
" WHERE sensor_id IN (select id from sensor where name = '",sensorName,"')",
" AND timestamp > now() - interval '1 day'",
+ # ausreißer ausblenden
+ " AND COALESCE(value_int,value_float) < 200",
+ " AND COALESCE(value_int,value_float) > -50",
" ORDER BY timestamp desc", sep=""))
d$timestamp <- as.POSIXct(round(d$timestamp, "mins"))
#d <- supsmu(as.vector(d$timestamp), as.vector(d$value))
@@ -88,6 +115,11 @@ for (i in c(1:nrow(brenner))) {
text(as.numeric(brenner$time[i]), max(data[2:length(data)],na.rm=TRUE)/2, paste("ab hier", brenner$value_string[i]) ,srt=90)
}
+# quick and dirty add solarEngine to plot
+for (i in c(1:nrow(solarEngine))) {
+ text(as.numeric(solarEngine$time[i]), max(data[2:length(data)],na.rm=TRUE)/2, paste("Solar Pumpe", solarEngine$value_int[i]), srt=90)
+}
+
rangeX <- as.POSIXct(range(data$time))
s <- round.POSIXt(seq(rangeX[1], rangeX[2], by=60*60),"hour")
axis.POSIXct(1, at=s, format="%H:%M")