summaryrefslogtreecommitdiff
path: root/ebus-racket/layer7.rkt
diff options
context:
space:
mode:
Diffstat (limited to 'ebus-racket/layer7.rkt')
-rw-r--r--ebus-racket/layer7.rkt26
1 files changed, 26 insertions, 0 deletions
diff --git a/ebus-racket/layer7.rkt b/ebus-racket/layer7.rkt
new file mode 100644
index 0000000..5b8f496
--- /dev/null
+++ b/ebus-racket/layer7.rkt
@@ -0,0 +1,26 @@
+#lang racket
+(require (planet lizorkin/sxml:2:1/sxml))
+(require (planet lizorkin/ssax:2:0/ssax))
+
+(define definition
+ (ssax:xml->sxml (open-input-file "../ebus-xml/ebus.xml")
+ '[(#f . "http://xapek.org/ebus/0.1")]))
+
+
+(define (ebus-paket primaryCommand secondaryCommand)
+ ((sxpath (string-append "//packet[@primary=" (number->string primaryCommand)
+ " and @secondary=" (number->string secondaryCommand) "]"))
+ definition))
+
+;; returns the full device-definition
+(define (device address)
+ ((sxpath (string-append "//devices/device[@address=" (number->string address) "]"))
+ definition))
+
+;; returns device-name in a list or empty-list
+(define (device-name address)
+ ((sxpath "@name/text()") (device address)))
+
+(provide (prefix-out layer7- ebus-paket)
+ (prefix-out layer7- device)
+ (prefix-out layer7- device-name)) \ No newline at end of file