=========== Quick Start =========== ------------ Requirements ------------ Enerplot can be controlled by either an internal Python script -- run inside of and under the control of Enerplot -- or from an externally run Python script. Internal Scripts ================ When using an internal script, Enerplot uses its own embedded Python interpreter. Beyond installing Enerplot itself, the only requirement is for the script to be added to the Workspace under the "Scripts" node, so it can be loaded and displayed in the "Scripts" docking pane. Once the script has been loaded and displayed in the "Scripts" docking pane, press the "Run" button to execute the script. The embedded Python interpreter is a Python 3.7 interpreter. It contains an internal copy of the :mod:`mhi.enerplot` module. There is no support for installing additional Python modules, such as ``numpy``, to the embedded Python interpreter. If additional Python modules are desired, external scripting is required. External Scripts ================ To use external scripting with Enerplot, the following must be installed: * Enerplot * Python 3.x (such as Python 3.7.2) * The following Python modules: * PIP - Python's Package Manager (included with Python 3.4 and later) * PyWin32 - Python extensions for Microsoft Windows * mhi.enerplot - Enerplot application library Installation of the above programs and modules is beyond the scope of this tutorial. ------------ Using Python ------------ Although any text editor which writes plain text files may be used to write python scripts, using an integrated development environment (IDE) will make developing the scripts easier and assist in debugging the scripts. Python 3.x comes bundled with such a tool, which is called IDLE. IDLE may be started using "Start ➭ All Programs ➭ Python 3.x ➭ IDLE (Python GUI)", or by right-clicking on an existing `*.py`, or `*.pyw` file, and selecting "Edit with IDLE". -------------- Python Version -------------- The Enerplot Automation Library is written with Python 3.x. While Python 2.x and Python 3.x can co-exist on a computer, the Python 3.x interpreter must be used to execute scripts with this Automation Library. A `shebang` [#shebang]_ line at the top of the file should be used to ensure the correct Python interpreter version is used. It consists of a number sign, followed by an exclamation mark, followed by the interpreter needed to run the script: .. literalinclude:: quick_start.py :lines: 1-3 :append: ... If more than one Python 3 interpreter is installed, a more specific version identifier may be used, such as ``#!/usr/bin/env python3.4`` or ``#!/usr/bin/env python3.7``, to control which particular subversion is executed. If a script is run from :abbr:`IDLE (Python's Integrated Development Environment)`, the shebang line is treated as a comment line, so take care to ensure the Python 3.x version of IDLE is used. .. [#shebang] Since the number sign is also known as a "hash" mark, and the exclamation mark is also known as a "bang", the combination of the two characters is pronounced "hash-bang", and usually shorten to "shebang". ---------------- Running Enerplot ---------------- The following :download:`script ` will: * establish a connection to Enerplot * first trying to establish connection to an already running instance, or * launching a new Enerplot instance, * load the "Enerplot_Examples.epwx" workspace, * list all books in the workspace, and * list all datafiles in the workspace .. literalinclude:: quick_start.py