5import isystem.connect
as ic
8class WorkspaceConfigurator():
9 def __init__(self, cmgr: ic.ConnectionMgr):
11 self.wsCtrl = ic.CWorkspaceController(cmgr)
12 self.configCtrl = ic.CConfigurationController(cmgr)
14 def create_workspace(self, workspaceFileName: str, workspaceDir:str =
None):
16 Creates a new workspace.
17 @param workspaceFileName: Name
for the created workspace.
18 @param workspaceDir: Directory where the new workspace gets generated.
21 if workspaceDir
is None:
22 workspaceDir = os.getcwd()
23 wsPath=os.path.join(workspaceDir, workspaceFileName)
26 self.wsCtrl.newWS(wsPath)
29 def save_workspace(self):
35 def close_workspace(self):
42 def set_emulator_type(self, Type: str):
44 Sets the emulator type used.
45 @param Type: Type of emulator used.
46 Options available are iC5000, iC5500, iC5700, iC6000
and XCP
49 optHardware = ic.COptionController(self.cmgr,
'/iOPEN/Hardware')
52 optHardware.set(
'Emulator', Type)
54 def set_USB_comm(self, device: str =
''):
56 Sets the emulator to use USB connection.
57 @param device: USB device name composed
from emulator type
and the
58 emulator serial number. Used when there are more than 1 emulator
59 connected to your PC, otherwise it can remain empty.
60 More information: https://www.isystem.com/downloads/winIDEA/help/winidea-configuration-communication-type.html
62 optCommunication = ic.COptionController(self.cmgr, '/iOPEN/Communication')
64 inParams[
'Mode'] =
'USB'
65 inParams[
'USBDeviceName'] = device
68 optCommunication.set_multi(inParams)
71 def set_TCP_comm(self, IP: str, port: str, useGlobalDiscoveryPort: bool=
True):
73 Sets the emulator to use TCP connection.
74 @param port: Selects which TCP port to use.
75 @param ipAddress: Device description. This option can be host name,
76 device ip address
or 'localhost'.
77 More information: https://www.isystem.com/downloads/winIDEA/help/winidea-configuration-communication-type.html
78 @param useGlobalDiscoveryPort: Switches on
or off
global discovery port.
79 This parameter
is used
for emulator discovery on the network.
83 optCommunication = ic.COptionController(self.cmgr,
'/iOPEN/Communication')
88 inParams[
'Mode'] =
'TCP'
89 inParams[
'TCPPortNumber'] = port
90 inParams[
'IPAddress'] = IP
91 if useGlobalDiscoveryPort:
92 inParams[
'IPUseGlobalDiscoveryPort'] =
'true'
94 inParams[
'IPUseGlobalDiscoveryPort'] =
'false'
97 optCommunication.set_multi(inParams)
99 def set_SoC(self, name: str):
101 Selects which target is connected.
102 @param name: Name of the target device. List of devices
is available
103 in the device drop down menu: https://www.isystem.com/downloads/winIDEA/help/advanced-soc-configuration.html.
107 optSoC = self.configCtrl.ide_SoC(
'MCU')
109 optSoC.set(
'SFRName', name)
111 def add_application(self, name: str):
113 Adds a new application.
114 @param name: Name of the created application.
117 optApps = self.configCtrl.ide_apps()
118 optApp = optApps.add()
121 optApp.set(
'Name', name)
124 def add_symbol_file(self, appName: str, path: str, Type: str):
126 Adds a symbol file to the application.
127 @param appName: Name of the application to which the symbol file
is added.
128 @param path: Path to the symbol file.
129 @param Type: Type of the symbol file.
130 Options available are BIN, ELF, HEX, OMF51,
131 25(OFM2 251/MX51), SIT(SLO text), TMSCOFF, UBROF
and S37.
133 optApps = self.configCtrl.ide_apps()
134 appIndex = optApps.index_of("Name", appName)
135 optApp = optApps.at(appIndex)
138 optSymbolFile = optApp.opt(
'SymbolFiles.File').add()
141 optSymbolFile.set(
'Path', path)
144 optSymbolFile.set(
'Options.Type', Type)
147 def add_memory_space(self, name: str, coreName: str, appName: str,
148 isEnabled: bool =
True, useMsid: bool =
False, msidLevel: str =
''):
150 Adds a new memory space.
151 @param name: Name
for the created memory space.
152 @param coreName: Name of the core which
is associated
with
153 the created memory space.
154 @param appName: Name of the application which
155 is associated
with the created memory space.
156 @param isEnabled: Selects
if the memory space
is enabled.
157 @param useMsid: Selects
if MSID
is used.
158 @param msidLevel: Selects which MSID level
is used.
162 optSoC = self.configCtrl.ide_SoC(
'MCU')
163 optMemSpace = optSoC.opt(
"MemorySpaces")
166 optMyMemSpace = optMemSpace.add()
171 inParams[
'Enabled'] =
'true'
173 inParams[
'Enabled'] =
'false'
174 inParams[
'UserName'] = name
175 inParams[
'Cores'] = coreName
176 inParams[
'Application'] = appName
180 inParams[
'MSID.Use'] =
'true'
181 inParams[
'MSID.Level'] = msidLevel
183 inParams[
'MSID.Use'] =
'false'
186 optMyMemSpace.set_multi(inParams)
188 def add_program_file(self, path: str, Type: str,
192 @param path: Path of the program file.
193 @param programFileType: Type of the program file.
194 Options available are BIN, ELF, HEX
and S37.
195 @param offset: Download offset of the program file.
197 optSoC = self.configCtrl.ide_SoC('MCU')
198 optProgFile = optSoC.opt(
"DLFs_Program.File")
199 optProgFile = optProgFile.add()
202 inParams[
'Path'] = path
203 inParams[
'Options.Type'] = Type
204 inParams[
'Options.CodeOffset'] = str(offset)
206 optProgFile.set_multi(inParams)
208 def set_demo_mode(self, isDemoModeOn: bool):
210 Enables demo mode for winIDEA.
211 @param cmgr: ConnectionMgr instance.
212 @param isDemoModeOn: Enables
or disables demo mode.
215 ideCtrl = ic.CIDEController(self.cmgr)
216 params = ic.StrStrMap()
218 params[
"Demo"] =
"TRUE"
219 ideCtrl.invoke(
"/IDE/Demo", params)
221 params[
"Demo"] =
"FALSE"
222 ideCtrl.invoke(
"/IDE/Demo", params)
225 def create_analyzer_trigger(self, profilerCtrl: ic.CProfilerController2, triggerName: str) -> int:
227 Creates a new Analyzer trigger and returns index.
228 @param profilerCtrl: Profiler controller instance.
229 @param triggerName: Trigger name
232 profilerCtrl.removeTrigger(triggerName)
235 triggerIdx = profilerCtrl.createTrigger(triggerName)
236 profilerCtrl.select(triggerIdx)
239 def remove_existing_process_triggers(self, optProcessTrigger: ic.COptionController):
241 Removes all existing process triggers.
242 @param optProcessTrigger: Process trigger option controller instance.
244 while optProcessTrigger.size():
245 optProcessTrigger.remove(0)
247 def add_new_process_trigger(self, optProcessTrigger: ic.COptionController, appName: str,
248 memorySpaceName: str) -> ic.COptionController:
250 Adds a new process trigger.
251 @param optProcessTrigger: Process trigger option controller instance.
252 @param appName: Name of the application.
253 @param MemorySpaceName: Name of the memory space.
255 optProcessTriggerInstance = optProcessTrigger.add()
256 optProcessTriggerInstance.set('ProcessURL', appName +
'/' + memorySpaceName)
257 return optProcessTriggerInstance
259 def add_new_profiler_data_area(self, optProfilerData: ic.COptionController, variableName: str,
260 appName: str, memorySpaceName: str, interpretationType: str, accessType: str):
262 Adds a new profiler data area.
263 @param optProfilerData: Profiler data option controller instance.
264 @param variableName: Name of the variable to profile.
265 @param interpretationType: Profiler data interpretation type.
266 Available types are State, Function, Regular
and Sampling.
267 @param accessType: Type of data access.
268 Available types are Write, Read
and WriteAndRead.
271 optProfilerDataArea = optProfilerData.add()
275 inParams[
'Name'] = f
'{variableName},,,{appName}/{memorySpaceName}'
276 inParams[
'Type'] = interpretationType
277 inParams[
'DataType'] =
'Variable'
278 inParams[
'AccessType'] = accessType
280 optProfilerDataArea.set_multi(inParams)