EcoStruxure Machine Expert version 1.1 does not support the M258, LMC058 and LMC078 controllers.

Using Logic Builder Shell with Microsoft Visual Studio Code and Python Extension

Overview

With EcoStruxure Machine Expert and the LogicBuilderShell.exe, you can develop and debug Python scripts. To develop a EcoStruxure Machine Expert Python script, you can use the editors presented in the Introduction chapter.

It is a good practice to use an IDE from a third-party vendor such as Microsoft Visual Studio Code with installed Python extension. Visual Studio Code is an open source product from Microsoft. It is not part of the EcoStruxure Machine Expert delivery but can be downloaded from https://code.visualstudio.com. Visual Studio Code is cross-platform and supports Windows, macOS, and several Linux distributions.

NOTE: Since the Python extension (see https://marketplace.visualstudio.com/items?itemName=donjayamanne.python) is free and open source, it may be that not all versions are fully compatible with the EcoStruxure Machine Expert LogicBuilderShell.exe versions.

In the following figure, you can see the two tools that are working together with EcoStruxure Machine Expert LogicBuilderShell.exe.

G-SE-0073211.1.gif-high.gif

 

 

Procedure of Developing and Debugging

Step

Action

1

Start Visual Studio Code.

2

Create or open a Python file.

3

Develop your script and execute it in Visual Studio Code.

Result: Visual Studio Code performs the following tasks:

oLaunching the LogicBuilderShell.exe.

oEstablishing a TCP/IP connection between Visual Studio Code and LogicBuilderShell.exe.

oSending the Python statements to the shell.

oGetting feedback of results.

Developing Scripts with Microsoft Visual Studio Code

Visual Studio Code with Python extension allows you to develop your EcoStruxure Machine Expert Python scripts.

The following features are supported:

oDebug by setting breakpoints and using the debugger commands Step Into, Step Over, Step Out, and Continue.

oSyntax highlighting of Python script.

oIntelliSense for local elements and code snippets. (NOTE: Code inside external modules cannot be resolved.)

After you have executed the command Debug > Start Debugging, or you have pressed F5 in Visual Studio Code, the LogicBuilderShell.exe is launched, and script execution starts. If you have set a breakpoint in the script and the breakpoint is hit, Visual Studio Code marks the present statement, and you can use the debugger commands. The script output is displayed in the Debug Console.

Python script debugging with Visual Studio Code:

G-SE-0064483.1.gif-high.gif

 

1   Debugger commands

2   Breakpoint in Python script

3   Debug Console of LogicBuilderShell.exe started by Visual Studio Code

4   Input box for directly issuing Python statements

For further information on how to use Visual Studio Code debugging, refer to https://code.visualstudio.com/docs/editor/debugging.

System Requirements for Debugging Scripts

To debug EcoStruxure Machine Expert Python scripts, your system has to meet the following pre-conditions.

oEcoStruxure Machine Expert with Logic Builder Shell feature installed.

oVisual Studio Code installed.

oVisual Studio Code Python extension installed and configured (see next section Installing and Configuring the Python Extension in Visual Studio Code).

Installing and Configuring the Python Extension in Visual Studio Code

Step

Action

1

Start Visual Studio Code.

2

Execute the command View > Extensions or press Ctrl+Shift+X, and type python into the search box.

Result: The extension view opens, and a list of matching extensions is displayed.

G-SE-0064484.1.gif-high.gif

 

 

3

Install the Python extension by clicking the Install button of the corresponding entry.

NOTE: Make sure to install the correct extension since there exist multiple different Python implementations.

NOTE: If an error is detected during the installation, verify your Internet connection: An existing proxy of the network you are connected to must be configured in Visual Studio Code using the http.proxy* settings.

For further information regarding Visual Studio Code settings, refer to https://code.visualstudio.com/docs/getstarted/settings.

4

After the installation process of the Python extension has been completed successfully, restart Visual Studio Code manually, or press the Reload button.

5

Configure the path to your LogicBuilderShell.exe (for example, C:\Program Files (x86)\Schneider Electric\SoMachine Software\V4.40 Motion\LogicBuilderShell.exe) in your Visual Studio Code settings.

Open the settings.json file by executing the command File > Preferences > Settings, or press Ctrl+,, and add the following lines inside the curly braces (adapt the path to your installation):

"python.pythonPath": "C:\\Program Files (x86)\\Schneider Electric\\SoMachine Software\\V4.40 Motion\\LogicBuilderShell.exe",
"python.linting.enabledWithoutWorkspace": false

If the settings file already contains entries, append a final comma to the previous line.

After that it should look like this:

G-SE-0064485.1.gif-high.gif

 

 

For further information regarding Visual Studio Code settings, refer to https://code.visualstudio.com/docs/getstarted/settings.