2.4. Supported IDEs

2.4.1. Python Shell IDLE

This is the default IDE.

It can be started from Windows Start Menu or by calling C:/Python/Lib/idlelib/idle.py:
Python IDLE shell window showing the default IDE environment for running Python code
In this shell, the user can simply copy&paste the sample code from: Examples/EcMasterDemoPython/EcDemoAppInteractive.py
exec("""
import os
import sys
INSTALLDIR = "C:/Program
Files/acontis_technologies/EC-Master-Windows-x86_64Bit/"
os.environ["PATH"] += os.pathsep + INSTALLDIR + "Bin/Windows/x64"
sys.path.append(INSTALLDIR + "Sources/EcWrapperPython")
sys.path.append(INSTALLDIR + "Examples/EcMasterDemoPython")
from EcDemoApp import \*
demo = EcMasterDemoPython()
demo.pAppParms.tRunMode = RunMode.Master
demo.pAppParms.dwBusCycleTimeUsec = 4000
demo.pAppParms.szENIFilename = "ENI.xml"
demo.pAppParms.szLinkLayer = "ndis 127.0.0.0 1"
demo.pAppParms.nVerbose = 3
demo.startDemo()
print("EcMasterDemoPython is running.")
print("Type demo.help() for interactive help.")
""")
… and the demo is running.
Python IDLE shell window showing EcMasterDemoPython running in interactive mode

2.4.2. Visual Studio 2019

Create a new project:
Visual Studio 2019 shows create a new project dialog
Configure the project:
  • Replace the generated file EcMasterDemoPython.py with the existing EcDemoApp.py.

Visual Studio 2019 shows configure your new project dialog
Configure project General settings:
  • Startup File: EcDemoApp.py

Visual Studio 2019 shows general tab of new generated Python appliation project
Configure project Debug settings:
  • Search Paths:

../../Sources/EcWrapperPython;../EcMasterDemoPython
  • Script Arguments:

-mode 1 -file ENI.xml -link "ndis 127.0.0.0 1 1" -cycletime 4000 -time 1000 -lvl 3
  • Environment Variables:

PATH=../../Bin/Windows/x64;%PATH%
Visual Studio 2019 shows debug tab of new generated Python appliation project
Press Start and the demo is running:
Command prompt window showing EcMasterDemoPython

2.4.3. Visual Studio Code

Install python extension by open extension tab and enter python:
Visual Studio Code Extensions tab showing the Python extension
Open folder Examples/EcMasterDemoPython and configure the launch.json:
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Aktuelle Datei",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "cwd": "",
            "args" : [
                "-mode", "1",
                "-file", "ENI.xml",
                "-link", "ndis 127.0.0.1 1",
                "-cycleTime", "4000",
                "-time", "1000",
                "-lvl", "3",
            ],
            "env": {"PYTHONPATH": "${workspaceRoot}"}
        }
    ]
}
Visual Studio Code showing the launch.json configuration for running EcMasterDemoPython with cmdline parameters
Configure linter in settings.json:
{
      "git.ignoreLimitWarning": true,
      "python.linting.pylintArgs": [
          "--init-hook='import sys; sys.path.append(\"C:/Temp/EC-Master-Windows-x86_64Bit/Sources/EcWrapperPython\")'"
      ]
}
Visual Studio Code showing the settings.json configuration for Python linter
Open EcDemoApp.py and the following lines to set environment:
import os
import sys
INSTALLDIR = "C:/Temp/EC-Master-Windows-x86_64Bit/"
os.environ["PATH"] += os.pathsep + INSTALLDIR + "Bin/Windows/x64"
sys.path.append(INSTALLDIR + "Sources/EcWrapperPython")
sys.path.append(INSTALLDIR + "Examples/EcMasterDemoPython")
Visual Studio Code showing EcDemoApp.py with possbile environment setup lines
Start debugging and the demo output will be written into the terminal:
Visual Studio Code debug session showing EcMasterDemoPython console output in the integrated terminal