run_test-0.py 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458
  1. #!/usr/bin/python
  2. # _*_ coding: utf-8 _*_
  3. try:
  4. from Tkinter import *
  5. import ttk
  6. import tkMessageBox
  7. except Exception as e:
  8. from tkinter import *
  9. from tkinter import ttk
  10. from tkinter import messagebox as tkMessageBox
  11. import sys
  12. import os
  13. import subprocess
  14. import time
  15. import threading
  16. import csv
  17. import subprocess
  18. from datetime import datetime
  19. # declaring global variables
  20. script_ver = 'C180-C-C7-v1.2'
  21. log_file = './Logs/temp.txt'
  22. log1_buffer = ""
  23. step_status = ['x', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns',
  24. 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns']
  25. result_msg = []
  26. # 'x' = don't care
  27. # 'ns' = not started
  28. # 'p' = passed
  29. # 'f' = failed
  30. # 'r' = running
  31. test_channel = ['1', '6', '11']
  32. device_info = {}
  33. params_dict = {}
  34. params_dict['path_loss'] = '25'
  35. params_dict['wave_file'] = './11b_waveforms/wave11rc_1000.mod'
  36. params_dict['per_limit'] = '92'
  37. params_dict['SA_RSSI'] = '-80'
  38. params_dict['BTOn_RSSI'] = '-30'
  39. ###########################################################################
  40. class IO_process:
  41. def __init__(self, log_file_path):
  42. # log_file_path is the absolute path of the log file
  43. self.log_file = log_file_path
  44. self.line_count = 0
  45. def read_file(self):
  46. try:
  47. f = open(self.log_file, 'r') # open file to read
  48. flag = 0
  49. for i, line in enumerate(f):
  50. if i == self.line_count: # if reached the correct line
  51. self.line_count += 1
  52. flag = 1
  53. # print self.line_count
  54. break
  55. f.close()
  56. if flag == 1:
  57. return line.rstrip('\r') # get rid of the newline character
  58. else:
  59. return ""
  60. except:
  61. return ""
  62. def empty_file(self):
  63. f = open(self.log_file, 'w')
  64. f.close()
  65. def reset_counter(self):
  66. self.line_count = 0
  67. ###########################################################################
  68. def write_log_to_file(content):
  69. curr_time = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime())
  70. log_dir = "./Logs/"
  71. log_file = "log_" + curr_time + ".txt"
  72. log_file_location = log_dir + log_file
  73. file = open(log_file_location, 'a') # open file to append
  74. file.write(str(content) + '\n')
  75. file.close()
  76. ###########################################################################
  77. def print1(string, newline=0):
  78. global log1_buffer
  79. if newline == 0: # if user doesn't want to insert a line feed
  80. log1_buffer += "\n" + str(string)
  81. elif newline == 1: # if user wants to insert a line feed
  82. log1_buffer += "\n" + str(string) + "\n"
  83. ###########################################################################
  84. def step1_routine():
  85. # bios_version
  86. global step_status
  87. global result_msg
  88. step_num = 1
  89. print(">>>1", step_status, "<<<")
  90. step_status[step_num] = 'r' # running
  91. print1("\nstep1----------------------------------------------------")
  92. print1("Step " + str(step_num) + " Started...")
  93. time.sleep(1)
  94. a = os.popen("sh os-ver.sh bios").read()
  95. a = a.replace('\n', '')
  96. a = a.replace('\r', '')
  97. a = a.strip()
  98. if len(a) == 0:
  99. print1("Error! No Device found!")
  100. print1(a)
  101. step_status[step_num] = 'f' # failed
  102. else:
  103. print1("Success! Device found! Rsync completed!")
  104. print1(a)
  105. step_status[step_num] = 'p' # passed
  106. result_msg[step_num] = a
  107. ###########################################################################
  108. def step2_routine():
  109. # bios release date
  110. global step_status
  111. global device_info
  112. global result_msg
  113. print(">>>2", step_status, "<<<")
  114. step_num = 2
  115. step_status[step_num] = 'r' # running
  116. print1("\nstep2----------------------------------------------------")
  117. print1("Step " + str(step_num) + " Started...")
  118. # tkMessageBox.showinfo("Message Box", "PS2 keyboard/mouse test! Make sure PS2 keyboard and mouse are connected.")
  119. # read the data and analysis it.
  120. # a = os.popen('sh bios-release-date.sh').read()
  121. a = os.popen('sh os-ver.sh ec').read()
  122. a = a.replace('\n', '')
  123. a = a.replace('\r', '')
  124. a = a.strip()
  125. # a = os.system(r'./usb-location.sh')
  126. # a = subprocess.call(['./usb-location.sh'])
  127. print1("Step " + str(a) + " End...")
  128. if len(a) == 0:
  129. print1("Error! Standalone Sensitivity Fails!")
  130. print1("Please check the cable and antenna connection and try again!")
  131. step_status[step_num] = 'f' # failed
  132. else:
  133. step_status[step_num] = 'p'
  134. result_msg[step_num] = a
  135. ###########################################################################
  136. def step3_routine():
  137. # CPU type
  138. global step_status
  139. global result_msg
  140. print(">>>3", step_status, "<<<")
  141. step_num = 3
  142. step_status[step_num] = 'r' # running
  143. print1("\n----------------------------------------------------")
  144. print1("Step " + str(step_num) + " Started...")
  145. # step_status[step_num] = 'p' # passed
  146. # result_msg[step_num] = 'AAPASS'
  147. # return;
  148. a = os.popen("cat /proc/cpuinfo | grep \"model name\" | awk '{print $5}' | head -1").read()
  149. a = a.replace('\n', '')
  150. a = a.replace('\r', '')
  151. a = a.strip()
  152. if len(a) == 0:
  153. print1("Error! No Device found!")
  154. print1(a)
  155. step_status[step_num] = 'f' # failed
  156. else:
  157. print1("Error! No Device found!")
  158. print1(a)
  159. step_status[step_num] = 'p' # passed
  160. result_msg[step_num] = a
  161. ###########################################################################
  162. def step4_routine():
  163. # memory_version
  164. global step_status
  165. global result_msg
  166. step_num = 4
  167. step_status[step_num] = 'r' # running
  168. print1("\nFT----------------------------------------------------")
  169. print1("Step " + str(step_num) + " Started...")
  170. a = os.popen("sh mem-ver.sh").read()
  171. a = a.replace('\n', '')
  172. a = a.replace('\r', '')
  173. a = a.strip()
  174. if len(a) == 0:
  175. print1("Error! No Device found!")
  176. print1(a)
  177. step_status[step_num] = 'f' # failed
  178. else:
  179. step_status[step_num] = 'p' # passed
  180. result_msg[step_num] = a
  181. ###########################################################################
  182. def step5_routine():
  183. # hdd_version
  184. global step_status
  185. global result_msg
  186. step_num = 5
  187. step_status[step_num] = 'r' # running
  188. print1("\n----------------------------------------------------")
  189. print1("Step " + str(step_num) + " Started...")
  190. a = os.popen("sh hdd-ver.sh").read()
  191. a = a.replace('\n', '')
  192. a = a.replace('\r', '')
  193. a = a.strip()
  194. if len(a) == 0:
  195. print1("Error! No Device found!")
  196. print1(a)
  197. step_status[step_num] = 'f' # failed
  198. else:
  199. step_status[step_num] = 'p' # passed
  200. result_msg[step_num] = a
  201. ###########################################################################
  202. def step6_routine():
  203. # os_version
  204. global step_status
  205. global result_msg
  206. step_num = 6
  207. step_status[step_num] = 'r' # running
  208. time.sleep(3)
  209. print1("\n----------------------------------------------------")
  210. print1("Step " + str(step_num) + " Started...")
  211. a = os.popen("sh os-ver.sh os").read()
  212. if str == "os":
  213. a = os.popen("sh os-ver.sh os").read()
  214. if str == "tpm":
  215. a = os.popen("sh os-ver.sh tpm").read()
  216. a = a.replace('\n', '')
  217. a = a.replace('\r', '')
  218. a = a.strip()
  219. if len(a) == 0:
  220. print1("Error! No Device found!")
  221. print1(a)
  222. step_status[step_num] = 'f' # failed
  223. else:
  224. print1(a)
  225. step_status[step_num] = 'p' # passed
  226. result_msg[step_num] = a
  227. ###########################################################################
  228. def step7_routine():
  229. # cpu_version
  230. global step_status
  231. global result_msg
  232. step_num = 7
  233. step_status[step_num] = 'r' # running
  234. print1("\n----------------------------------------------------")
  235. print1("Step " + str(step_num) + " Started...")
  236. tkMessageBox.showinfo("Message Box", "HDMI test! HDMI测试,如果没有插上HDMI cable,请插上HDMI查看显示器及edp显示状况.")
  237. # a = os.popen("sh cpu-ver.sh").read()
  238. a = os.popen('sh os-ver.sh HDMI').read()
  239. if tkMessageBox.askokcancel("PASS?", "确定HDMI及edp显示是否正常?"):
  240. step_status[step_num] = 'p' # passed
  241. result_msg[step_num] = 'PASS'
  242. return;
  243. a = a.replace('\n', '')
  244. a = a.replace('\r', '')
  245. a = a.strip()
  246. print1("Error! No Device found!")
  247. print1(a)
  248. step_status[step_num] = 'f' # failed
  249. ###########################################################################
  250. def step8_routine():
  251. # camera function
  252. global step_status
  253. global result_msg
  254. step_num = 8
  255. step_status[step_num] = 'r' # running
  256. # step_status[step_num] = 'p' # passed
  257. # result_msg[step_num] = 'AAPASS'
  258. # return;
  259. tkMessageBox.showinfo("Message Box", "camera test! 相机测试,将弹出相机软件guvcview,手动测试相机是否正常.")
  260. print1("\n----------------------------------------------------")
  261. print1("Step " + str(step_num) + " Started...")
  262. a = os.popen("/usr/bin/guvcview &").read()
  263. if tkMessageBox.askokcancel("PASS?", "确定测试相机是否正常?"):
  264. print1("camera Test! device test pass!")
  265. step_status[step_num] = 'p' # passed
  266. result_msg[step_num] = 'PASS'
  267. return;
  268. a = a.replace('\n', '')
  269. a = a.replace('\r', '')
  270. a = a.strip()
  271. print1("camera Test Error! No Device found!")
  272. print1(a)
  273. step_status[step_num] = 'f' # failed
  274. def step9_routine():
  275. # speaker-test
  276. global step_status
  277. global result_msg
  278. # tkMessageBox.showinfo("Message Box", "Error on Step " + str(i) + "! See Log for details.")
  279. step_num = 9
  280. step_status[step_num] = 'r' # running
  281. # step_status[step_num] = 'p' # passed
  282. # result_msg[step_num] = 'AAPASS'
  283. # return;
  284. tkMessageBox.showinfo("Message Box", "test speaker test! 喇叭测试,如果没有喇叭,请插上耳机确定是否有声音.")
  285. print1("\n----------------------------------------------------")
  286. print1("Step " + str(step_num) + " Started...")
  287. a = os.popen("sh os-ver.sh speaker").read()
  288. if tkMessageBox.askokcancel("PASS?", "确定测试机器是否有声音?"):
  289. step_status[step_num] = 'p' # passed
  290. result_msg[step_num] = 'PASS'
  291. return;
  292. a = a.replace('\n', '')
  293. a = a.replace('\r', '')
  294. a = a.strip()
  295. print1("Error! No Device found!")
  296. print1(a)
  297. step_status[step_num] = 'f' # failed
  298. def step10_routine():
  299. # arecord
  300. global step_status
  301. global result_msg
  302. step_num = 10
  303. step_status[step_num] = 'r' # running
  304. # step_status[step_num] = 'p' # passed
  305. # result_msg[step_num] = 'AAPASS'
  306. # return;
  307. tkMessageBox.showinfo("Message Box", "arecord test! 录音测试,将弹出录音软件Audacity,手动测试录音是否正常.")
  308. print1("\n----------------------------------------------------")
  309. print1("Step " + str(step_num) + " Started...")
  310. a = os.popen("sh os-ver.sh arecord").read()
  311. if tkMessageBox.askokcancel("PASS?", "确定测试机器录音是否正常?"):
  312. step_status[step_num] = 'p' # passed
  313. result_msg[step_num] = 'PASS'
  314. return;
  315. a = a.replace('\n', '')
  316. a = a.replace('\r', '')
  317. a = a.strip()
  318. # print1("Error! No Device found!")
  319. print1(a)
  320. step_status[step_num] = 'f' # failed
  321. def step11_routine():
  322. global step_status
  323. global result_msg
  324. step_num = 11
  325. step_status[step_num] = 'r' # running
  326. step_status[step_num] = 'p' # passed
  327. result_msg[step_num] = 'AAPASS'
  328. return;
  329. os.system("sh os-ver.sh USB211 &")
  330. time.sleep(1)
  331. tkMessageBox.showinfo("Message Box", "USB2.0 test! 请插入U盘到后端usb2.0接口1号位置.")
  332. print1("\n----------------------------------------------------")
  333. print1("Step " + str(step_num) + " Started...")
  334. a = os.popen("sh os-ver.sh USB21").read()
  335. print1(a)
  336. a = a.replace('\n', '')
  337. a = a.replace('\r', '')
  338. a = a.strip()
  339. if a == "0":
  340. print1("Error! No Device found!")
  341. print1(a)
  342. step_status[step_num] = 'f' # failed
  343. result_msg[step_num] = a
  344. else:
  345. print1(a)
  346. step_status[step_num] = 'p' # passed
  347. result_msg[step_num] = a
  348. def step12_routine():
  349. global step_status
  350. global result_msg
  351. step_num = 12
  352. step_status[step_num] = 'r' # running
  353. step_status[step_num] = 'p' # passed
  354. result_msg[step_num] = 'AAPASS'
  355. return;
  356. os.system("sh os-ver.sh USB211 &")
  357. time.sleep(1)
  358. tkMessageBox.showinfo("Message Box", "USB2.0 test! 请插入U盘到后端usb2.0接口2号位置.")
  359. print1("\n----------------------------------------------------")
  360. print1("Step " + str(step_num) + " Started...")
  361. a = os.popen("sh os-ver.sh USB22").read()
  362. a = a.replace('\n', '')
  363. a = a.replace('\r', '')
  364. a = a.strip()
  365. if a == "0":
  366. print1("Error! No Device found!")
  367. print1(a)
  368. step_status[step_num] = 'f' # failed
  369. result_msg[step_num] = a
  370. else:
  371. print1(a)
  372. step_status[step_num] = 'p' # passed
  373. result_msg[step_num] = a
  374. def step13_routine():
  375. global step_status
  376. global result_msg
  377. step_num = 13
  378. step_status[step_num] = 'r' # running
  379. print1("\n----------------------------------------------------")
  380. print1("Step " + str(step_num) + " Started USB3.0 test 1...")
  381. os.system("sh os-ver.sh USB211 &")
  382. time.sleep(1)
  383. tkMessageBox.showinfo("Message Box", "USB3.0 test! 请插入U盘到整个hub全usb3.0接口1号位置-靠近主板.")
  384. a = os.popen("sh os-ver.sh USB391").read()
  385. a = a.replace('\n', '')
  386. a = a.replace('\r', '')
  387. a = a.strip()
  388. print1("\n----------------------------------------------------")
  389. # tkMessageBox.showinfo("Message Box", "USB3.0 test! 请插入U盘到后端usb3.0接口4号指定位置.")
  390. if a == "0":
  391. print1("Error! No Device found!")
  392. print1(a)
  393. step_status[step_num] = 'f' # failed
  394. result_msg[step_num] = a
  395. else:
  396. print1(a)
  397. step_status[step_num] = 'p' # passed
  398. result_msg[step_num] = a
  399. def step14_routine():
  400. global step_status
  401. global result_msg
  402. step_num = 14
  403. step_status[step_num] = 'r' # running
  404. print1("\n----------------------------------------------------")
  405. print1("Step " + str(step_num) + " Started USB3.0 test 1...")
  406. os.system("sh os-ver.sh USB211 &")
  407. time.sleep(1)
  408. tkMessageBox.showinfo("Message Box", "USB3.0 test! 请插入U盘到整个hub全usb3.0接口2号位置-靠近主板.")
  409. a = os.popen("sh os-ver.sh USB392").read()
  410. a = a.replace('\n', '')
  411. a = a.replace('\r', '')
  412. a = a.strip()
  413. print1("\n----------------------------------------------------")
  414. if a == "0":
  415. print1("Error! No Device found!")
  416. print1(a)
  417. step_status[step_num] = 'f' # failed
  418. result_msg[step_num] = a
  419. else:
  420. print1(a)
  421. step_status[step_num] = 'p' # passed
  422. result_msg[step_num] = a
  423. def step15_routine():
  424. global step_status
  425. global result_msg
  426. step_num = 15
  427. step_status[step_num] = 'r' # running
  428. print1("\n----------------------------------------------------")
  429. print1("Step " + str(step_num) + " Started USB3.0 test 1...")
  430. os.system("sh os-ver.sh USB211 &")
  431. time.sleep(1)
  432. tkMessageBox.showinfo("Message Box", "USB3.0 test! 请插入U盘到整个hub全usb3.0接口3号位置-靠近主板.")
  433. a = os.popen("sh os-ver.sh USB393").read()
  434. a = a.replace('\n', '')
  435. a = a.replace('\r', '')
  436. a = a.strip()
  437. print1("\n----------------------------------------------------")
  438. if a == "0":
  439. print1("Error! No Device found!")
  440. print1(a)
  441. step_status[step_num] = 'f' # failed
  442. result_msg[step_num] = a
  443. else:
  444. print1(a)
  445. step_status[step_num] = 'p' # passed
  446. result_msg[step_num] = a
  447. def step16_routine():
  448. global step_status
  449. global result_msg
  450. step_num = 16
  451. step_status[step_num] = 'r' # running
  452. print1("\n----------------------------------------------------")
  453. print1("Step " + str(step_num) + " Started USB3.0 test 1...")
  454. os.system("sh os-ver.sh USB211 &")
  455. time.sleep(1)
  456. tkMessageBox.showinfo("Message Box", "USB3.0 test! 请插入U盘到整个hub全usb3.0接口4号位置-靠近主板.")
  457. a = os.popen("sh os-ver.sh USB394").read()
  458. a = a.replace('\n', '')
  459. a = a.replace('\r', '')
  460. a = a.strip()
  461. print1("\n----------------------------------------------------")
  462. if a == "0":
  463. print1("Error! No Device found!")
  464. print1(a)
  465. step_status[step_num] = 'f' # failed
  466. result_msg[step_num] = a
  467. else:
  468. print1(a)
  469. step_status[step_num] = 'p' # passed
  470. result_msg[step_num] = a
  471. def step17_routine():
  472. # network speed cli
  473. global step_status
  474. global result_msg
  475. step_num = 17
  476. step_status[step_num] = 'r' # running
  477. step_status[step_num] = 'p' # passed
  478. result_msg[step_num] = 'AAPASS'
  479. return;
  480. tkMessageBox.showinfo("Message Box", "RJ45网口 test! 请插入网线到指定RJ45网口中,再点确定开始测试!.")
  481. print1("\n----------------------------------------------------")
  482. print1("Step " + str(step_num) + " Started...")
  483. step_status[step_num] = 'p' # passed
  484. result_msg[step_num] = 'AAPASS'
  485. return;
  486. a = os.popen("sh os-ver.sh speedcliDownload").read()
  487. a = a.replace('\n', '')
  488. a = a.replace('\r', '')
  489. a = a.strip()
  490. if len(a) == 0:
  491. print1("Error! No Device found!")
  492. print1(a)
  493. step_status[step_num] = 'f' # failed
  494. elif a == "Download: Upload:":
  495. print1("Error! no ethernet!")
  496. print1(a)
  497. step_status[step_num] = 'f' # failed
  498. result_msg[step_num] = a
  499. else:
  500. print1(a)
  501. step_status[step_num] = 'p' # passed
  502. result_msg[step_num] = a
  503. def step18_routine():
  504. # serial
  505. global step_status
  506. global result_msg
  507. step_num = 18
  508. step_status[step_num] = 'r' # running
  509. # tkMessageBox.showinfo("Message Box", "Serial test! 串口基本功能测试是否AAPASS.")
  510. print1("\n----------------------------------------------------")
  511. print1("Step " + str(step_num) + " Started...")
  512. if tkMessageBox.askokcancel("PASS?", "串口基本功能测试是否AAPASS."):
  513. step_status[step_num] = 'p' # passed
  514. result_msg[step_num] = 'PASS'
  515. return;
  516. a = os.popen("sh os-ver.sh tpm").read()
  517. a = a.replace('\n', '')
  518. a = a.replace('\r', '')
  519. a = a.strip()
  520. if len(a) == 0:
  521. print1("Error! No Device found!")
  522. print1(a)
  523. step_status[step_num] = 'f' # failed
  524. else:
  525. print1(a)
  526. step_status[step_num] = 'p' # passed
  527. result_msg[step_num] = a
  528. def step19_routine():
  529. # battery
  530. global step_status
  531. global result_msg
  532. step_num = 19
  533. step_status[step_num] = 'r' # running
  534. # tkMessageBox.showinfo("Message Box", "battery test! 电池包测试(C180)是否AAPASS.")
  535. print1("\n----------------------------------------------------")
  536. print1("Step " + str(step_num) + " Started...")
  537. step_status[step_num] = 'p' # passed
  538. result_msg[step_num] = 'AAPASS'
  539. return;
  540. tkMessageBox.showinfo("Message Box", "battery test! 电池包测试(C180)是否能正常工作!")
  541. a = os.popen("sh os-ver.sh ps2").read()
  542. if tkMessageBox.askokcancel("PASS?", "电池包测试(C180)是否正常."):
  543. step_status[step_num] = 'p' # passed
  544. result_msg[step_num] = 'PASS'
  545. return;
  546. a = a.replace('\n', '')
  547. a = a.replace('\r', '')
  548. a = a.strip()
  549. print1("Error! No Device found!")
  550. print1(a)
  551. step_status[step_num] = 'f' # failed
  552. def step20_routine():
  553. global step_status
  554. global result_msg
  555. step_num = 20
  556. step_status[step_num] = 'r' # running
  557. # step_status[step_num] = 'p' # passed
  558. # result_msg[step_num] = 'AAPASS'
  559. # return;
  560. # tkMessageBox.showinfo("Message Box", "play video test! 视频测试,播放720p视频.")
  561. print1("\n----------------------------------------------------")
  562. print1("Step " + str(step_num) + " Started...")
  563. print1("Step " + str(step_num) + " 开始播放720p视频")
  564. # a = os.popen("sh os-ver.sh 720p").read()
  565. # subprocess.run('sh os-ver.sh 720p',stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
  566. # os.system("sudo setenforce 0")
  567. time.sleep(1)
  568. os.system("sh os-ver.sh 720p &")
  569. time.sleep(2)
  570. # os.system("sudo setenforce 1")
  571. if not tkMessageBox.askokcancel("PASS?", "视频播放器要关-确定测试机器播放720p视频正常吗?"):
  572. os.system("sh os-ver.sh exit &")
  573. time.sleep(1)
  574. print1("Error! No Device found!")
  575. print1("The video is playing abnormally! - 720p video")
  576. step_status[step_num] = 'f' # failed
  577. return;
  578. """
  579. #os.system("systemctl suspend &")
  580. #os.system("sh os-ver.sh suspend &")
  581. os.system("sh os-ver.sh sudo &")
  582. time.sleep(10)
  583. if not tkMessageBox.askokcancel("PASS?", "视频播放器不要关-睡眠之后再确定测试机器播放720p视频正常吗?"):
  584. print1("Error! No Device found!")
  585. print1("The video is playing abnormally! - 720p suspend")
  586. step_status[step_num] = 'f' # failed
  587. return;
  588. print1("Step " + str(step_num) + " 开始是休眠再播放720p视频")
  589. #os.system("systemctl hibernate &")
  590. #os.system("sh os-ver.sh hibernate &")
  591. #os.system("sh os-ver.sh sudo &")
  592. #time.sleep(30)
  593. if not tkMessageBox.askokcancel("PASS?", "视频播放器要关-休眠之后再确定测试机器播放720p视频正常吗?"):
  594. os.system("sh os-ver.sh exit &")
  595. time.sleep(1)
  596. print1("Error! No Device found!")
  597. print1("The video is playing abnormally! - 720p hibernate")
  598. step_status[step_num] = 'f' # failed
  599. return;
  600. """
  601. os.system("sh os-ver.sh exit &")
  602. time.sleep(1)
  603. print1("The video is playing normally! - 720p")
  604. step_status[step_num] = 'p' # passed
  605. result_msg[step_num] = 'PASS'
  606. def step21_routine():
  607. global step_status
  608. global result_msg
  609. # tkMessageBox.showinfo("Message Box", "Error on Step " + str(i) + "! See Log for details.")
  610. step_num = 21
  611. step_status[step_num] = 'r' # running
  612. # step_status[step_num] = 'p' # passed
  613. # result_msg[step_num] = 'AAPASS'
  614. # return;
  615. # tkMessageBox.showinfo("Message Box", "play video test! 视频测试,播放1080p视频.")
  616. print1("\n----------------------------------------------------")
  617. print1("Step " + str(step_num) + " Started...")
  618. print1("Step " + str(step_num) + " 开始播放1080p视频")
  619. # a = os.popen("sh os-ver.sh 720p").read()
  620. # subprocess.run('sh os-ver.sh 720p',stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
  621. time.sleep(1)
  622. os.system("sh os-ver.sh 1080p &")
  623. time.sleep(2)
  624. if not tkMessageBox.askokcancel("PASS?", "视频播放器要关-确定测试机器播放1080p视频正常吗?"):
  625. os.system("sh os-ver.sh exit &")
  626. time.sleep(1)
  627. print1("Error! No Device found!")
  628. print1("The video is playing abnormally! - 1080p video")
  629. step_status[step_num] = 'f' # failed
  630. return;
  631. """
  632. #os.system("sh os-ver.sh suspend &")
  633. os.system("sh os-ver.sh sudo &")
  634. time.sleep(10)
  635. if not tkMessageBox.askokcancel("PASS?", "视频播放器不要关-睡眠之后再确定测试机器播放1080p视频正常吗?"):
  636. print1("Error! No Device found!")
  637. print1("The video is playing abnormally! - 1080p suspend")
  638. step_status[step_num] = 'f' # failed
  639. return;
  640. print1("Step " + str(step_num) + " 开始是休眠再播放1080p视频")
  641. #os.system("sh os-ver.sh hibernate &")
  642. #os.system("sh os-ver.sh sudo &")
  643. #time.sleep(30)
  644. if not tkMessageBox.askokcancel("PASS?", "视频播放器要关-休眠之后再确定测试机器播放1080p视频正常吗?"):
  645. os.system("sh os-ver.sh exit &")
  646. time.sleep(1)
  647. print1("Error! No Device found!")
  648. print1("The video is playing abnormally! - 1080p hibernate")
  649. step_status[step_num] = 'f' # failed
  650. return;
  651. """
  652. os.system("sh os-ver.sh exit &")
  653. time.sleep(1)
  654. print1("The video is playing normally! - 1080p")
  655. step_status[step_num] = 'p' # passed
  656. result_msg[step_num] = 'PASS'
  657. def step22_routine():
  658. global step_status
  659. global result_msg
  660. # tkMessageBox.showinfo("Message Box", "Error on Step " + str(i) + "! See Log for details.")
  661. step_num = 22
  662. step_status[step_num] = 'r' # running
  663. # step_status[step_num] = 'p' # passed
  664. # result_msg[step_num] = 'AAPASS'
  665. # return;
  666. # tkMessageBox.showinfo("Message Box", "play video test! 视频测试,播放4K视频.")
  667. print1("\n----------------------------------------------------")
  668. print1("Step " + str(step_num) + " Started...")
  669. print1("Step " + str(step_num) + " 开始播放4K视频")
  670. # a = os.popen("sh os-ver.sh 720p").read()
  671. # subprocess.run('sh os-ver.sh 720p',stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
  672. time.sleep(1)
  673. os.system("sh os-ver.sh 4K &")
  674. time.sleep(1)
  675. if not tkMessageBox.askokcancel("PASS?", "视频播放器要关-确定测试机器播放4K视频正常吗?"):
  676. os.system("sh os-ver.sh exit &")
  677. time.sleep(1)
  678. print1("Error! No Device found!")
  679. print1("The video is playing abnormally! - 4K suspend")
  680. step_status[step_num] = 'f' # failed
  681. return;
  682. """
  683. #os.system("sh os-ver.sh suspend &")
  684. os.system("sh os-ver.sh sudo &")
  685. #a = os.popen("sh os-ver.sh suspend").read()
  686. time.sleep(10)
  687. if not tkMessageBox.askokcancel("PASS?", "视频播放器不要关-睡眠之后再确定测试机器播放4K视频正常吗?"):
  688. print1("Error! No Device found!")
  689. print1("The video is playing abnormally! - 4K hibernate")
  690. step_status[step_num] = 'f' # failed
  691. return;
  692. print1("Step " + str(step_num) + " 开始是休眠再播放4K视频")
  693. #os.system("sh os-ver.sh hibernate &")
  694. #os.system("sh os-ver.sh sudo &")
  695. #time.sleep(30)
  696. #a = os.popen("sh os-ver.sh hibernate").read()
  697. if not tkMessageBox.askokcancel("PASS?", "视频播放器要关-休眠之后再确定测试机器播放4K视频正常吗?"):
  698. os.system("sh os-ver.sh exit &")
  699. time.sleep(1)
  700. print1("Error! No Device found!")
  701. print1("The video is playing abnormally! - 4K hibernate")
  702. step_status[step_num] = 'f' # failed
  703. return;
  704. """
  705. os.system("sh os-ver.sh exit &")
  706. time.sleep(1)
  707. print1("The video is playing normally! - 4K")
  708. step_status[step_num] = 'p' # passed
  709. result_msg[step_num] = 'PASS'
  710. #########################################################################
  711. def step23_routine():
  712. global step_status
  713. global result_msg
  714. step_num = 23
  715. step_status[step_num] = 'r' # running
  716. os.system("sh os-ver.sh USB211 &")
  717. time.sleep(1)
  718. tkMessageBox.showinfo("Message Box", "USB3.0 test! 请插入U盘到带网口hub的usb3.0接口1号位置-靠近主板.")
  719. print1("\n----------------------------------------------------")
  720. print1("Step " + str(step_num) + " Started...")
  721. a = os.popen("sh os-ver.sh USB381").read()
  722. print1(a)
  723. a = a.replace('\n', '')
  724. a = a.replace('\r', '')
  725. a = a.strip()
  726. if a == "0":
  727. print1("Error! No Device found!")
  728. print1(a)
  729. step_status[step_num] = 'f' # failed
  730. result_msg[step_num] = a
  731. else:
  732. print1(a)
  733. step_status[step_num] = 'p' # passed
  734. result_msg[step_num] = a
  735. def step24_routine():
  736. global step_status
  737. global result_msg
  738. step_num = 24
  739. step_status[step_num] = 'r' # running
  740. os.system("sh os-ver.sh USB211 &")
  741. time.sleep(1)
  742. tkMessageBox.showinfo("Message Box", "USB3.0 test! 请插入U盘到带网口hub的usb3.0接口2号位置-靠近主板.")
  743. print1("\n----------------------------------------------------")
  744. print1("Step " + str(step_num) + " Started...")
  745. a = os.popen("sh os-ver.sh USB382").read()
  746. a = a.replace('\n', '')
  747. a = a.replace('\r', '')
  748. a = a.strip()
  749. if a == "0":
  750. print1("Error! No Device found!")
  751. print1(a)
  752. step_status[step_num] = 'f' # failed
  753. result_msg[step_num] = a
  754. else:
  755. print1(a)
  756. step_status[step_num] = 'p' # passed
  757. result_msg[step_num] = a
  758. def step25_routine():
  759. global step_status
  760. global result_msg
  761. step_num = 25
  762. step_status[step_num] = 'r' # running
  763. print1("\n----------------------------------------------------")
  764. print1("Step " + str(step_num) + " Started USB3.0 test 1...")
  765. # step_status[step_num] = 'p' # passed
  766. # result_msg[step_num] = 'AAPASS'
  767. # return;
  768. tkMessageBox.showinfo("Message Box", "LED test! 电池健康指示灯/充电指示灯/心跳灯.")
  769. time.sleep(1)
  770. # os.system("sh os-ver.sh 4K &")
  771. time.sleep(1)
  772. if not tkMessageBox.askokcancel("PASS?", "LED test-确定电池健康指示灯/充电指示灯/心跳灯正常吗?"):
  773. time.sleep(1)
  774. print1("Error! No Device found!")
  775. print1("The video is playing abnormally! - 4K suspend")
  776. step_status[step_num] = 'f' # failed
  777. return;
  778. time.sleep(1)
  779. print1("Battery health indicator/charging indicator/heartbeat light test normally!")
  780. step_status[step_num] = 'p' # passed
  781. result_msg[step_num] = 'PASS'
  782. def step26_routine():
  783. global step_status
  784. global result_msg
  785. step_num = 26
  786. step_status[step_num] = 'r' # running
  787. print1("\n----------------------------------------------------")
  788. print1("Step " + str(step_num) + " Started keyboard test...")
  789. step_status[step_num] = 'p' # passed
  790. result_msg[step_num] = 'AAPASS'
  791. return;
  792. # os.system("sh os-ver.sh keyboard")
  793. # time.sleep(1)
  794. a = os.popen('sh os-ver.sh keyboard').read()
  795. if tkMessageBox.askokcancel("PASS?", "确定键盘测试是否正常?"):
  796. step_status[step_num] = 'p' # passed
  797. result_msg[step_num] = 'PASS'
  798. return;
  799. a = a.replace('\n', '')
  800. a = a.replace('\r', '')
  801. a = a.strip()
  802. print1("Error! No Device found!")
  803. print1(a)
  804. step_status[step_num] = 'f' # failed
  805. def step27_routine():
  806. global step_status
  807. global result_msg
  808. step_num = 27
  809. step_status[step_num] = 'r' # running
  810. print1("\n----------------------------------------------------")
  811. print1("Step " + str(step_num) + " Started touchpad test 1...")
  812. step_status[step_num] = 'p' # passed
  813. result_msg[step_num] = 'AAPASS'
  814. return;
  815. a = os.popen('sh os-ver.sh TP').read()
  816. if tkMessageBox.askokcancel("PASS?", "确定触摸板测试是否正常?"):
  817. step_status[step_num] = 'p' # passed
  818. result_msg[step_num] = 'PASS'
  819. return;
  820. a = a.replace('\n', '')
  821. a = a.replace('\r', '')
  822. a = a.strip()
  823. print1("Error! No Device found!")
  824. print1(a)
  825. step_status[step_num] = 'f' # failed
  826. def step28_routine():
  827. global step_status
  828. global result_msg
  829. step_num = 28
  830. step_status[step_num] = 'r' # running
  831. print1("\n----------------------------------------------------")
  832. print1("Step " + str(step_num) + " Started RTC test 1...")
  833. # step_status[step_num] = 'p' # passed
  834. # result_msg[step_num] = 'AAPASS'
  835. # return;
  836. time.sleep(1)
  837. # tkMessageBox.showinfo("Message Box", "RTC test! RTC电池测试.")
  838. a = os.popen("sh os-ver.sh RTCBATTERY").read()
  839. a = a.replace('\n', '')
  840. a = a.replace('\r', '')
  841. a = a.strip()
  842. print1("\n----------------------------------------------------")
  843. try:
  844. a_int = int(a)
  845. if 3000 <= a_int <= 4000:
  846. # print1("Error! No Device found!")
  847. print1(a)
  848. step_status[step_num] = 'p' # passed
  849. result_msg[step_num] = a
  850. else:
  851. print1(a)
  852. print1("Error! No Device found!")
  853. step_status[step_num] = 'f' # failed
  854. result_msg[step_num] = a
  855. except ValueError:
  856. step_status[step_num] = 'f' # failed
  857. result_msg[step_num] = "Invalid output: {a}"
  858. # else:
  859. # print1("Error! No Device found!")
  860. # print1(a)
  861. # step_status[step_num] = 'f' # failed
  862. # result_msg[step_num] = a
  863. # $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  864. class MasterThread(threading.Thread):
  865. def __init__(self, guiobj):
  866. super(MasterThread, self).__init__()
  867. def run(self):
  868. global step_status
  869. global script_ver
  870. print1("X86 C180####################################################", 1)
  871. print1(script_ver)
  872. step1_routine()
  873. if step_status[1] == 'p' or step_status[1] == 'f': # if step 1 passed
  874. step2_routine()
  875. if step_status[2] == 'p' or step_status[2] == 'f':
  876. step3_routine()
  877. if step_status[3] == 'p' or step_status[3] == 'f':
  878. step4_routine()
  879. if step_status[4] == 'p' or step_status[4] == 'f':
  880. step5_routine()
  881. if step_status[5] == 'p' or step_status[5] == 'f':
  882. step6_routine()
  883. if step_status[6] == 'p' or step_status[6] == 'f':
  884. step7_routine()
  885. if step_status[7] == 'p' or step_status[7] == 'f':
  886. step8_routine()
  887. if step_status[8] == 'p' or step_status[8] == 'f':
  888. step9_routine()
  889. if step_status[9] == 'p' or step_status[9] == 'f':
  890. step10_routine()
  891. if step_status[10] == 'p' or step_status[10] == 'f':
  892. step11_routine()
  893. if step_status[11] == 'p' or step_status[11] == 'f':
  894. step12_routine()
  895. if step_status[12] == 'p' or step_status[12] == 'f':
  896. step13_routine()
  897. if step_status[13] == 'p' or step_status[13] == 'f':
  898. step14_routine()
  899. if step_status[14] == 'p' or step_status[14] == 'f':
  900. step15_routine()
  901. if step_status[15] == 'p' or step_status[15] == 'f':
  902. step16_routine()
  903. if step_status[16] == 'p' or step_status[16] == 'f':
  904. step17_routine()
  905. if step_status[17] == 'p' or step_status[17] == 'f':
  906. step18_routine()
  907. if step_status[18] == 'p' or step_status[18] == 'f':
  908. step19_routine()
  909. if step_status[19] == 'p' or step_status[19] == 'f':
  910. step20_routine()
  911. if step_status[20] == 'p' or step_status[20] == 'f':
  912. step21_routine()
  913. if step_status[21] == 'p' or step_status[21] == 'f':
  914. step22_routine()
  915. if step_status[22] == 'p' or step_status[22] == 'f':
  916. step23_routine()
  917. if step_status[23] == 'p' or step_status[23] == 'f':
  918. step24_routine()
  919. if step_status[24] == 'p' or step_status[24] == 'f':
  920. step25_routine()
  921. if step_status[25] == 'p' or step_status[25] == 'f':
  922. step26_routine()
  923. if step_status[26] == 'p' or step_status[26] == 'f':
  924. step27_routine()
  925. if step_status[27] == 'p' or step_status[27] == 'f':
  926. step28_routine()
  927. print1("\n----------------------------------------------------")
  928. print1("Test concluded!")
  929. # $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  930. class GuiThread(object):
  931. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  932. def __init__(self):
  933. global log_file
  934. global result_msg
  935. self.thread_list = {}
  936. self.running = False
  937. self.counter = 0
  938. self.root = Tk()
  939. self.root.geometry("1800x1200")
  940. self.root.protocol("WM_DELETE_WINDOW", self.destroy) # when user closes the window
  941. self.root.title("WiPER: FT Simular Test")
  942. self.note1 = Label(self.root, text="Please press 'Start Test' to begin...", fg='blue')
  943. self.button1 = Button(self.root, text="Start Test", command=self.start)
  944. self.lbl = Label(self.root, text="NOT STARTED", width=15, bg='gray')
  945. self.lbl2 = Label(self.root, text="Device: ", width=20, bg="#C6EBFF")
  946. self.nb = ttk.Notebook(self.root, name='notebook')
  947. self.textframe1 = Frame(self.root)
  948. self.text1 = Text(self.textframe1)
  949. self.scrollbar1 = Scrollbar(self.textframe1)
  950. self.paramframe = Frame(self.root)
  951. self.lblframe = Frame(self.root)
  952. # 创建按钮列表
  953. self.step_buttons = []
  954. # 创建标签列表
  955. self.step_name_list = [] # 步骤描述标签
  956. self.step_status_list = ["x"] # 步骤状态标签
  957. # 步骤描述文本列表
  958. step_descriptions = [
  959. "Step1: 检查BIOS版本号",
  960. "Step2: 检查EC版本号",
  961. "Step3: 检查CPU测试",
  962. "Step4: 检查Memory内存版本号",
  963. "Step5: 检查HDD硬盘版本号",
  964. "Step6: 检查OS操作系统版本号",
  965. "Step7: HDMI功能测试",
  966. "Step8: 相机功能测试",
  967. "Step9: 检查SPEAKER耳机测试",
  968. "Step10: 检查耳机录音测试",
  969. "Step11: 检查usb2.0后接口1U盘基本功能测试",
  970. "Step12: 检查usb2.0后接口2U盘基本功能测试",
  971. "Step13: 检查整个hub全usb3.0接口1号位置基本功能测试",
  972. "Step14: 检查整个hub全usb3.0接口2号位置基本功能测试",
  973. "Step15: 检查整个hub全usb3.0接口3号位置基本功能测试",
  974. "Step16: 检查整个hub全usb3.0接口4号位置基本功能测试",
  975. "Step17: 检查网络在线速度测试",
  976. "Step18: 串口基本功能测试",
  977. "Step19: 电池包测试",
  978. "Step20: 720p视频测试",
  979. "Step21: 1080p视频测试",
  980. "Step22: 4K视频测试",
  981. "Step23: 检查带网口hub的usb3.0接口1号基本功能测试",
  982. "Step24: 检查带网口hub的usb3.0接口2号基本功能测试",
  983. "Step25: 电池健康指示灯/充电指示灯/心跳灯",
  984. "Step26: 外置键盘测试C180",
  985. "Step27: 触摸板测试C180",
  986. "Step28: RTC电池"
  987. ]
  988. # 创建按钮和标签
  989. for i, desc in enumerate(step_descriptions, 1):
  990. # 创建按钮
  991. btn = Button(self.lblframe, text="Run Step {}".format(i), command=lambda num=i: self.run_single_step(num),
  992. width=12, bg='lightblue')
  993. self.step_buttons.append(btn)
  994. # 创建步骤描述标签
  995. item_lable = Label(self.lblframe, text=desc, width=50)
  996. self.step_name_list.append(item_lable)
  997. # 创建状态标签
  998. status_label = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  999. self.step_status_list.append(status_label)
  1000. result_msg.append("P")
  1001. #
  1002. # self.step1_lbl1 = Label(self.lblframe, text="Step1: 检查BIOS版本号 ", width=50)
  1003. # self.step1_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1004. # self.step_status_list.append(self.step1_lbl2)
  1005. # result_msg.append('P')
  1006. self.my_io_process = IO_process(log_file)
  1007. self.readLog1()
  1008. self.set_param_frame()
  1009. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1010. def destroy(self):
  1011. if tkMessageBox.askokcancel("Quit?", "Are you sure you want to quit?"):
  1012. self.root.quit()
  1013. def counter_label(self):
  1014. def count():
  1015. if self.running:
  1016. global counter
  1017. if self.counter == 0: # 66600
  1018. display = "Starting..."
  1019. else:
  1020. tt = datetime.fromtimestamp(self.counter)
  1021. string = tt.strftime("%H:%M:%S")
  1022. display = string
  1023. self.note1.config(text=display)
  1024. self.note1.after(1000, count)
  1025. self.counter += 1
  1026. count()
  1027. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1028. def run(self):
  1029. self.note1.pack()
  1030. self.button1.pack(side=TOP, padx=10, pady=3)
  1031. self.lbl.pack()
  1032. self.lbl2.pack(fill=BOTH, expand=Y)
  1033. self.scrollbar1.config(command=self.text1.yview)
  1034. self.text1.config(yscrollcommand=self.scrollbar1.set)
  1035. self.text1.pack(side=LEFT, fill=Y)
  1036. self.scrollbar1.pack(side=RIGHT, fill=Y)
  1037. for i in range(28):
  1038. row = i
  1039. self.step_buttons[i].grid(row=row, column=0, sticky=W, padx=5)
  1040. self.step_name_list[i].grid(row=row, column=1, sticky=W)
  1041. self.step_name_list[i].grid(row=row, column=1, sticky=W)
  1042. self.step_status_list[i + 1].grid(row=row, column=2, sticky=W)
  1043. self.lblframe.pack()
  1044. self.textframe1.pack()
  1045. self.paramframe.pack()
  1046. self.nb.add(self.lblframe, text='Status')
  1047. self.nb.add(self.textframe1, text='Log')
  1048. self.nb.add(self.paramframe, text='Parameters')
  1049. self.nb.enable_traversal() # enable keyboard traversal using Ctrl+Tab
  1050. self.nb.pack(fill=BOTH, expand="true", padx=5, pady=1)
  1051. self.root.mainloop()
  1052. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1053. def readLog1(self):
  1054. # This function periodically reads and empties the log buffer
  1055. global log1_buffer
  1056. if log1_buffer != "":
  1057. self.text1.insert(END, log1_buffer)
  1058. text = self.my_io_process.read_file()
  1059. if text != "":
  1060. self.text1.insert(END, text)
  1061. if log1_buffer != "" or text != "": # if log buffer was populated
  1062. self.text1.yview_pickplace("end") # move the scrollbar to the bottom
  1063. log1_buffer = "" # empty the log buffer
  1064. self.root.update() # update the screen
  1065. self.root.after(100, self.readLog1)
  1066. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1067. def set_param_frame(self):
  1068. global params_dict
  1069. self.L = []
  1070. self.E = []
  1071. count = 1
  1072. for key, value in params_dict.items():
  1073. lbl = Label(self.paramframe, text=key)
  1074. enty = Entry(self.paramframe, bd=4)
  1075. enty.delete(0, END)
  1076. enty.insert(0, value)
  1077. enty.config(state=DISABLED)
  1078. lbl.grid(row=count, sticky=W)
  1079. enty.grid(row=count, column=1)
  1080. self.L.append(lbl)
  1081. self.E.append(enty)
  1082. count = count + 1
  1083. def run_single_step(self, step_num):
  1084. """运行单个测试步骤"""
  1085. global step_status
  1086. # 重置该步骤的状态
  1087. step_status[step_num] = 'r'
  1088. # 根据步骤号调用对应的函数
  1089. step_functions = {
  1090. 1: step1_routine,
  1091. 2: step2_routine,
  1092. 3: step3_routine,
  1093. 4: step4_routine,
  1094. 5: step5_routine,
  1095. 6: step6_routine,
  1096. 7: step7_routine,
  1097. 8: step8_routine,
  1098. 9: step9_routine,
  1099. 10: step10_routine,
  1100. 11: step11_routine,
  1101. 12: step12_routine,
  1102. 13: step13_routine,
  1103. 14: step14_routine,
  1104. 15: step15_routine,
  1105. 16: step16_routine,
  1106. 17: step17_routine,
  1107. 18: step18_routine,
  1108. 19: step19_routine,
  1109. 20: step20_routine,
  1110. 21: step21_routine,
  1111. 22: step22_routine,
  1112. 23: step23_routine,
  1113. 24: step24_routine,
  1114. 25: step25_routine,
  1115. 26: step26_routine,
  1116. 27: step27_routine,
  1117. 28: step28_routine,
  1118. }
  1119. if step_num in step_functions:
  1120. # 在新线程中运行步骤,避免阻塞GUI
  1121. def run_step():
  1122. step_functions[step_num]()
  1123. # 更新UI状态
  1124. self.root.after(0, self.update_step_status)
  1125. thread = threading.Thread(target=run_step)
  1126. thread.start()
  1127. def update_step_status(self):
  1128. """更新步骤状态显示"""
  1129. global step_status
  1130. total_no_of_steps = len(step_status) - 1
  1131. for i in range(1, total_no_of_steps + 1):
  1132. if step_status[i] == 'r':
  1133. self.step_status_list[i]["text"] = "RUNNING..."
  1134. self.step_status_list[i]["bg"] = 'yellow'
  1135. elif step_status[i] == 'p':
  1136. self.step_status_list[i]["text"] = result_msg[i]
  1137. self.step_status_list[i]["bg"] = 'green'
  1138. elif step_status[i] == 'f':
  1139. self.step_status_list[i]["text"] = "ERROR!"
  1140. self.step_status_list[i]["bg"] = 'red'
  1141. # 继续监控状态变化
  1142. self.root.after(200, self.update_step_status)
  1143. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1144. def start(self):
  1145. global step_status
  1146. running = True
  1147. # self.counter_label()
  1148. # step_status = ['x', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns'] #
  1149. step_status = ['x', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns',
  1150. 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns'] #
  1151. self.button1.config(state=DISABLED) # disable the start button
  1152. self.text1.delete('1.0', 'end') # delete the log
  1153. self.my_io_process.reset_counter()
  1154. self.thread_list['thread'] = MasterThread(self)
  1155. self.thread_list['thread'].start()
  1156. self.manage()
  1157. self.manage_lblframe()
  1158. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1159. def manage(self):
  1160. # manage the pop-up dialog boxes
  1161. global step_status
  1162. total_no_of_steps = len(step_status) - 1
  1163. flag = 0
  1164. count = 0
  1165. for i in range(1, total_no_of_steps + 1):
  1166. if step_status[i] == 'f': # if failed
  1167. # tkMessageBox.showinfo("Message Box", "Error on Step " + str(i) + "! See Log for details.")
  1168. print1("Error on Step " + str(i) + "! See Log for details.")
  1169. flag = 1
  1170. time.sleep(1)
  1171. write_log_to_file(self.text1.get('1.0', 'end'))
  1172. print1("Log written to the external txt file under ./Logs/")
  1173. if step_status[i] == 'p' or step_status[i] == 'f': # if passed
  1174. count = count + 1
  1175. if count == total_no_of_steps: # if all the steps were successful
  1176. flag = 1
  1177. tkMessageBox.showinfo("Message Box",
  1178. "Test succesfully done!") # Please safely remove the device from the chamber.
  1179. print1("Test succesfully done! Please safely remove the device from the chamber.")
  1180. time.sleep(1)
  1181. write_log_to_file(self.text1.get('1.0', 'end'))
  1182. print1("Log written to the external txt file under ./Logs/")
  1183. self.running = False
  1184. self.counter = 0
  1185. if flag == 0: # if not(any step failed or all steps passed)
  1186. self.root.after(500, self.manage)
  1187. else: # if any step has failed or if all the steps have passed
  1188. self.button1.config(state=NORMAL) # enable the start button
  1189. self.my_io_process.empty_file()
  1190. return 0
  1191. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1192. def manage_lblframe(self):
  1193. # manage the frame that displays the step-by-step status
  1194. # manage the top-level status Label
  1195. global step_status
  1196. global device_info
  1197. global result_msg
  1198. total_no_of_steps = len(step_status) - 1
  1199. try:
  1200. SrNo = device_info['SrNo']
  1201. string = "Device: " + SrNo
  1202. self.lbl2.config(text=string)
  1203. except:
  1204. string = "Device: "
  1205. self.lbl2.config(text=string)
  1206. flag = 0
  1207. count1 = 0
  1208. count2 = 0
  1209. count3 = 0
  1210. # self.counter_label()
  1211. for i in range(1, total_no_of_steps + 1):
  1212. if step_status[i] == 'r': # if running
  1213. self.step_status_list[i]["text"] = "RUNNING..."
  1214. self.step_status_list[i]["bg"] = 'yellow'
  1215. self.lbl.config(bg='yellow')
  1216. self.lbl.config(text='RUNNING...')
  1217. self.running = True
  1218. # self.counter_label()
  1219. if step_status[i] == 'p': # if passed
  1220. self.step_status_list[i]["text"] = result_msg[i]
  1221. self.step_status_list[i]["bg"] = 'green'
  1222. count2 = count2 + 1
  1223. if step_status[i] == 'f': # if failed
  1224. self.step_status_list[i]["text"] = "ERROR!"
  1225. self.step_status_list[i]["bg"] = 'red'
  1226. self.lbl.config(bg='red')
  1227. self.lbl.config(text='ERROR!')
  1228. # flag = 1
  1229. count3 = count3 + 1
  1230. if step_status[i] == 'ns': # if not started
  1231. self.step_status_list[i]["text"] = "NOT STARTED"
  1232. self.step_status_list[i]["bg"] = 'gray'
  1233. count1 = count1 + 1
  1234. if count1 == total_no_of_steps: # if none of the steps have started
  1235. self.lbl.config(bg='gray')
  1236. self.lbl.config(text='NOT STARTED')
  1237. if count2 == total_no_of_steps: # if all the steps are done
  1238. self.lbl.config(bg='green')
  1239. self.lbl.config(text='DONE!')
  1240. flag = 1
  1241. if flag == 0: # if there is no error and all the steps aren't done yet
  1242. self.root.after(200, self.manage_lblframe)
  1243. else: # if there is an error or if all the steps are done already
  1244. device_info['SrNo'] = ""
  1245. return 0
  1246. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1247. # $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  1248. if __name__ == "__main__":
  1249. g = GuiThread()
  1250. g.run()