summaryrefslogtreecommitdiff
path: root/ebus-racket/layer7.rkt
blob: 5b8f496b1f4e2313dd50083ec2b4f26ac33a689c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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))