summaryrefslogtreecommitdiff
path: root/ebus-racket/inserter.rkt
diff options
context:
space:
mode:
authorEbus-at-dockstar <ebus@dockstar>2014-09-16 01:36:38 +0200
committerEbus-at-dockstar <ebus@dockstar>2014-09-16 01:41:16 +0200
commitf3295bd150079984d115faad0a5a9de10c6d6de0 (patch)
treea4825033c7a3bbe92d83502f571ba88fc5a30288 /ebus-racket/inserter.rkt
parentf7f2f4a611f15d98d8e33241dc65d5cbfe7ff03b (diff)
downloadebus-alt-f3295bd150079984d115faad0a5a9de10c6d6de0.tar.gz
ebus-alt-f3295bd150079984d115faad0a5a9de10c6d6de0.zip
ersatzwerte
Diffstat (limited to 'ebus-racket/inserter.rkt')
-rwxr-xr-xebus-racket/inserter.rkt29
1 files changed, 16 insertions, 13 deletions
diff --git a/ebus-racket/inserter.rkt b/ebus-racket/inserter.rkt
index d72d2ea..b234ad9 100755
--- a/ebus-racket/inserter.rkt
+++ b/ebus-racket/inserter.rkt
@@ -19,19 +19,22 @@
;; Send field and value to database server
(define (insert-field sensor-name datatype value)
- (define url (format "~a/~a" (baseurl?) sensor-name))
- (define raw-value
- (cond ((member datatype '(data1c data2b data2c)) (real->decimal-string value))
- ((member datatype '(bit byte data1b word bcd)) (format "~s" value))
- ((member datatype '(byteEnum)) value)
- (else (error 'invalid-datatype))))
- (define input-port (put-impure-port (string->url url) (string->bytes/utf-8 raw-value)))
- (define server-response (read-line input-port))
- (close-input-port input-port)
- (cond ((string=? (list-ref (string-split server-response) 1) "200")
- (log-inserter-info "OK: ~a : ~a" url raw-value))
- (else
- (error "server-error" url raw-value server-response))))
+ (if (layer7-ersatzwert? value)
+ (log-inserter-info "Skipping Ersatzwert for ~a/~a" sensor-name datatype)
+ (let ()
+ (define url (format "~a/~a" (baseurl?) sensor-name))
+ (define raw-value
+ (cond ((member datatype '(data1c data2b data2c)) (real->decimal-string value))
+ ((member datatype '(bit byte data1b word bcd)) (format "~s" value))
+ ((member datatype '(byteEnum)) value)
+ (else (error 'invalid-datatype))))
+ (define input-port (put-impure-port (string->url url) (string->bytes/utf-8 raw-value)))
+ (define server-response (read-line input-port))
+ (close-input-port input-port)
+ (cond ((string=? (list-ref (string-split server-response) 1) "200")
+ (log-inserter-info "OK: ~a : ~a" url raw-value))
+ (else
+ (error "server-error" url raw-value server-response))))))
(define (handle-packet packet)
(for ([field packet])