-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.py
83 lines (61 loc) · 1.95 KB
/
controller.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Controller:
import networkx as nx
# but!... might also consider: https://graph-tool.skewed.de/
"""
import statematrix
sm = statematrix.StateMatrix(inputs={'C':0, 'L':1, 'R':2},
outputs={'centerWater':0, 'centerLED':1})
#elif CASE==100:
sm.add_state(name='wait_for_cpoke', statetimer=12,
transitions={'Cin':'play_target'},
outputsOff=['centerLED'])
sm.add_state(name='play_target', statetimer=0.5,
transitions={'Cout':'wait_for_apoke','Tup':'wait_for_cpoke'},
outputsOn=['centerLED'])
print(sm)
"""
# support all helpers from within this project
import view_matrix
import view_graphic
import model
smm = model.StateMatrixModel()
print('Instantiated state matrix designer')
print("creating 'a place to start'")
smm.createState('a place to start')
smm.recordState()
print smm.toString()
print("creating 'and then go here'")
smm.createState('and then go here')
smm.recordState()
print smm.toString()
"""
print("creating 'and then go here' (conflict!)")
if(smd.createState('and then go here')):
smd.recordState()
print smd.toString()
"""
print("modifying with a new transition")
smm.loadState('and then go here')
smm.addTransition('a place to start','tap button')
smm.recordState()
print smm.toString()
#smd.addTransition('yikes0','yikes1')
"""
sm.add_state(name='wait_for_cpoke', statetimer=12,
transitions={'Cin':'play_target'},
outputsOff=['centerLED'])
"""
"""
# Instantiate a finite state machine (network graph)...
# ultimately the graph will be built up through interaction with the graphic view
# (or read in from a state transition matrix)
fsm=nx.Graph()
# again, edges will be added through interaction (or parsing a state transition matrix)
fsm.add_edge(1,2)
# Visualize the
view_graphic.plotMe(nx,fsm)
# Serialize the graph
view_matrix.prettyPrint(fsm)
# separate function? or implement an optional parameter on the prettyPrint?
#view_matrix.writeToFile(fsm,'demo.csv')
"""