Giter Site home page Giter Site logo

xirui / ptc-sim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dustinfast/ptc-sim

0.0 0.0 0.0 8.26 MB

A PTC Back Office Server with web interface, track/locomotive simulators, and EMP messaging subsystem.

License: MIT License

Python 74.25% CSS 2.12% HTML 5.29% JavaScript 18.35%

ptc-sim's Introduction

PTC-Sim - Positive Train Control Simulation

Heroku

This application is a Positive Train Control (PTC) Back Office Server (BOS) with web interface, track/locomotive simulators, and Edge Message Protocol (EMP) messaging subsystems. Development has begun with the intention of growing into an open-source PTC solution after observing first-hand the difficulties railroads are currently experiencing as they attempt to meet PTC implementation deadlines imposed by congress. It is a work in progress and distributable free under the MIT license. All images obtained under the Creative Common License.

PTC's mandate is to prevent:

  • Train on train collisions
  • Over-speed derailments
  • Incursions into work zone limits
  • Movement through misaligned track-switches

Interoperability between railroads is also required, as defined by the Federal Railroad Administration's Interoperable Train Control (ITC) standard.

PTC-Sim currently implements broker-assisted EMP communication between simulated on-track devices (locomotives and 220 MHz radio base-stations) and the BOS. Locomotive tracking and computer-aided-dispatch (CAD) is facilitated by a web interface, where current device status and location are displayed graphically. For the simulation, each web client gets its own "sanbox", consisting of an independent broker and track/locomotive simulator.

Usage

From a Linux terminal, start the application with ./sim_bos.py, then navigate to `http://localhost:5000'

Application Structure

Components

Each component exists as a seperate entity. Communication between entities occurs via EMP messaging over TCP/IP.

  • Back Office Server : Displaying real-time device and locomotive status via its web interface. Plans exist to also provides CAD capabilities, such as communicating track restrictions to locomotives.

  • Message Broker: An intermediate message translation system allowing bi-directional communication between track devices, locomotives, and the BOS. Currently, each component transports EMP messages via TCP/IP only. Future versions will implememnt Class C (IP based multicast protocol) and Class D (IP based point-to-point protocol) messaging.

  • Track Simulator: Simulates on-track devices:

    • Locomotives: Each locomotive travels along the track, broadcasting status messages (and eventually receiving CAD directives) over its two simulated 220 MHz radio transducers.
    • 220 MHz Radio Base Stations: Receives locomotive status messages and transmits them to the Message Broker via LAN.
    • Waysides: Receives status messages from it's attached switches via LAN, then broadcasts them over 220 MHz radio to the BOS.
    • Switches: Each switch sends its current position (OPEN, CLOSED, or ERROR) to its parent wayside at regular intervals.

Files

PTC-Sim
|   app_config.dat - Application configuration information.
|   lib_app.py - Shared application-level library.
|   lib_messaging.py - Messaging subsystem library.  
|   lib_track.py - Track simulation class library.
|   lib_web.py - Web interface library.
|   LICENSE - MIT License.
|   Procfile - Process definition, for use in virtual environments.
|   requirements.txt - Dependencies, for use in virtual environments.
|   runtime.txt - Python version def, for use in virtual environments.
|   README.md - This document.
|   sim_bos.py - The Back Office Server / web interface.
|
+---docs - Contains documentation.
|
+---logs - Created on startup to hold log files for each component.
|
+---static - Static web content, such as images, css, and js.
|
+---templates - Flask web templates
|       home.html - The main device and locomotive satus page. 
|       layout.html - Top-level container template, including navbar.
|
+---track
|       track_bases.json - JSON representation of the track's radio base stations.
|       track_locos.json - JSON representation of the railroad's locomotives.
|       track_rail.json - JSON representation of the track's main branch.

Dependencies / Technologies

Requires Python 2.7. Other dependencies managed by the application include: Flask, Jinja, JQuery, and the GoogleMaps API.

Preview

To preview PTC-Sim, navigate to https://ptc-sim.herokuapp.com/

PTC-Sim Screenshot

Unimplemented

At this point in development, some features typical in a PTC deployment, such as authentication, encryption, high availability, redundancy, and persistent data have not been implemented. Track simulation is also currently restricted to a single branch, however locomotives are not currently aware of each other on that branch. Additionally, the following TODO items are in progress:

  • Broker queue msg expire time
  • Web Output: logs and broker queue monitor, to demonstrate msging system
  • Base coverage overlays in website map display
  • Segregated logs
  • Ensure PEP8 for file headers, imports, and docstrings (model after Tack and connection, but move public members to class level-doc)
  • Privatize necessary members and do validation on public members
  • Readme screenshots and high-level PTC images
  • Track Circuits, to aid col avoidance.

ptc-sim's People

Contributors

dustinfast avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.