blob: 6444c5aa257b9b7c2a0c2b053f78ea4226306086 [file] [log] [blame]
A R Karthicka2e53d62016-02-19 17:38:30 -08001class CordTester(object):
2
3 def __init__(self, fsmTable, stopState, stateTable = None, eventTable = None):
4 self.fsmTable = fsmTable
5 self.stopState = stopState
6 self.stateTable = stateTable
7 self.eventTable = eventTable
8 self.currentState = None
9 self.currentEvent = None
10 self.nextState = None
11 self.nextEvent = None
12
13 def runTest(self):
14 while self.currentState != self.stopState and self.currentEvent != None:
15 if self.stateTable and self.eventTable:
16 print 'Current state: %s, Current event: %s' %(self.stateTable.toStr(self.currentState),
17 self.eventTable.toStr(self.currentEvent))
18 key = (self.currentState, self.currentEvent)
19 (actions, nextState) = self.fsmTable[key]
20 if actions:
21 for a in actions:
22 a()
23 self.currentState = nextState
24 self.currentEvent = self.nextEvent