ecutest.toolaccess

class ecutest.toolaccess.BusSignal(name: str, tool_access: ToolAccess)

Bases: _VarBase

Represents a bus signal in ecu.test.

Warning

Do not instantiate this class manually! Always use ToolAccess.bus_signal() to create instances of this class.

read() → str | int | float | list | tuple | None

Read the current value of this variable from ecu.test.

Returns:

The value of the variable.

Raises:
write(value: str | int | float | list | tuple | None) → None

Write a new value to this variable in ecu.test.

Parameters:
value: str | int | float | list | tuple | None

The value to assign.

Raises:
class ecutest.toolaccess.CalibVar(name: str, tool_access: ToolAccess)

Bases: _VarBase

Represents a calibration variable in ecu.test.

Warning

Do not instantiate this class manually! Always use ToolAccess.calib_var() to create instances of this class.

read() → str | int | float | list | tuple | None

Read the current value of this variable from ecu.test.

Returns:

The value of the variable.

Raises:
write(value: str | int | float | list | tuple | None) → None

Write a new value to this variable in ecu.test.

Parameters:
value: str | int | float | list | tuple | None

The value to assign.

Raises:
class ecutest.toolaccess.Job(name: str, param_names: list[str], tool_access: ToolAccess)

Bases: object

Represents a callable ecu.test job.

Warning

Do not instantiate this class manually! Always use ToolAccess.job() to create instances of this class.

class ecutest.toolaccess.MeasVar(name: str, tool_access: ToolAccess)

Bases: _VarBase

Represents a measurement variable in ecu.test.

Warning

Do not instantiate this class manually! Always use ToolAccess.meas_var() to create instances of this class.

read() → str | int | float | list | tuple | None

Read the current value of this variable from ecu.test.

Returns:

The value of the variable.

Raises:
write(value: str | int | float | list | tuple | None) → None

Write a new value to this variable in ecu.test.

Parameters:
value: str | int | float | list | tuple | None

The value to assign.

Raises:
class ecutest.toolaccess.ModelVar(name: str, tool_access: ToolAccess)

Bases: _VarBase

Represents a model variable in ecu.test.

Warning

Do not instantiate this class manually! Always use ToolAccess.model_var() to create instances of this class.

read() → str | int | float | list | tuple | None

Read the current value of this variable from ecu.test.

Returns:

The value of the variable.

Raises:
write(value: str | int | float | list | tuple | None) → None

Write a new value to this variable in ecu.test.

Parameters:
value: str | int | float | list | tuple | None

The value to assign.

Raises:
class ecutest.toolaccess.ToolAccess(init_timeout: float = 10.0, request_timeout: float = 10.0, allow_any_version: bool = False)

Bases: object

Interface for interacting with ecu.test jobs and variables in user-defined Python code.

A ToolAccess instance manages connection lifecycle, registration of jobs and variables, and execution state transitions (uninitialized <-> initialized <-> running).

Typical usage:

ta = ToolAccess()                       # unitialized state
with ta.init():                         # enter initialized state
    job = ta.job("PORT/SomeJob")        # register job
    var = ta.model_var("Model/Value")   # register variable
    with ta.run():                      # enter running state
        result = job(1, 2)              # call job
        current = var.read()            # read variable
        var.write(42)                   # write variable
    # by leaving the run context, ta falls back into the initialized state
# by leaving the init context, ta falls back into the unitialized state

The factory methods (job(), model_var(), meas_var(), calib_var(), bus_signal()) can only be invoked in the initialized state. read(), write(), call() and simu_wait() operations require the running state.

Parameters:
init_timeout: float = 10.0

Maximum time (in seconds) to wait for establishing a connection to ecu.test.

request_timeout: float = 10.0

Per-request timeout (in seconds) for API calls (read, write, job calls, …). You might want to increase this value e.g. when using long-running jobs.

allow_any_version: bool = False

Allows connection to any ecu.test version if True. Beware incompatible versions might lead to errors and undefined behavior.

bus_signal(name: str) → BusSignal

Create and register an ecu.test bus signal. Repeated calls with the same name parameter return the already registered instance and do not trigger an additional registration on the ecu.test side.

Parameters:
name: str

Fully qualified signal name (path).

Returns:

A registered BusSignal instance.

Raises:
  • RemoteError – If an error occurs in ecu.test during this function call.

  • StateError – If ToolAccess is not in the initialized state.

  • TimeoutError – If ecu.test does not respond within the configured request timeout.

calib_var(name: str) → CalibVar

Create and register an ecu.test calibration variable. Repeated calls with the same name parameter return the already registered instance and do not trigger an additional registration on the ecu.test side.

Parameters:
name: str

Fully qualified calibration variable name (path).

Returns:

A registered CalibVar instance.

Raises:
  • RemoteError – If an error occurs in ecu.test during this function call.

  • StateError – If ToolAccess is not in the initialized state.

  • TimeoutError – If ecu.test does not respond within the configured request timeout.

deinit()

Close the connection to ecu.test and reset all registered variables and jobs. After calling this methode ToolAccess falls back into the initialized state.

Info

This method should only be called when init() was called explicitly before.

Raises:

StateError – If ToolAccess is not in the initialized state.

init() → _ContextManager

Initialize the connection to ecu.test.

The initialized state is required before registering jobs or variables. Can be used as a context manager which will automatically invoke deinit() when leaving the context:

with ToolAccess().init() as ta:
    job = ta.job("PORT/Job")
    ...

Alternatively call it explicitly and later deinit():

ta = ToolAccess()
ta.init()
job = ta.job("PORT/Job")
...
ta.deinit()
Raises:
  • AuthenticationError – If ecu.test can not verify this client.

  • TimeoutError – If ecu.test does not respond within the configured init timeout.

job(name: str) → Job

Create and register an ecu.test job. Repeated calls with the same name parameter return the already registered instance and do not trigger an additional registration on the ecu.test side.

Parameters:
name: str

Fully qualified job name.

Returns:

A registered Job instance.

Raises:
  • RemoteError – If an error occurs in ecu.test during this function call.

  • StateError – If ToolAccess is not in the initialized state.

  • TimeoutError – If ecu.test does not respond within the configured request timeout.

meas_var(name: str) → MeasVar

Create and register an ecu.test measurement variable. Repeated calls with the same name parameter return the already registered instance and do not trigger an additional registration on the ecu.test side.

Parameters:
name: str

Fully qualified measurement variable name (path).

Returns:

A registered MeasVar instance.

Raises:
  • RemoteError – If an error occurs in ecu.test during this function call.

  • StateError – If ToolAccess is not in the initialized state.

  • TimeoutError – If ecu.test does not respond within the configured request timeout.

model_var(name: str) → ModelVar

Create and register an ecu.test model variable. Repeated calls with the same name parameter return the already registered instance and do not trigger an additional registration on the ecu.test side.

Parameters:
name: str

Fully qualified model variable name (path).

Returns:

A registered ModelVar instance.

Raises:
  • RemoteError – If an error occurs in ecu.test during this function call.

  • StateError – If ToolAccess is not in the initialized state.

  • TimeoutError – If ecu.test does not respond within the configured request timeout.

required_evts = ['Notifications.Error', 'Notifications.Completions', 'Notifications.ToolAccessRead', 'Notifications.ToolAccessCall', 'Notifications.ToolAccessWait', 'Notifications.JobSignatures', 'Notifications.JobParamNames', 'Notifications.ToolAccessWrite']
run() → _ContextManager

Enter the running state required for read / write / job calls / simu_wait.

Usable as a context manager which automatically invokes stop() after leaving the context:

with ta.run():
    value = var.read()
    ...

Or explicitly:

ta.run()
my_var.read()
...
ta.stop()
Raises:
  • RemoteError – If an error occurs in ecu.test during this function call.

  • StateError – If ToolAccess is not in the initialized state.

  • TimeoutError – If ecu.test does not respond within the configured request timeout.

simu_wait(timeout: float | int) → None

Waits the specified amount of time based on the active time basis in ecu.test (model time or system time).

Parameters:
timeout: float | int

Time to wait in seconds.

Raises:
  • RemoteError – If an error occurs in ecu.test during this function call.

  • StateError – If ToolAccess is not in the running state.

  • TimeoutError – If ecu.test does not respond within the configured request timeout.

stop() → None

Exit the running state and fall back into the initialized state. Depending on the used tools, this can restore defaults for variables which were altered during the running state.

Info

This method should only be called when run() was called explicitly before.

Raises:

StateError – If ToolAccess is not in the running state.