return True def execute(self): for case in self.cases: print "=============Execution================" result = self.execute_one(case) print("================%s=================" % str(result) ) def dumpcase(self): i = 0 for case in self.cases: print("Case " + str(i) + ": " ), self.g.outputpath(case) i+=1 def savesvg(self): self.g.savesvg() if __name__ == '__main__': fsm = FSM() action1 = Action() action1.transfer = lambda x : (x == "1" and "1" ) or "2" action1.name = "rule 1" action2 = Action() action2.transfer = lambda x : (x == "2" and "1") or "2" action2.name = "rule 2" fsm.actionset.append(action1) fsm.actionset.append(action2) fsm.startstates = ["1"] fsm.generateEdge() #for edge in fsm.edgeset: # print(str(edge))
return status def transfer_appon(status): if status['app'] != 'na' and status['black']!='on': status['app'] = 'on' return status def transfer_appoff(status): if status['app'] != 'na': status['app'] = 'off' return status if __name__ == '__main__': fsm = FSM() action1 = Action() action1.transfer = transfer_blackon action1.name = 'black_on' action2 = Action() action2.transfer = transfer_blackoff action2.name = 'black_off' action3 = Action() action3.transfer = transfer_appin action3.name = 'app_in' action4 = Action() action4.transfer = transfer_appon action4.name = 'app_on' action5 = Action()