input and error handling update

This release brings quite the large change to libtrainsim. Hardware input was added, there is now a simulator configuration and most of the error handling was rewritten.

input updates

There is now working hardware input 🎉. If you have hardware connected you can specify the used serial port in the serial configuration file. The default port is /dev/ttyACM0 so if you use windows you have to change it. The input handler class uses the serial input by default when it is available.

simulator configuration

Now there is a simulator configuration file. It specifies all of the tracks that can be used by the simulator, the location of the serial config file and additional trains that may be used on all tracks. If wanted the index of the default track can also be provided, so that the used track can be changed from the config file. The reference implementation now needs a simulator configuration instead of a Track configuration to start.

Helper class

There now is a helper class to provide useful functions throughout the library. At the moment the following functions are provided:

  • printException -> prints a (nested) exception to make diagnosting runtime problems easier
  • getJsonField -> gets a field from a json object and throws exceptions if it does not exist or has the wrong type
  • getOptionalJsonField -> like getJsonField but no error when it does not exist

More functions will be added in the future.

Error handling

All of the core classes now throw exceptions when something goes wrong in the constructor. The exceptions can be nested to get more details on what went wrong during the runtime without the need for a debugger. To output these exceptions in a nice way the helper class may be used.