Metadata-Version: 2.5
Name: pmri
Version: 0.1.2
Summary: PMRI -- Python Model Railroad Interface. Full base install: launcher + web service + shared infrastructure, bundled as one wheel.
Project-URL: Homepage, https://github.com/railmodeler/pmri
Project-URL: Issues, https://github.com/railmodeler/pmri/issues
Project-URL: Source, https://github.com/railmodeler/pmri
Author-email: J Petrovick <jpetrovick@gmail.com>
License-Expression: GPL-2.0-or-later
License-File: LICENSE
Keywords: dcc,dcc-ex,jmri,loconet,model-railroad,nce,openlcb
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.12
Requires-Dist: bcrypt>=4.1
Requires-Dist: customtkinter>=5.2
Requires-Dist: fastapi>=0.110
Requires-Dist: itsdangerous>=2.1
Requires-Dist: jinja2>=3.1
Requires-Dist: lxml>=5.2
Requires-Dist: pydantic>=2.7
Requires-Dist: pyserial-asyncio>=0.6
Requires-Dist: pyserial>=3.5
Requires-Dist: python-multipart>=0.0.9
Requires-Dist: pyyaml>=6.0
Requires-Dist: structlog>=24.1
Requires-Dist: uvicorn[standard]>=0.27
Description-Content-Type: text/markdown

# Python Model Railroad Interface

## Overview
This is a native python re-implementation of the Java Model Railroad Interface (JMRI) based on JMRI version 5.14. The implementation uses python, JSON, html and javascript. The interface is rendered using a web browser and a native python web server. The purpose of this work was to move to a more modern infrastructure that is more accessible to contributors, as python is far easier to learn, code, and debug that java. Furthermore, there is a dramatic reduction in the number of classes and methods, improving overall performance, particularly on slower hardware such as a raspberry pi. It also allows for user scripts written in python3 natively, and eliminates the dependency on jython which is effectively dead due to being locked to python2.7.

This implementation if fully compatible with the JMRI implementation. It reads and writes all the existing xml profiles in the user working directory. As such, you can switch between PMRI and JMRI without loss of information. However, unlike JMRI, there is a single interface which incorporates both PanelPro and DecoderPro functionality. There are some enhancements, like support for multiple connections. So, if you use and NCE command station for operations and some other device, like an SPROG2 or dccex board for decoder programming, there is one profile directory (roster.xml, decoder settings, etc.) and you can switch between connections to the different devices.

## Structure
pmri is the base engine that includes all the core functions for managing all the connections and operation of the web interface. Support for different command station hardware is treated as a plug-in and are installed separately from the pmri base. There is a well defined hardware abstraction layer (HAL) by which all the command station interfaces are implemented.

### Basic Component Overview

- pmri-core:
Handles persistence of all the settings from the various xml files and the connection manager between the command station hardware and the JSON server.
- pmri-server:
Essentially the JSON server, connecting between pmri-core and pmri-web
- pmri-web:
Runs the web server and renders the interface, sending request back through pmri-server.pmri-scripting:
Executes user defined scripts and provides an API interface. In addition, there is a jmri shim that allows for direct execution of existing jython based python scripts. Depending on the script, some modification may be required to work with python 3.x, mostly related to print statement format.
- pmri-decoderpro:
decoder programming interface
- pmri-openlcb:
LCC implementation support
- pmri-logixng:
The logixng support for layout automation.
- pmri-loconet:
The loconet network protocol support
- pmri-withrottle:
The wifi server for using throttle software on android/ios devices
- pmri-pmri:
The launcher for pmri to configure the settings and start the server and web interface

## Supported command stations
There is a hardware plugin for nce (pmri-nce) and dccex (pmri-dccex). There are stubs for digitrax, lenz, and mrc that plugin, but require implementation and debug.

## Status
The existing release has been fully tested for both operation and decoder programming with an NCE PowerPro with a 2006+ eprom and a dccex command station. In addition, withrottle has been fully tested with android and the EngineDriver app. The scripting environment is also debugged. It has been run on Windows11, Linux (ubuntu and mint), and raspbian OS on a raspberry pi 3B.

## Installation

Python 3.12 or later is required. Support for the case statement is necessary.

To install pmri:
- pip install pmri

Installation of command station support:
- pip install pmri-nce
- pip install pmri-dccex

Note that you can install as many command station plugins as desired. They won't be used unless specfied as the active connection

Note also, if you do "pip install pmri-nce", it will also automatically install pmri if hasn't been already installed since it is a dependency.

## Execution

Once installed there will be a launcher called pmri created by pip dependent on the platform. 

For windows, a pmri.exe will be located in the user AppData space for the version of python you are using. For example, for python3.13, it would be located here: C:\Users\_user_\AppData\Local\Programs\Python\Python313\Scripts\pmri.exe. At this point, there are two optionsto launch pmri:
- Right click the desktop, choose "Open in Terminal", then type pmri at the command prompt
- Create a desktop icon so that you can launch pmri
-- Open File Explorer and navigate to the directory that contains pmri.exe. Note that AppData is hidden by default, so you may have to enable hidden directories in order to navigate the path.
-- Right click pmri.exe, "Show more options", "Send To", then choose "Desktop (create shortcut)". You should then see a pmri-shortcut icon on the desktop
-- Double click the pmri icon to launch the application

For linux/raspbian, a python script is created which can be launched in an xterm:
- pmri command will launch the gui to set the options and manage the web service.
- pmri --headless will start the server directly without the pmri launch gui or web server (background operation on a raspberry pi, for example) 

Note:
Presently, this depends on the decoder and signal xml files from JMRI. These are not currently bundled with pmri. 

On linux/raspbian, these are normally located here:
- /home/_user_/JMRI/xml/signals
- /home/_user_/JMRI/xml/decoders

On windows: 
- C:\Program Files (x86)\JMRI\xml\decoders
- C:\Program Files (x86)\JMRI\xml\signals
