urbit/pkg/arvo/app/aqua-behn.hoon

132 lines
2.8 KiB
Plaintext
Raw Normal View History

2019-03-07 10:31:14 +03:00
/- aquarium
=, aquarium
2019-03-30 01:39:01 +03:00
=> |%
2019-03-07 10:31:14 +03:00
+$ move (pair bone card)
+$ card
$% [%poke wire dock %aqua-events (list aqua-event)]
[%peer wire dock path]
[%pull wire dock ~]
[%wait wire p=@da]
[%rest wire p=@da]
==
::
+$ state
$: %0
subscribed=_|
2019-03-08 08:15:42 +03:00
piers=(map ship pier)
2019-03-07 10:31:14 +03:00
==
2019-03-08 08:15:42 +03:00
::
+$ pier next-timer=(unit @da)
2019-03-07 10:31:14 +03:00
--
=, gall
=| moves=(list move)
|_ $: bowl
state
==
++ this .
++ apex %_(this moves ~)
++ abet [(flop moves) this]
++ emit-moves
|= ms=(list move)
%_(this moves (weld ms moves))
::
++ emit-aqua-events
|= aes=(list aqua-event)
%- emit-moves
2019-03-08 08:15:42 +03:00
[ost %poke /aqua-events [our %aqua] %aqua-events aes]~
2019-03-07 10:31:14 +03:00
::
++ poke-aqua-vane-control
|= command=?(%subscribe %unsubscribe)
2019-03-08 08:15:42 +03:00
:_ this(subscribed =(command %subscribe))
(aqua-vane-control-handler our ost subscribed command)
2019-03-07 10:31:14 +03:00
::
++ diff-aqua-effects
|= [way=wire afs=aqua-effects]
^- (quip move _this)
=. this apex =< abet
|- ^+ this
?~ ufs.afs
this
=. this
?+ -.q.i.ufs.afs this
%sleep abet-pe:handle-sleep:(pe who.afs)
%restore abet-pe:handle-restore:(pe who.afs)
%doze abet-pe:(handle-doze:(pe who.afs) i.ufs.afs)
2019-03-08 08:15:42 +03:00
==
2019-03-07 10:31:14 +03:00
$(ufs.afs t.ufs.afs)
::
:: Received timer wake
::
++ wake
|= [way=wire error=(unit tang)]
2019-03-07 10:31:14 +03:00
^- (quip move _this)
=. this apex =< abet
?> ?=([@ *] way)
=/ who (,@p (slav %p i.way))
abet-pe:(take-wake:(pe who) t.way error)
2019-03-07 10:31:14 +03:00
::
++ pe
|= who=ship
=+ (~(gut by piers) who *pier)
2019-03-07 10:31:14 +03:00
=* pier-data -
|%
++ abet-pe
^+ this
=. piers (~(put by piers) who pier-data)
this
::
++ handle-sleep
^+ ..abet-pe
=< ..abet-pe(pier-data *pier)
?~ next-timer
..abet-pe
cancel-timer
::
++ handle-restore
^+ ..abet-pe
2019-03-08 08:15:42 +03:00
=. this
%- emit-aqua-events
[%event who [//behn/0v1n.2m9vh %born ~]]~
..abet-pe
2019-03-07 10:31:14 +03:00
::
++ handle-doze
|= [way=wire %doze tim=(unit @da)]
^+ ..abet-pe
?~ tim
?~ next-timer
2019-03-08 08:15:42 +03:00
..abet-pe
2019-03-07 10:31:14 +03:00
cancel-timer
?~ next-timer
(set-timer u.tim)
(set-timer:cancel-timer u.tim)
::
++ set-timer
|= tim=@da
2019-03-21 03:37:05 +03:00
~? debug=| [who=who %setting-timer tim]
2019-03-07 10:31:14 +03:00
=. next-timer `tim
2019-03-08 08:15:42 +03:00
=. this (emit-moves [ost %wait /(scot %p who) tim]~)
..abet-pe
2019-03-07 10:31:14 +03:00
::
++ cancel-timer
2019-03-21 03:37:05 +03:00
~? debug=| [who=who %cancell-timer (need next-timer)]
2019-03-08 08:15:42 +03:00
=. this (emit-moves [ost %rest /(scot %p who) (need next-timer)]~)
2019-03-08 09:28:10 +03:00
=. next-timer ~
2019-03-08 08:15:42 +03:00
..abet-pe
2019-03-07 10:31:14 +03:00
::
++ take-wake
|= [way=wire error=(unit tang)]
~? debug=| [who=who %aqua-behn-wake now error=error]
2019-03-07 10:31:14 +03:00
=. next-timer ~
=. this
%- emit-aqua-events
:_ ~
^- aqua-event
:+ %event who
:- //behn/0v1n.2m9vh
?~ error
[%wake ~]
[%crud %fail u.error]
2019-03-07 10:31:14 +03:00
..abet-pe
--
--