Psim_DS_GetParameters
Usage
psim.Psim_DS_GetParameters();
Python Help
py.help(psim.Psim_DS_GetParameters)
Python def
PSIM 2025 and above:
def Psim_DS_GetParameters(self, schFilePath_or_Obj):
result = 0
ErrorMessage = ""
szParameters = ""
nParamCount = 0
try:
if not self.IsValid():
ErrorMessage = "PSIM object was not loaded."
Result = 0;
return result , szParameters, nParamCount, ErrorMessage;
sch_closeFile = False
schHandle = 0
#is schFilePath a filePath or schematicID?
if isinstance(schFilePath_or_Obj, PSIM_schematic):
schHandle = schFilePath_or_Obj.value
elif isinstance(schFilePath_or_Obj, str):
schFilePath = schFilePath_or_Obj
SimOpenSchematicFileW = getattr(self.psimHandle, "SimOpenSchematicFileW")
if not SimOpenSchematicFileW:
raise AttributeError(self.VersionErrorMessage)
SimOpenSchematicFileW.restype = ctypes.c_int
# int SimOpenSchematicFileW(const wchar_t * szFileName, UINT nFlag)
schHandle = SimOpenSchematicFileW(ctypes.c_wchar_p(schFilePath), ctypes.c_int (1)); #returns 0 on error
if schHandle == 0 :
ErrorMessage = "Unable to open schematic file " + schFilePath
Result = 0;
return result , szParameters, nParamCount, ErrorMessage;
sch_closeFile =True
elif schFilePath_or_Obj is None:
ErrorMessage = "in Psim_DS_GetParameters function, schFilePath_or_Obj is None"
Result = 0;
return result , szParameters, nParamCount, ErrorMessage;
else:
ErrorMessage = "in Psim_DS_GetParameters function, schFilePath_or_Obj is of an unknown type"
Result = 0;
return result , szParameters, nParamCount, ErrorMessage;
# int EXPORT DS_GetParameterList(int nID, int * pParameterCount, char* szParameters_szValues, int *pBufferSize)
# get the function pointer
DS_GetParameterList = getattr(self.psimHandle, "DS_GetParameterList")
if not DS_GetParameterList:
raise AttributeError(self.VersionErrorMessage)
DS_GetParameterList.argtypes = [
ctypes.c_int, # nID
ctypes.POINTER(ctypes.c_int), # int* pParameterCount
ctypes.c_char_p, # char* szParameters_szValues
ctypes.POINTER(ctypes.c_int) # int* pBufferSize
]
DS_GetParameterList.restype = ctypes.c_int # Return type
# call DS_GetParameterFile
pParameterCount = ctypes.c_int(0) # Initial value for pParameterCount
initial_buffer_size = 1000
buffer_size = initial_buffer_size
pBufferSize = ctypes.c_int(buffer_size) # Set initial pBufferSize to buffer size
# Allocate buffer
szParameters_szValues = ctypes.create_string_buffer(buffer_size)
# Call the function
result = DS_GetParameterList(
schHandle,
ctypes.byref(pParameterCount),
szParameters_szValues,
ctypes.byref(pBufferSize)
)
if result == 0:
if pBufferSize.value > initial_buffer_size:
initial_buffer_size = pBufferSize.value
szParameters_szValues2 = ctypes.create_string_buffer(initial_buffer_size) # Allocate memory
result = DS_GetParameterList(
schHandle,
ctypes.byref(pParameterCount),
szParameters_szValues2,
ctypes.byref(pBufferSize)
)
if result == 0:
ErrorMessage = "in Psim_DS_GetParameters function: Failed to retrieve parameters."
result = 0
else:
# Retrieve the output values
nParamCount = pParameterCount.value
updated_pBufferSize = pBufferSize.value
szParameters = szParameters_szValues2.value.decode('utf-8')
result = 1
else:
ErrorMessage = "in Psim_DS_GetParameters function: Failed to retrieve parameters, may not be a Design Suite schematic file. "
result = 0
else:
# Retrieve the output values
szParameters = szParameters_szValues.value.decode('utf-8')
updated_pBufferSize = pBufferSize.value
nParamCount = pParameterCount.value
result = 1
if sch_closeFile:
CloseSchematicFile = getattr(self.psimHandle, "SimCloseSchematicFile")
if not CloseSchematicFile:
raise AttributeError(self.VersionErrorMessage)
CloseSchematicFile.restype = ctypes.c_int
# int SimCloseSchematicFile(int nSchematicID)
res = CloseSchematicFile(schHandle); #returns 0 on error
except Exception as e:
Result = 0
ErrorMessage += f"Error: {e}"
return result , szParameters, nParamCount, ErrorMessage;