2.3. Wrapper

2.3.1. Modules

The Python Wrapper contains of 5 modules:

EcWrapperPython.py
class CEcWrapperPython

EC-Wrapper base class

class CEcMasterPython

EC-Master

class CEcMasterRasServerPython

RAS Server for EC-Master

class CEcMasterMbxGatewayClientPython

Mailbox Gateway Client for EC-Master

class CEcMasterMbxGatewayServerPython

Mailbox Gateway Server for EC-Master

class CEcSimulatorPython

EC-Simulator

class CEcSimulatorRasServerPython

RAS Server for EC-Simulator

class CEcRasClientPython

RAS Client for EC-Master / EC-Simulator

EcMotionPython.py
class CEcMotionPython

EC-Motion interface

EcWrapperPythonTypes.py

Python types

EcWrapper.py

CPython interface (internal)

EcWrapperTypes.py

CPython 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)