ScadeOne app#

The ScadeOne “app” is the Python class that allows to interact with Scade One projects.

The ansys.scadeone.core module must be referenced by scripts using PyScadeOne. It exposes the ScadeOne class representing a Scade One instance.

An instance of the ScadeOne class gives access to project loading and model-related activities as shown in the next figure:

../_images/scadeone.svg

Fig. 1 ScadeOne class hierarchy#

ScadeOne class#

class ansys.scadeone.core.ScadeOne(install_dir: str | Path | None = None)#

Bases: IScadeOne

Scade One API. This is the main entry point for users of the API, providing access to projects, tools, and other functionality.

Parameters:
install_dirOptional[Union[str, Path]]

Optional installation directory to use for determining tool paths.

If not provided, the API will look for the Configuration/modulesLocation.config file next to the ‘ansys.scadeone.core’ module.

If neither provided nor found, tool paths will not be available and no functionality requiring code generation, or other tool-dependent features, will be accessible.

class Tool(*values)#

Bases: Enum

Enum for Scade One tools, used in get_tool_path method.

JOB_LAUNCHER = 1#

Job launcher tool for running Scade One jobs.

LIBRARIES = 2#

LIBRARIES for Scade One libraries.

MINGW = 3#

MINGW tool for C code generation.

SCADE_ONE_LOCATION = 4#

Scade One installation directory.

SIMULATOR = 5#

Simulator tool for running Scade One simulations.

close() → None#

Close application, releasing any connection.

find_project(path: Path) → Project | None#

Return the loaded Project for the given sproj path, or None.

get_tool_path(tool: Tool) → Path | None#

Get the path of a Scade One tool.

Parameters:
toolIScadeOne.Tool

Enum value representing the tool. Currently supported value is IScadeOne.Tool.JOB_LAUNCHER.

Returns
——-
Path|None

Path to the tool executable, or None if not found.

load_project(storage: Project | str | Path) → Project | None#

Load a Scade One project.

Parameters:
storageUnion[Project, str, Path]

Storage containing project data.

Returns:
Project|None

Project object, or None if file does not exist.

new_project(project_path: str | Path) → Project#

Create a new project.

Parameters:
project_pathUnion[str, Path]

Project location.

Returns:
Project

Project object.

subst_in_path(path: str) → str#

Substitute $(SCADE_ONE_LIBRARIES_DIR) in path.

if ScadeOne.install_dir is None, no change is made.

property install_dir: Path | None#

Installation directory as given when creating the ScadeOne instance.

property parser: Parser#

Shared SwanParser used by every per-project model.

property projects: List[Project]#

Returns the loaded projects.

Returns:
List[Project]

Loaded projects.

property version: str#

API version.

Tools#

The ScadeOne.get_tool_path() method allows to retrieve the path of Scade One tools, such as the Job Launcher, which can be used to run Scade One jobs.

Available tools are given by the IScadeOne.Tool enum.

class ansys.scadeone.core.interfaces.IScadeOne#

Bases: ABC

Interface class

class Tool(*values)#

Bases: Enum

Enum for Scade One tools, used in get_tool_path method.

JOB_LAUNCHER = 1#

Job launcher tool for running Scade One jobs.

LIBRARIES = 2#

LIBRARIES for Scade One libraries.

MINGW = 3#

MINGW tool for C code generation.

SCADE_ONE_LOCATION = 4#

Scade One installation directory.

SIMULATOR = 5#

Simulator tool for running Scade One simulations.

abstractmethod find_project(path: Path) → IProject | None#

Return the loaded IProject for the given sproj path, or None.

abstract property parser: SwanParser#

Shared Swan parser used by all per-project models.