Code Monkey home page Code Monkey logo

model-railway's Introduction

Java Central Station

Static Badge License

GitHub commit activity Java CI with Maven

GitHub Gist last commit GitHub issues GitHub Release

Model railway control with JCS

Experiments wich should eventually lead to automated rail road control.

Why?

To have fun! I know there are ready to go products on the market. This project is not an attempt to compeat with any of them, hence this project is Open Source so anyone can benefit.

About The Project

JCS is an application to control a model railway. It is in an early stage of development. The project mostly contains my experiments to automate my model railway.

I started this project 2019 as (and still is) a hobby to automate my model-rail layout. As I am trying to do this project beside my work, family and other hobbies it is a project with sometimes a very slow pace...

The aim of the program is to automate the running of trains on my layout.

Supported Hardware

Current status

Currently the following modules are build:

  • A Throttle for driving locomotives
  • Keyboard Screen for switching Turnouts or Signals
  • Sensor Monitor to see the status of feedback sensors
  • Locomotives overview (including automatic downloading of the Locomotive- and function button images) and control.
  • Turnout and Signals overview (Synchronized with the CS2/3) and control.
  • A Screen to edit/display de schematic Layout.
  • A HAL for command Stations such that other hardware then the Marklin CS 2/3 can be used.
  • First Release V 0.0.1

Screenshots

So here are a few screenshots of the Project:

Thottle / Driver Cab

The Locomotive- and function images are displayed. Images are automatically downloaded from the Central Station. Or can be manually added.

UI screenshot: JCS Throttle

Keyboard Panel for switching accessories and viewing feedback sensor status

UI screenshot: JCS keyboard Screen

Sensor Monitor

UI screenshot: JCS Sensor Monitor

Layout display

UI screenshot: JCS Main Screen

In Editmode you can draw a layout using pre defined Tiles. also the layout can be routed. (it the very first and early step for the preparation of automatic running). UI screenshot: JCS Edit Screen

Import Locomotives from a CS-2 or CS-3

UI screenshot: JCS Preferences Locomotives

TODO's (and there are still a lots of todo's...):

Currently the following features are under active development:

  • Configuration screens to edit the Locomotives, Accessories and Sensors. [more or less done :)]
  • Add deployment configuration for MacOS, Windows and Linux an App [more or less done :)]
  • Automatically route the Layout. [more or less done :)]
  • React on relevant CS-3 events like start/stop, Sensor events, Loco, Accessory, power etc events. [work in progress :)]
  • Automatically run trains. [Work in progress]
  • Add more Unit tests
  • ...

So I hope you get inspired!

Frans

License

LICENSE

Build JCS from source

BUILDING

Contributors

frans
Frans Jacobs
Buy Me A Coffee

** Copyright 2019 - 2024 Frans Jacobs **

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

model-railway's People

Contributors

dependabot[bot] avatar fransjacobs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

p-dekker

model-railway's Issues

Add support for DCC-EX

DCC-EX is a low-cost command station which is DIY
Adding support for this command station will greatly enhance the functionality of JCS

Link sensors to a block

The ability to link a sensor to a block so that you know whether a train is incoming, or standing in a block

Block properties

To run train automatically a train has to be put in a block. add functionality to be able to configure a block

Functions 17 to 32 do not work

Tried with Locomotive RFF 561 Function 0 to 16 all work, bu the higher number have strange pictures an doe no seem to work when activated from JCS but when switch on the CS-3 the image in JCS change from black to yellow

Add input validation

Most of the input screen do not have input validation, so when you forget to fill in a name or address by example a SQL exception is thrown due to a not null constraint in the database. This error is not evaluated back to the screen but only in the log vissible

Implement Disconnection Event

Currently all thing continue also when the connection to the command station is gone. Only a lot of errors are logged. JCS should show a dialog message saying that the command station is disconnected. and stop all command station actions

Route check

Functionality which can check the layout before or after routing for errors
Like loose or unconnected tiles
Switches, signals or sensors which are no linked to a CS3 Switch signal or sensor

Error when recreating sensors when the sensor is also linked to a block

Error when recreating sensors:
TRACE 2024-04-06 11:48:13.792 [AWT-EventQueue-0] H2PersistenceService.generateSensorBeans(): Removing B0-S-2
Exception in thread "AWT-EventQueue-0" com.dieselpoint.norm.DbException: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Referential integrity constraint violation: "blck_sens_plus_fk: jcs.blocks FOREIGN KEY(plus_sensor_id) REFERENCES jcs.sensors(id) ('0-0002')"; SQL statement:
delete from sensors where id=? [23503-220]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:520)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
at org.h2.message.DbException.get(DbException.java:223)
at org.h2.message.DbException.get(DbException.java:199)
at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:365)
at org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:382)
at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:256)
at org.h2.table.Table.fireConstraints(Table.java:1200)
at org.h2.table.Table.fireAfterRow(Table.java:1218)
at org.h2.command.dml.Delete.update(Delete.java:92)
at org.h2.command.dml.DataChangeStatement.update(DataChangeStatement.java:74)
at org.h2.command.CommandContainer.update(CommandContainer.java:169)
at org.h2.command.Command.executeUpdate(Command.java:252)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:408)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:191)
at java.base/java.lang.Thread.run(Unknown Source)

at com.dieselpoint.norm.Query.execute(Query.java:371)
at com.dieselpoint.norm.Query.delete(Query.java:534)
at com.dieselpoint.norm.Database.delete(Database.java:182)
at jcs.persistence.H2PersistenceService.remove(H2PersistenceService.java:136)
at jcs.persistence.H2PersistenceService.generateSensorBeans(H2PersistenceService.java:203)
at jcs.ui.options.CommandStationPanel.recreateSensors(CommandStationPanel.java:1348)
at jcs.ui.options.CommandStationPanel.recreateSensorsBtnActionPerformed(CommandStationPanel.java:1338)
at jcs.ui.options.CommandStationPanel$20.actionPerformed(CommandStationPanel.java:829)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2314)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:407)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6621)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3398)
at java.desktop/java.awt.Component.processEvent(Component.java:6386)
at java.desktop/java.awt.Container.processEvent(Container.java:2266)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4996)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4828)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4828)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:98)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:744)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Referential integrity constraint violation: "blck_sens_plus_fk: jcs.blocks FOREIGN KEY(plus_sensor_id) REFERENCES jcs.sensors(id) ('0-0002')"; SQL statement:
delete from sensors where id=? [23503-220]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:520)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
at org.h2.message.DbException.get(DbException.java:223)
at org.h2.message.DbException.get(DbException.java:199)
at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:365)
at org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:382)
at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:256)
at org.h2.table.Table.fireConstraints(Table.java:1200)
at org.h2.table.Table.fireAfterRow(Table.java:1218)
at org.h2.command.dml.Delete.update(Delete.java:92)
at org.h2.command.dml.DataChangeStatement.update(DataChangeStatement.java:74)
at org.h2.command.CommandContainer.update(CommandContainer.java:169)
at org.h2.command.Command.executeUpdate(Command.java:252)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:408)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:191)
at java.base/java.lang.Thread.run(Unknown Source)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:520)
at org.h2.engine.SessionRemote.readException(SessionRemote.java:650)
at org.h2.engine.SessionRemote.done(SessionRemote.java:619)
at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:216)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:174)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
at com.dieselpoint.norm.Query.execute(Query.java:363)
... 42 more

Accessory does sometimes not switch

When clicking on a turnout sometime it does not switch it only does it after the second time. for some reason the accessory vales is switched off which can not happen.

Logging into files

The first 0.0.1 release can only show console log when started form a command shell. Add Logging into a files

Route to the next block

Create a route to the next free block for a train , set all the switches and signals in the right position

Loc list via can

Using the can message to request a loc list so sending acquire config data:
TX: 00 40 03 00 08 6c 6f 6b 73 00 00 00 00 leads to response:
RX: 00 41 03 00 08 6c 6f 6b 73 00 00 00 00 so CS-3 confirms the message,
but then a response should come like
RX: 00 42 0300 06 00 00 00 00 0b 50 65 be
RX 00 42 0300 08 00 00 6e a6 78 9c ed 5d ...... should come.
This data steam does not come when tried with Packet sender or with JCS
However it does work as Traintastic does the same and the stream is visible in the log

Fix route display of a Cross

Now a cross is sowing also the non used start and end leaved in a route display should only display the active route

Add a Graph builder

The Graph builder will transform the tiles from the layout in to a Graph which can be routen using a A8 or other algorithm

Add a Data export button

It would be very useful to be able to export the setting from one PC to an other so some sort of dataexport is needed

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.