diff options
Diffstat (limited to 'simulation.scm')
-rw-r--r-- | simulation.scm | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/simulation.scm b/simulation.scm index c667750..ca30041 100644 --- a/simulation.scm +++ b/simulation.scm @@ -120,33 +120,31 @@ (lambda () (forever (let ((ev (get-message in))) - (match (event-type ev) - ('start - (let ((msg (event-data ev))) - (ll "Device ~a started ~a of message ~a" - (message-device-id msg) - (message-body msg) - (message-id msg)) - (set! started (cons msg started)))) - ('end - (let ((msg (event-data ev))) - (ll "Device ~a finished ~a of message ~a" - (message-device-id msg) - (message-body msg) - (message-id msg)) - (set! started - (remove! (lambda (x) - (and (= (message-id msg) (message-id x)) - (= (message-device-id msg) (message-device-id x)))) started)) - (if (interference? msg started) - (ll "Interference!!!!!!") - (if (message-uplink? msg) - (hash-table-walk gateways - (lambda (k gateway) - (put-message (device-channel gateway) msg))) - (put-message - (device-channel (hash-ref end-devices (message-device-id msg))) - msg)))))))))) + (match ev + (($ <event> 'start msg) + (ll "Device ~a started ~a of message ~a" + (message-device-id msg) + (message-body msg) + (message-id msg)) + (set! started (cons msg started))) + (($ <event> 'end msg) + (ll "Device ~a finished ~a of message ~a" + (message-device-id msg) + (message-body msg) + (message-id msg)) + (set! started + (remove! (lambda (x) + (and (= (message-id msg) (message-id x)) + (= (message-device-id msg) (message-device-id x)))) started)) + (if (interference? msg started) + (ll "Interference!!!!!!") + (if (message-uplink? msg) + (hash-table-walk gateways + (lambda (k gateway) + (put-message (device-channel gateway) msg))) + (put-message + (device-channel (hash-ref end-devices (message-device-id msg))) + msg))))))))) |