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

Using Logic Builder Shell with JetBrains PyCharm

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 JetBrains PyCharm. PyCharm is a product from JetBrains and contains a free Community Edition and a purchasable Professional Edition. It is not part of the EcoStruxure Machine Expert delivery but can be downloaded from https://www.jetbrains.com/pycharm. PyCharm is cross-platform and supports Windows, macOS, and Linux.

In the following figure, you can see how PyCharm works together with EcoStruxure Machine Expert LogicBuilderShell.exe.

G-SE-0046397.2.gif-high.gif

 

 

Procedure of Developing and Debugging

Step

Action

1

Start PyCharm.

2

Create or open a PyCharm project or Python file.

3

Develop your script and execute it in PyCharm.

Result: PyCharm performs the following tasks:

oLaunching the LogicBuilderShell.exe.

oEstablishing a TCP/IP connection between PyCharm and LogicBuilderShell.exe.

oSending the Python statements to the shell.

oGetting feedback of results.

Developing Scripts with JetBrains PyCharm

PyCharm allows you to develop your EcoStruxure Machine Expert Python scripts.

The following features are supported:

oVerification of the Python syntax while writing.

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

oSyntax highlighting of Python script.

oAutocomplete support. (NOTE: Code inside external modules cannot be resolved.)

After you have executed the command Run > Debug..., or you have pressed Alt+Shift+F9 in PyCharm, and selected the Python script to be executed, the LogicBuilderShell.exe is launched and script execution starts. If you have set a breakpoint in the script and the breakpoint is hit, PyCharm marks the present statement, and you can use the debugger commands. The script output is displayed in the Console.

Python script debugging with PyCharm:

G-SE-0064479.1.gif-high.gif

 

1   Breakpoint in Python script

2   Debug Console of LogicBuilderShell.exe started by PyCharm

3   Debugger commands

4   Open evaluate expression dialog for directly issuing Python statements

For further information on how to use PyCharm debugging, refer to https://www.jetbrains.com/help/pycharm/2017.1/debugging.html.

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.

oPyCharm installed.

oLogic Builder Shell environment configured in PyCharm (see next section Configuring the Logic Builder Shell in PyCharm).

Configuring the Logic Builder Shell in PyCharm

NOTE: There is one action which must be applied to the corresponding EcoStruxure Machine Expert installation in order to be able to use PyCharm. Since PyCharm expects and only allows the original executable name to be configured for a Python interpreter, the LogicBuilderShell.exe must be named appropriately. To achieve this, execute step 1 of the following steps.

Step

Action

1

Rename the LogicBuilderShell.exe:

oNavigate to your LogicBuilderShell.exe (for example, C:\Program Files (x86)\Schneider Electric\SoMachine Software\V4.40 Motion) in Windows Explorer.

oDuplicate the files LogicBuilderShell.exe and LogicBuilderShell.exe.config by copying and pasting them into the same directory.

oRename the files to ipy.exe and ipy.exe.config since Logic Builder uses IronPython as Python interpreter.

2

Start PyCharm and open the Settings dialog box via Configure > Settings.

3

Open the Project Interpreter view, and execute the command Add Local from the button to the right of the Project Interpreter: box.

G-SE-0064480.1.gif-high.gif

 

 

Result: After this process has been completed (which may take some time), the Project Interpreter is displayed and set as default.

4

Execute the command More... from the button to the right of the Project Interpreter: box.

5

Select the newly created entry, and click the pencil on the right to edit the properties.

6

Rename it to LogicBuilderShell_V4.x where x is the specific version of the Logic Builder Shell.

7

Click OK to apply the settings and to close the dialog boxes.

For further information on how to configure PyCharm Python interpreters, refer to https://www.jetbrains.com/help/pycharm/2017.1/configuring-available-python-interpreters.html.

Configuring Existing PyCharm Projects or Python Files

If you apply the steps described in the previous section Configuring the Logic Builder Shell in PyCharm when you create PyCharm projects, the newly created Logic Builder Shell Python interpreter is preconfigured.

Step

Action

1

Start PyCharm.

2

Open an existing project or Python file.

3

Click the Configure Python Interpreter link of the message in the header highlighted in yellow.

4

In the Settings dialog box, select the previously created LogicBuilderShell_V4.x as Project Interpreter, and click OK to confirm.

For further information on how to configure PyCharm Project Interpreters, refer to https://www.jetbrains.com/help/pycharm/2017.1/configuring-python-interpreter-for-a-project.html.