Installation - topological-state/stskit GitHub Wiki

English text below.

Allgemeines

STSkit läuft auf allen Plattformen, auf denen Python verfügbar ist (also u.a. Linux, Windows, MacOS). Es gibt zwei Wege, das Programm einzurichten und auszuführen:

  1. Quelltext mit Python-Installation. Dieser Weg wird empfohlen, erfordert aber (einfache) Operationen auf der Kommandozeile. Funktioniert auf allen Betriebssystemen, auf denen Python verfügbar ist. Das GitHub-Repository ist immer auf dem neusten Stand.
  2. Ausführbare Programmdatei für Windows. Programmdateien werden nach bestem Wissen erstellt, es gibt keine Garantie, dass sie in allen Umgebungen funktionieren und frei von Fehlern oder schädlichem Code sind. Die Programmversion ist oft etwas älter, da neue Versionen nur sporadisch veröffentlicht werden. Der Programmstart dauert etwas länger als bei der Quelltext-Variante.

Python-Installation

Die empfohlene Python-Version ist 3.9. STSkit ist kompatibel mit Python 3.8-3.10.

Hinweis: In Python 3.11 gibt es gegenwärtig ein Problem mit der Matplotlib-Library. Es sollte deshalb nicht eingesetzt werden. Die untenstehende Anleitung legt die Version auf 3.9 fest.

Schritt 1: Miniconda installieren

Passenden Miniconda3 Installer von https://conda.io/miniconda.html herunterladen und installieren, z.B. latest Miniconda3 Windows 64-bit.

Schritt 2: Notwendige Pakete installieren

Öffne ein Terminal (Linux, Mac) bzw. den Anaconda prompt (Windows).

Erstelle eine neue Umgebung für sts:

conda create -q --yes -n sts python=3.9 pip matplotlib=3.5 numpy scipy pyqt

Aktiviere die Umgebung:

conda activate sts

Installiere weitere Pakete:

pip install trio qtrio untangle networkx

Schritt 3: STSkit installieren

Lade den STSkit Quellcode als zip-File aus dem GitHub repository herunter und entpacke ihn in ein Zielverzeichnis deiner Wahl.

Anwender, die mit git vertraut sind, können das Repository stattdessen mit git klonen.

Schritt 4: Stellwerksim und STSdispo starten

Starte ein Stellwerk mit Stellwerksim, bevor du STSdispo startest.

Öffne ein Terminal oder den Anaconda Prompt auf Windows und gib folgende Befehle ein. stskit-directory sollte das Verzeichnis sein, das die Datei stsdispo.py enthält:

conda activate sts
cd stskit-directory
python stsdispo.py

Das Hauptfenster von STSdispo öffnet und verbindet sich mit dem laufenden Stellwerk. Um STSdispo zu beenden, schliesse das Hauptfenster.

Schritt 5 (optional): Script erstellen

Um das Programm mittels Doppelklick zu starten, kann eine Batch-Datei, z.b. stsdispo.bat, mit folgendem Inhalt erstellt werden. Hierbei muss ggf. in der vierten Zeile der Pfad zur Miniconda3-Installation korrigiert werden. Miniconda3 kann systemweit oder nur für einen User installiert worden sein. Im letzteren Fall befindet es sich unter C:\Users\{username}\miniconda3.

@echo OFF
rem STSdispo starten
rem hier den Pfad zur Miniconda-Installation angeben
set CONDAPATH=C:\ProgramData\Miniconda3
set ENVNAME=sts
set ENVPATH=%CONDAPATH%\envs\%ENVNAME%
call  %CONDAPATH%\Scripts\activate.bat %ENVPATH%
python stsdispo.py

[Codebeispiel basiert auf https://gist.github.com/maximlt/531419545b039fa33f8845e5bc92edd6 ]

Ausführbare Programmdatei

Schritt 1: Programmdatei herunterladen

Ausführbare Programmdateien für Windows 10 werden unter Releases veröffentlicht. Lade die Zip-Datei stsdispo.zip herunter und entpacke sie in ein Verzeichnis deiner Wahl.

Schritt 2: Stellwerksim und STSdispo starten

  1. Starte ein Stellwerk im Stellwerksim.
  2. Starte das Programm stsdispo.exe.

Kommandozeilen-Optionen

Ohne Angabe verbindet sich STSdispo mit dem laufenden Stellwerk auf dem gleichen Rechner. Wenn der Simulator auf einem anderen Rechner im gleichen Netzwerk oder auf einem anderen Port läuft, lautet der Befehl:

python stsdispo.py --host other-host --port 12345

Wenn Fehler auftreten, erstellt STSdispo eine Protokolldatei stskit.log im aktuellen Verzeichnis. Für mehr Details kann ein niedriger Log Level (WARNING, INFO or DEBUG) eingestellt werden. Ausserdem kann der Name der Protokolldatei angegeben werden:

python stsdispo.py --log-level DEBUG --log-file mylog.log

Installing Python

At this time, the recommended Python version is 3.9. However, stskit is compatible with 3.8-3.10. 3.11 should not be used at this time.

The following instructions are based on the recommended Miniconda distribution. Conda tries to ensure that the versions of installed packages are compatible. Furthermore, it allows you to create separate environments for different applications, which can help to avoid version conflicts. However, other distributions including the official Python binaries using packages from https://pypi.org/ should work as well.

Step 1: Installing Miniconda

Install Miniconda3 according to their installation instructions.

Step 2: Installing required packages

Open a Terminal (Linux, Mac) or the Anaconda prompt (Windows).

Set up a new environment for stskit. Here, sts is the name of the Conda environment - you may choose a different one.

conda create -q --yes -n sts python=3.9 pip matplotlib=3.5 numpy scipy pyqt

Activate the new environment.

conda activate sts

Install additional required packages from PyPI.

pip install trio qtrio untangle networkx

Step 3: Installing stskit

Download the STSkit source code from the github repository, master branch. Users familiar with git may choose to clone the repository, else just download a zip file and unpack it to a directory of your choice.

Step 4: Running STSdispo

STSdispo is the main program contained in STSkit. Start Stellwerksim and open a stellwerk before starting STSdispo.

Open a terminal (or Anaconda prompt on Windows). Enter the following commands, replacing stskit-directory by the directory that contains stsdispo.py.

conda activate sts
cd stskit-directory
python stsdispo.py

STSdispo will open its main window and connect to the locally running stellwerk. To terminate STSdispo, close the main window.

Command Line Options

By default, STSdispo connects to the running stellwerk on the local host. To specify another host and/or port:

python stsdispo.py --host other-host --port 12345

By default, a log file stskit.log will be produced if errors are encountered. More verbose output can be generated by specifying a lower log level (WARNING, INFO or DEBUG). Example:

python stsdispo.py --log-level DEBUG --log-file mylog.log