winIDEA SDK
Loading...
Searching...
No Matches
dynamic_options.py
1# This script is licensed under BSD License, see file LICENSE.txt, or search for `License` in the SDK online help.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import isystem.connect as ic
6
7
8winidea_id = ''
9
10
11def printAllBPs():
12
13 numOfBreakpoints = ideCtrl.getDynamicOptionSize('/IDE/ExecBPs.BP')
14
15 for i in range(0, numOfBreakpoints):
16 print('- location: ' + ideCtrl.getOptionStr('/IDE/ExecBPs.BP[' + str(i) + '].Location'))
17 print(' enabled: ' + str(ideCtrl.getOptionInt('/IDE/ExecBPs.BP[' + str(i) + '].Enabled')))
18 print(' condition: ' + str(ideCtrl.getOptionInt('/IDE/ExecBPs.BP[' + str(i) + '].Condition')))
19 print(' count: ' + str(ideCtrl.getOptionInt('/IDE/ExecBPs.BP[' + str(i) + '].Count')))
20 # example of the long form of getOptionStr
21 print(' expression: ' + ideCtrl.getOptionStr(ic.ofDestIDE, '', 'ExecBPs.BP[' + str(i) + '].Expression'))
22
23def main():
24 cmgr = ic.ConnectionMgr()
25 cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
26
27 ideCtrl = ic.CIDEController(cmgr)
28
29 numOfBreakpoints = ideCtrl.getDynamicOptionSize('/IDE/ExecBPs.BP')
30
31 print("Number of breakpoints: ", numOfBreakpoints)
32
33 numOfDlFiles = ideCtrl.getDynamicOptionSize('/IDE/Debug.DownloadFiles.File')
34 print("Number of dl. files: ", numOfDlFiles)
35
36 downloadFiles = ic.StrVector()
37 ideCtrl.getDynamicOptions('/IDE/Debug.DownloadFiles.File',
38 'Path', downloadFiles)
39 print("List of download files: ")
40 for downloadFile in downloadFiles:
41 print(downloadFile)
42
43 if numOfBreakpoints < 3:
44 raise Exception("Please define at least three breakpoints in winIDEA before running this script!")
45
46 print(r'Index of option "common\main.cpp"::27:',
47 ideCtrl.findDynamicOption('/IDE/ExecBPs.BP',
48 'Location',
49 r'"src\main.cpp"::27'))
50
51 print('Breakpoints defined before running this script:')
52 printAllBPs()
53
54 # insert the option
55 ideCtrl.addDynamicOption('/IDE/ExecBPs.BP', -1)
56 # example of the long form of setOption
57 ideCtrl.setOption(ic.ofDestIDE, '', 'ExecBPs.BP[1].Enabled', 'false')
58
59
60 # append the option with default values
61 ideCtrl.addDynamicOption(ic.ofDestIDE, '', 'ExecBPs.BP')
62
63
64 print('Two new BPs added:')
65 printAllBPs()
66
67
68 # remove dynamic items
69 ideCtrl.removeDynamicOption('/IDE/ExecBPs.BP', 0)
70 print('BP at index 0 removed:')
71 printAllBPs()
72 ideCtrl.removeDynamicOption(ic.ofDestIDE, '', 'ExecBPs.BP')
73
74
75 # verify the result
76 numOfBreakpoints = ideCtrl.getDynamicOptionSize('/IDE/ExecBPs.BP')
77
78 if numOfBreakpoints != 0:
79 raise Exception("Number of breakpoints is expected to be 0, but it is " + str(numOfBreakpoints))
80
81 # append dynamic option and get its URL
82 print('Added option 1: ', ideCtrl.addDynamicOptionUrl('/IDE/ExecBPs.BP', -1))
83 print('Added option 2: ', ideCtrl.addDynamicOptionUrl('/IDE/ExecBPs.BP', -1))
84
85
86if __name__ == "__main__":
87 main()