summaryrefslogtreecommitdiff
path: root/guile/nanolight/state.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guile/nanolight/state.scm')
-rw-r--r--guile/nanolight/state.scm36
1 files changed, 28 insertions, 8 deletions
diff --git a/guile/nanolight/state.scm b/guile/nanolight/state.scm
index 405a19c..8237d6e 100644
--- a/guile/nanolight/state.scm
+++ b/guile/nanolight/state.scm
@@ -1,6 +1,6 @@
(define-module (nanolight state)
#:use-module (oop goops)
- #:export (print-state define-state
+ #:export (print-state define-state exec-state
merge-states merge-rule-htp merge-rule-ltp
merge-htp merge-ltp
int flash pan tilt
@@ -97,16 +97,36 @@
'() (apply append list-of-states)))
-(define (compare-addr a b)
- (or
- (< (get-universe (fixture a)) (get-universe (fixture b)))
- (and
- (eq? (get-universe (fixture a)) (get-universe (fixture b)))
- (< (get-start-addr (fixture a)) (get-start-addr (fixture b))))))
+(define (find-attribute fix attr)
+ (find (lambda (a)
+ (eq? (name a) attr))
+ (attributes fix)))
+
+
+; Execute the state, i.e. apply it to the physical lighting rig
+(define (exec-state state)
+ (for-each
+ (lambda (a)
+ (assign-attr!
+ (fixture a)
+ (attribute a)
+ (value-func a)))
+ state))
(define (sort-by-dmx-addr state)
- (stable-sort state compare-addr))
+ (stable-sort state (lambda (a b)
+ (or
+ (<
+ (get-universe (fixture a))
+ (get-universe (fixture b)))
+ (and
+ (eq?
+ (get-universe (fixture a))
+ (get-universe (fixture b)))
+ (<
+ (get-start-addr (fixture a))
+ (get-start-addr (fixture b))))))))
(define (print-state st)