Franck Pommereau

more complete httpless

......@@ -26,6 +26,17 @@ class ABCDSimulator (BaseSimulator) :
if nid in n2html.n2a :
self.abcd[trans.name] = ", ".join("#" + i for i in
n2html.n2a[nid])
def init (self, state=-1) :
res = BaseSimulator.init(self, state)
res.update(self.info)
res["help"] = self.init_help()
return res
def init_help (self) :
help = BaseSimulator.init_help(self)
help.update({"#model .abcd" : "ABCD source code",
"#model .tree" : "hierarchy of ABCD objects",
"#model .petrinet" : "Petri nets semantics"})
return help
def getstate (self, state) :
marking = self.states[state]
modes = dict((t, []) for t in self.transid)
......@@ -70,9 +81,3 @@ class Simulator (BaseHTTPSimulator) :
"href" : "#",
"script" : "dialog($('#model .petrinet').html())"
}]
def init_help (self) :
help = BaseHTTPSimulator.init_help(self)
help.update({"#model .abcd" : "ABCD source code",
"#model .tree" : "hierarchy of ABCD objects",
"#model .petrinet" : "Petri nets semantics"})
return help
......
......@@ -108,6 +108,12 @@ class BaseSimulator (object) :
def succ (self, state, mode) :
state = self.states.succ(state, mode)
return self.getstate(state)
def init_help (self) :
return {"#trace": "the states and transitions explored so far",
"#model" : "the model being simulated",
"#alive .ui #ui-quit" : "stop the simulator (server side)",
"#alive .ui #ui-help" : "show this help",
"#alive .ui #ui-about" : "show information about the simulator"}
class BaseHTTPSimulator (Node) :
def __init__ (self, net, port=8000, respatt=[], simulator=None) :
......@@ -197,12 +203,6 @@ class BaseHTTPSimulator (Node) :
"id" : "ui-argv",
"href" : "#",
"script" : "dialog(%r)" % argv}]
def init_help (self) :
return {"#trace": "the states and transitions explored so far",
"#model" : "the model being simulated",
"#alive .ui #ui-quit" : "stop the simulator (server side)",
"#alive .ui #ui-help" : "show this help",
"#alive .ui #ui-about" : "show information about the simulator"}
@http("application/json", state=int)
def init (self, state=-1) :
ret = {"ui" : self.init_ui(),
......