HyWorksApi Commands

Documentation Home Page HYPERSIM Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.

HyWorksApi Commands

General

closeHyperWorks():

HyWorksApiGRPC.closeHyperWorks()

Close HyperWorks

Examples:

  • HyWorksApi.closeHyperWorks()

closeLibrary(libraryPath):

HyWorksApiGRPC.closeLibrary(libraryPath)

close a CLF library located at the specified ‘libraryPath’.

Parameters:

libraryPath (str) – The path to the CLF library to be closed.

Returns:

True if the library was successfully closed; False otherwise.

Return type:

bool

connectToHyWorks(host=socket.gethostname(), register=getpass.getuser():

HyWorksApiGRPC.connectToHyWorks(host=socket.gethostname(), register=getpass.getuser()

Connect HyJavaApi to HYPERSIM

Parameters:

  • host (str) – computer name

  • register (str) – user name

  • timeout (int) – timeout for function

  • id (int) – Hyworks index to register to

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

disableHyWorksApiExceptions():

HyWorksApiGRPC.disableHyWorksApiExceptions()

Disable HyWorksApi from returning HYPERSIM exceptions through Python

enableHyWorksApiExceptions():

HyWorksApiGRPC.enableHyWorksApiExceptions()

Enable HyWorksApi to return HYPERSIM exceptions through Python

getApiSession():

HyWorksApiGRPC.getApiSession()

Retrieve the currently active API session with HyWorks Note : To be used only when multiple HYPERSIM instances are required at the same time

getCurrentDesign():

HyWorksApiGRPC.getCurrentDesign()

Get the currently focused HYPERSIM design.

Returns:

path to the currently active HYPERSIM design

Return type:

str

getProperties():

HyWorksApiGRPC.getProperties()

Get current HYPERSIM general properties

Returns:

HYPERSIM general properties

Return type:

str

getProperty(key):

HyWorksApiGRPC.getProperty(key)

Get HYPERSIM property Refer to the following page of the documentation to find the properties names:

Parameters:

key (str) – property key

Returns:

HYPERSIM property

Return type:

str

Raises:

AssertionError – raises exception on error

Examples:

  • HyWorksApi.getProperty(“hyworks.hysim.extraTimeout”)

getVersion(long=False) :

HyWorksApiGRPC.getVersion(long=False)

Get the current HYPERSIM version name

Parameters:

long (bool) – Add ‘’ prefix, which is necessary for certain compatibility usage

Returns:

HYPERSIM version

Return type:

str

newApiSession():

HyWorksApiGRPC.newApiSession()

Create a new API disconnected API session for HyWorks

openLibrary(libraryPath, visible=True):

HyWorksApiGRPC.openLibrary(libraryPath, visible=True)

opens a CLF library located at the specified ‘libraryPath’.

Parameters:

  • libraryPath (str) – The path to the CLF library to be opened.

  • visible (bool) – (Optional) A boolean indicating whether the library should be opened in a visible state (default is True).

Returns:

True if the library was successfully opened; False otherwise.

Return type:

bool

setApiSession(session):

HyWorksApiGRPC.setApiSession(session)

Activates a previously save API session retrieved by getApiSession

Parameters:

session (HyWorksGRPCSession) – gRPC Session

Returns:

the currently active session

Return type:

HyWorksGRPCSession

setProperty(key, value, save=False):

HyWorksApiGRPC.setProperty(key, value, save=False)

Set HYPERSIM general property Refer to the following page of the documentation to find the properties names:

Parameters:

  • key (str) – property key

  • value (str) – property value

  • save (bool) – save preferences for the next session

Returns:

error value

Return type:

bool

Raises:

AssertionError – raises exception on error

Examples:

  • HyWorksApi.setProperty(“hyworks.hysim.extraTimeout”, “1200000”)

  • HyWorksApi.setProperty(“hyworks.hysim.extraTimeout”, “1800000”, True)

startAndConnectHypersim(host=socket.gethostname(), register=getpass.getuser(), stdout=None, stderr=None:

startHyperWorks(stdout=None, stderr=None):

HyWorksApiGRPC.startHyperWorks(stdout=None, stderr=None)

Start HYPERSIM

Parameters:

  • stdout – standard output

  • stderr – standard error

Examples:

  • HyWorksApi.startHyperWorks()

Design

batchAddDevices(devices, interrupt_on_error=False):

HyWorksApiGRPC.batchAddDevices(devices, interrupt_on_error=False)

Add multiple devices to a design in a single batch operation.

Each entry in the returned list corresponds (by AddDeviceResult.index) to an entry in devices. Inspect AddDeviceResult.success to distinguish successes from failures without raising.

devices dictionaries should be in the following format: {

Required keys:

  • library (string)

  • type (string)

Optional keys:

  • x (int)

  • y (int)

  • page (int)

  • subcircuit (string)

  • name (string)

  • rotation (int)

  • flipVertically (bool)

  • flipHorizontally (bool)

}

Parameters:

  • devices (list[dict]) – a list of devices to be added.

  • interrupt_on_error (bool) – if True, stop processing on the first failure.

Returns:

one AddDeviceResult per processed operation.

Return type:

list[AddDeviceResult]

Raises:

RuntimeError – if every operation failed.

closeDesign(designPath):

HyWorksApiGRPC.closeDesign(designPath)

Close design

Parameters:

designPath (str) – path to the HYPERSIM model (.ecf)

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

disconnectDesign(designPath):

HyWorksApiGRPC.disconnectDesign(designPath)

Disconnect HyWorksApi from the HYPERSIM model

Parameters:

designPath (str) – path to the HYPERSIM model (.ecf)

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

findMinimalStepSize(timeout, overrunsThreshold: int, nCores=100, startingTimeStep=1e-6, jump=1e-6):

HyWorksApiGRPC.findMinimalStepSize(timeout, overrunsThreshold: int, nCores=100, startingTimeStep=1e-6, jump=1e-6)

Determines the smallest possible time step that prevents exceeding a specified number of overruns. This function requires Dashboards to be enabled beforehand. It attempts to start and stop the simulation in each iteration while staying within the overrun limit, ensuring the number of overruns does not reach the threshold. If the simulation completes before reaching the specified timeout, the time step is incremented by the given jump value. The minimal time step is identified when the simulation completes without timing out.

Parameters:

  • timeout (float) – Maximum allowed simulation iteration time in seconds.

  • overrunsThreshold (int) – The maximum number of overruns per iteration that must not be reached, for example, setting it to 1 means the program will iterate if the current simulation iteration experiences at least one overrun. Note that the threshold must be greater than 0.

  • nCores (int) – Number of processor cores to use (Default: 100). If the specified number exceeds available hardware cores, all available cores will be used. A value of 0 enables automatic core assignment.

  • startingTimeStep (float) – Initial time step in seconds (Default: 1 microsecond)

  • jump (float) – Increment for the time step in seconds (Default: 1 microsecond)

Returns:

The minimal time step in seconds, or None if unsuccessful

Return type:

float

Raises:

AssertionError – raises exception on error

getAllComponentDescriptions():

HyWorksApiGRPC.getAllComponentDescriptions()

Gets the descriptions of all components available in the current design, including their parameters and signals.

Returns:

a list of component descriptions

Return type:

list

getAllComponentParameters(compName):

HyWorksApiGRPC.getAllComponentParameters(compName)

Gets the list of parameters for a given component.

Parameters:

compName (str) – Component Name

Returns:

a list of parameter descriptions, for the ‘compName’

Return type:

list

getAllComponentSensors(compName):

HyWorksApiGRPC.getAllComponentSensors(compName)

Gets the list of sensors available for a given component type.

Parameters:

compName (str) – Component Name

Returns:

a list of sensor descriptions for the component.

Return type:

list

getAllDevicesNames():

HyWorksApiGRPC.getAllDevicesNames()

Gets the list of all devices names

Returns:

the list of all visible devices

Return type:

list

Raises:

AssertionError – raises exception on error

This call requires an analyze call before to function properly

getAllSelectedSensors():

HyWorksApiGRPC.getAllSelectedSensors()

Gets the list of selected sensors in the current design, including their runtime I/O connections. The returned value is a CSV string; it is the caller’s responsibility to decode it with the appropriate CSV parsing tool.

Returns:

csv string of selected sensor descriptions

Return type:

str

getDesignPrefs():

HyWorksApiGRPC.getDesignPrefs()

Get current model preferences