Code: don't sent tx_allocate until we're connected
So Code needs connected/lost from the RendezvousConnector
This commit is contained in:
parent
5d6989614b
commit
c95b6d402c
|
@ -2,11 +2,8 @@ digraph {
|
||||||
|
|
||||||
start [label="Wormhole Code\nMachine" style="dotted"]
|
start [label="Wormhole Code\nMachine" style="dotted"]
|
||||||
{rank=same; start S0}
|
{rank=same; start S0}
|
||||||
{rank=same; P0_list_nameplates P0_allocate}
|
|
||||||
{rank=same; S1 S2}
|
|
||||||
{rank=same; S3 P1_generate}
|
|
||||||
start -> S0 [style="invis"]
|
start -> S0 [style="invis"]
|
||||||
S0 [label="S0:\nunknown"]
|
S0 [label="S0:\nunknown\ndisconnected"]
|
||||||
S0 -> P0_got_code [label="set"]
|
S0 -> P0_got_code [label="set"]
|
||||||
P0_got_code [shape="box" label="B.got_code"]
|
P0_got_code [shape="box" label="B.got_code"]
|
||||||
P0_got_code -> S4
|
P0_got_code -> S4
|
||||||
|
@ -35,11 +32,14 @@ digraph {
|
||||||
S3 -> P0_got_code [label="<return>"
|
S3 -> P0_got_code [label="<return>"
|
||||||
color="orange" fontcolor="orange"]
|
color="orange" fontcolor="orange"]
|
||||||
|
|
||||||
S0 -> P0_allocate [label="allocate"]
|
S0 -> S1A [label="allocate"]
|
||||||
P0_allocate [shape="box" label="RC.tx_allocate"]
|
S1A [label="S1A:\nconnecting"]
|
||||||
P0_allocate -> S1
|
S1A -> P1_allocate [label="connected"]
|
||||||
S1 [label="S1:\nallocating"]
|
P1_allocate [shape="box" label="RC.tx_allocate"]
|
||||||
S1 -> P1_generate [label="rx_allocated"]
|
P1_allocate -> S1B
|
||||||
|
S1B [label="S1B:\nallocating"]
|
||||||
|
S1B -> P1_generate [label="rx_allocated"]
|
||||||
|
S1B -> S1A [label="lost"]
|
||||||
P1_generate [shape="box" label="generate\nrandom code"]
|
P1_generate [shape="box" label="generate\nrandom code"]
|
||||||
P1_generate -> P0_got_code
|
P1_generate -> P0_got_code
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ digraph {
|
||||||
|
|
||||||
Wormhole -> Boss [style="dashed" label="allocate\ninput\nset_code\nsend\nclose\n(once)"]
|
Wormhole -> Boss [style="dashed" label="allocate\ninput\nset_code\nsend\nclose\n(once)"]
|
||||||
#Wormhole -> Boss [color="blue"]
|
#Wormhole -> Boss [color="blue"]
|
||||||
Boss -> Wormhole [style="dashed" label="got_code\ngot_verifier\nreceived\nclosed\n(once)"]
|
Boss -> Wormhole [style="dashed" label="got_code\ngot_verifier\nreceived (seq)\nclosed\n(once)"]
|
||||||
|
|
||||||
#Boss -> Connection [color="blue"]
|
#Boss -> Connection [color="blue"]
|
||||||
Boss -> Connection [style="dashed" label="start"]
|
Boss -> Connection [style="dashed" label="start"]
|
||||||
|
@ -61,11 +61,11 @@ digraph {
|
||||||
]
|
]
|
||||||
|
|
||||||
#Boss -> Code [color="blue"]
|
#Boss -> Code [color="blue"]
|
||||||
|
Connection -> Code [style="dashed"
|
||||||
|
label="connected\nlost\nrx_allocated"]
|
||||||
Code -> Connection [style="dashed"
|
Code -> Connection [style="dashed"
|
||||||
label="tx_allocate"
|
label="tx_allocate"
|
||||||
]
|
]
|
||||||
Connection -> Code [style="dashed"
|
|
||||||
label="rx_allocated"]
|
|
||||||
Nameplates -> Code [style="dashed"
|
Nameplates -> Code [style="dashed"
|
||||||
label="got_nameplates"
|
label="got_nameplates"
|
||||||
]
|
]
|
||||||
|
|
|
@ -25,15 +25,17 @@ class Code(object):
|
||||||
_timing = attrib(validator=provides(_interfaces.ITiming))
|
_timing = attrib(validator=provides(_interfaces.ITiming))
|
||||||
m = MethodicalMachine()
|
m = MethodicalMachine()
|
||||||
|
|
||||||
def wire(self, wormhole, rendezvous_connector, nameplate_lister):
|
def wire(self, boss, rendezvous_connector, nameplate_lister):
|
||||||
self._W = _interfaces.IWormhole(wormhole)
|
self._B = _interfaces.IBoss(boss)
|
||||||
self._RC = _interfaces.IRendezvousConnector(rendezvous_connector)
|
self._RC = _interfaces.IRendezvousConnector(rendezvous_connector)
|
||||||
self._NL = _interfaces.INameplateLister(nameplate_lister)
|
self._NL = _interfaces.INameplateLister(nameplate_lister)
|
||||||
|
|
||||||
@m.state(initial=True)
|
@m.state(initial=True)
|
||||||
def S0_unknown(self): pass
|
def S0_unknown(self): pass
|
||||||
@m.state()
|
@m.state()
|
||||||
def S1_allocating(self): pass
|
def S1A_connecting(self): pass
|
||||||
|
@m.state()
|
||||||
|
def S1B_allocating(self): pass
|
||||||
@m.state()
|
@m.state()
|
||||||
def S2_typing_nameplate(self): pass
|
def S2_typing_nameplate(self): pass
|
||||||
@m.state()
|
@m.state()
|
||||||
|
@ -51,6 +53,10 @@ class Code(object):
|
||||||
|
|
||||||
# from RendezvousConnector
|
# from RendezvousConnector
|
||||||
@m.input()
|
@m.input()
|
||||||
|
def connected(self): pass
|
||||||
|
@m.input()
|
||||||
|
def lost(self): pass
|
||||||
|
@m.input()
|
||||||
def rx_allocated(self, nameplate): pass
|
def rx_allocated(self, nameplate): pass
|
||||||
|
|
||||||
# from NameplateLister
|
# from NameplateLister
|
||||||
|
@ -73,8 +79,10 @@ class Code(object):
|
||||||
self._stdio = stdio
|
self._stdio = stdio
|
||||||
self._NL.refresh_nameplates()
|
self._NL.refresh_nameplates()
|
||||||
@m.output()
|
@m.output()
|
||||||
def RC_tx_allocate(self, code_length):
|
def stash_code_length(self, code_length):
|
||||||
self._code_length = code_length
|
self._code_length = code_length
|
||||||
|
@m.output()
|
||||||
|
def RC_tx_allocate(self):
|
||||||
self._RC.tx_allocate()
|
self._RC.tx_allocate()
|
||||||
@m.output()
|
@m.output()
|
||||||
def do_completion_nameplates(self):
|
def do_completion_nameplates(self):
|
||||||
|
@ -90,22 +98,26 @@ class Code(object):
|
||||||
def do_completion_code(self):
|
def do_completion_code(self):
|
||||||
pass
|
pass
|
||||||
@m.output()
|
@m.output()
|
||||||
def generate_and_set(self, nameplate):
|
def generate_and_B_got_code(self, nameplate):
|
||||||
self._code = make_code(nameplate, self._code_length)
|
self._code = make_code(nameplate, self._code_length)
|
||||||
self._W_got_code()
|
self._B_got_code()
|
||||||
|
|
||||||
@m.output()
|
@m.output()
|
||||||
def W_got_code(self, code):
|
def B_got_code(self, code):
|
||||||
self._code = code
|
self._code = code
|
||||||
self._W_got_code()
|
self._B_got_code()
|
||||||
|
|
||||||
def _W_got_code(self):
|
def _B_got_code(self):
|
||||||
self._W.got_code(self._code)
|
self._B.got_code(self._code)
|
||||||
|
|
||||||
S0_unknown.upon(allocate, enter=S1_allocating, outputs=[RC_tx_allocate])
|
S0_unknown.upon(set, enter=S4_known, outputs=[B_got_code])
|
||||||
S1_allocating.upon(rx_allocated, enter=S4_known, outputs=[generate_and_set])
|
|
||||||
|
|
||||||
S0_unknown.upon(set, enter=S4_known, outputs=[W_got_code])
|
S0_unknown.upon(allocate, enter=S1A_connecting, outputs=[stash_code_length])
|
||||||
|
S1A_connecting.upon(connected, enter=S1B_allocating,
|
||||||
|
outputs=[RC_tx_allocate])
|
||||||
|
S1B_allocating.upon(lost, enter=S1A_connecting, outputs=[])
|
||||||
|
S1B_allocating.upon(rx_allocated, enter=S4_known,
|
||||||
|
outputs=[generate_and_B_got_code])
|
||||||
|
|
||||||
S0_unknown.upon(input, enter=S2_typing_nameplate,
|
S0_unknown.upon(input, enter=S2_typing_nameplate,
|
||||||
outputs=[start_input_and_NL_refresh_nameplates])
|
outputs=[start_input_and_NL_refresh_nameplates])
|
||||||
|
@ -116,4 +128,4 @@ class Code(object):
|
||||||
S2_typing_nameplate.upon(hyphen, enter=S3_typing_code,
|
S2_typing_nameplate.upon(hyphen, enter=S3_typing_code,
|
||||||
outputs=[lookup_wordlist])
|
outputs=[lookup_wordlist])
|
||||||
S3_typing_code.upon(tab, enter=S3_typing_code, outputs=[do_completion_code])
|
S3_typing_code.upon(tab, enter=S3_typing_code, outputs=[do_completion_code])
|
||||||
S3_typing_code.upon(RETURN, enter=S4_known, outputs=[W_got_code])
|
S3_typing_code.upon(RETURN, enter=S4_known, outputs=[B_got_code])
|
||||||
|
|
|
@ -119,6 +119,7 @@ class RendezvousConnector(object):
|
||||||
def ws_open(self, proto):
|
def ws_open(self, proto):
|
||||||
self._ws = proto
|
self._ws = proto
|
||||||
self._tx("bind", appid=self._appid, side=self._side)
|
self._tx("bind", appid=self._appid, side=self._side)
|
||||||
|
self._C.connected()
|
||||||
self._M.connected()
|
self._M.connected()
|
||||||
self._NL.connected()
|
self._NL.connected()
|
||||||
|
|
||||||
|
@ -136,6 +137,7 @@ class RendezvousConnector(object):
|
||||||
|
|
||||||
def ws_close(self, wasClean, code, reason):
|
def ws_close(self, wasClean, code, reason):
|
||||||
self._ws = None
|
self._ws = None
|
||||||
|
self._C.lost()
|
||||||
self._M.lost()
|
self._M.lost()
|
||||||
self._NL.lost()
|
self._NL.lost()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user