1
2
3
4
5
6
7
8
9
10
11
12
13
14
15import matplotlib
16matplotlib.use('TkAgg')
17
18import sys
19import pylab as p
20import time
21
22import isystem.connect as ic
23from isystem.connect import IConnectDebug as ICDebug
24
25if __name__ == '__main__':
26 winidea_id = ''
27
28 cmgr = ic.ConnectionMgr()
29 cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
30
31 debugCtrl = ic.CDebugFacade(cmgr)
32 debugCtrl.download()
33 debugCtrl.deleteAll()
34 debugCtrl.runUntilFunction('main')
35 debugCtrl.waitUntilStopped()
36 debugCtrl.run()
37
38
39 ax = p.subplot(111)
40 canvas = ax.figure.canvas
41
42 if len(sys.argv) < 2:
43 varName = 'main_loop_counter'
44 print('No target variable name specified in cmd line, using default: ' + varName)
45 else:
46 varName = sys.argv[1]
47 print('Drawing chart for target variable: ' + varName)
48
49
50 x = range(0, 500)
51 lineData = [0]*len(x)
52 line, = p.plot(x, lineData, animated=True, lw=2)
53
54
55 p.axis([0, 500, -2000, 2000])
56
57
58 def run(*args):
59 background = canvas.copy_from_bbox(ax.bbox)
60 run.flag = True
61 startTime = time.time()
62
63 while run.flag:
64
65 canvas.restore_region(background)
66
67
68 del lineData[0]
69
70 main_loop_counter = debugCtrl.evaluate(ICDebug.fRealTime, varName)
71 lineData.append(main_loop_counter.getInt())
72 line.set_ydata(lineData)
73
74
75 ax.draw_artist(line)
76
77 canvas.blit(ax.bbox)
78
79 if (time.time() - startTime) > 5:
80 print('Recording finished!')
81 run.flag = False
82
83
84 p.subplots_adjust(left=0.3, bottom=0.3)
85 p.grid()
86 manager = p.get_current_fig_manager()
87 manager.window.after(100, run)
88
89 p.show()