-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcontrol_master.py
executable file
·181 lines (153 loc) · 5.44 KB
/
control_master.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/usr/bin/env python3.10
'''
Top level of checking suite
'''
import sys
import logging
# do the setup, including argument parsing
import olcbchecker.setup
# We only import each specific option as it's
# invoked to reduce startup time and propagation of errors
# during development
def prompt() :
print("\nOpenLCB checking program")
print(" s Setup")
print("")
print(" 0 Frame Transport checking")
print(" 1 Message Network checking")
print(" 2 SNIP checking")
print(" 3 Event Transport checking")
print(" 4 Datagram Transport checking")
print(" 5 Memory Configuration checking")
print(" 6 Configuration Definition Information (CDI) checking")
print(" 7 Train Control checking")
print(" 8 Train Search checking")
print(" 9 Function Definition Information (FDI) checking")
print(" ")
print(" t Run all in sequence without three train protocols")
print(" a Run all in sequence including train protocols")
print(" ")
print(" q Quit")
def checkAll() :
total = 0
import control_frame
total += min(control_frame.checkAll(),1)
import control_message
total += min(control_message.checkAll(),1)
import control_snip
total += min(control_snip.checkAll(),1)
import control_events
total += min(control_events.checkAll(),1)
import control_datagram
total += min(control_datagram.checkAll(),1)
import control_memory
total += min(control_memory.checkAll(),1)
import control_cdi
total += min(control_cdi.checkAll(),1)
import control_traincontrol
total += min(control_traincontrol.checkAll(),1)
import control_trainsearch
total += min(control_trainsearch.checkAll(),1)
import control_fdi
total += min(control_fdi.checkAll(),1)
logger = logging.getLogger("OLCBCHECKER")
if total > 0 :
logger.info("{} sections had failures".format(total))
else :
logger.info("All sections passed")
return total;
def checkAllNoTrains() :
total = 0
import control_frame
total += min(control_frame.checkAll(),1)
import control_message
total += min(control_message.checkAll(),1)
import control_snip
total += min(control_snip.checkAll(),1)
import control_events
total += min(control_events.checkAll(),1)
import control_datagram
total += min(control_datagram.checkAll(),1)
import control_memory
total += min(control_memory.checkAll(),1)
import control_cdi
total += min(control_cdi.checkAll(),1)
logger = logging.getLogger("OLCBCHECKER")
if total > 0 :
logger.info("{} sections had failures".format(total))
else :
logger.info("All sections passed")
return total;
def main() :
# if immediate running has been requested, do that
if olcbchecker.setup.configure.runimmediate :
return (checkAll())
# Otherwise, show the menu and process input
'''
loop to check against individual standards
'''
while True :
prompt()
selection = input(">> ").lower()
match selection :
case "s" :
import control_setup
control_setup.main()
case "0" :
import control_frame
control_frame.main()
case "1" :
import control_message
control_message.main()
case "2" :
import control_snip
control_snip.main()
case "3" :
import control_events
control_events.main()
case "4" :
import control_datagram
control_datagram.main()
case "5" :
import control_memory
control_memory.main()
case "6" :
import control_cdi
control_cdi.main()
case "7" :
import control_traincontrol
control_traincontrol.main()
case "8" :
import control_trainsearch
control_trainsearch.main()
case "9" :
import control_fdi
control_fdi.main()
case "t" :
checkAllNoTrains()
case "a" :
checkAll()
case "q" | "quit" : return
case _ : continue
return
if __name__ == "__main__":
# check options to see if a connection is specified
import builtins
builtins.olcbchecker_bypass_a_or_d_check = True
import configure
if configure.devicename is None and configure.hostname is None :
print ("With neither an address nor device specified, you can")
print ("only set the options, so we'll take you directly to")
print ("that menu. You can restart with the -a or -d option")
print ("(or -h for additional help), or configure using the")
print ("following menu.")
print ("")
import control_setup
control_setup.main()
# can't continue without reset
sys.exit(0)
# run the checks or show the menu
import olcbchecker
result = main()
olcbchecker.setup.interface.close()
sys.exit(result)