From 36f42916cadd07bba5d0812566fba4546641cde9 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Sun, 26 Feb 2012 19:49:39 +0100 Subject: ebus-racked: rename to layer2-/layer7- --- ebus-racket/layer7.rkt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ebus-racket/layer7.rkt (limited to 'ebus-racket/layer7.rkt') 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 -- cgit v1.2.1