2.3. Wrapper
2.3.1. Modules
The Python Wrapper contains of 5 modules:
EcWrapperPython.pyEcMotionPython.pyEcWrapperPythonTypes.pyPython types
EcWrapper.pyCPython interface (internal)
EcWrapperTypes.pyCPython types (internal)
2.3.2. Return code vs. exception handling
The most of all API functions returns a return code for error handling. This behaviour can be changed to throw an exception in error case by simply setting:
CEcWrapperPython.EnableExceptionHandling = True # default is False
2.3.3. API with “out” or “ref” parameters
The Python Wrapper API is based on C# code. C# supports out and ref keywords for parameters. This is not supported in Python and is solved by simply submitting CEcWrapperPythonOutParam or CEcWrapperPythonRefParam to those functions:
# This function has an "out" parameter "out_oSbStatus"
def GetScanBusStatus(self, out_oSbStatus):
# ...
return
# Create "out" parameter
out_oStatus = CEcWrapperPythonOutParam()
# Call function
pythonWrapper.GetScanBusStatus(out_oStatus)
# Get the "out" parameter value
oStatus = out_oStatus.value
# Now, the "oStatus" object can be used
print(oStatus.dwResultCode)