Welcome to TrainThing’s documentation!¶
This is just the beginning
This is the software for the LapTop, part 4 of the TrainThing¶
This top level module provides a menu of program options to display and implement passing commands and responses to/from module client for RPi and Arduino Base Station.
- main.VERBOSE = True¶
Generates additional print lines to help troubleshooting
Uses module Client to open an internet connection to TrainThing. provide menu of options Passes Commands/responses between options and Client. If nothing else happens send wakeup status command every 30 seconds
This module provides: A socket client for the internet (WiFi LAN) connection to the Raspberry Pi (3), running TrainThing software, and on to the Arduino (2), running the DCC++ Base Station. All DCC++ and TrainThing commands strings passed to this module are sent to the Raspberry Pi. All received status messages are converted from bytes to strings bounded by “<” and “>”.
- class client.Client¶
Establish internet client (WiFi LAN) connection with Raspberry Pi server
- __init__() None ¶
Initialize link to Raspberry Pi. Start thread to receive responses
- _receive() None ¶
Thread to receive responses from RPi/Arduino
- get_response() str ¶
- send(msg: str) None ¶
Send command to Raspberry Pi/Arduino
Opens a window to enter a command to send to TrainThing. No editing or validity checking.
Replacement for module “dumb” . Open a window to enter DCC++ and TrainThing commands to be sent to the Raspberry Pi and Arduino. Bracketing “<” and “>” are provided. Command syntax and value validity are checked.
Opens a window to display traffic between the laptop and TrainThing.
Replacement for module “dump”. Opens a window to display traffic between the laptop and TrainThing with decoding of each command/response.
Provides a menu of data elements/tables to print in a ‘pretty’ format.
This module contains all aspects and methods related to TrainThing semaphore signals, establishing signal aspect and sending commands to RPi to change signals.
The aspect of each signal depends on the state of turnouts and track
- class HW.signals.Signals¶
Signal aspects and methods
- B_CLEAR = 0¶
- T_CLEAR = 1¶
- T_THROWN = 2¶
- T_UNKN = 0¶
- X_CLEAR = 0¶
- X_EVEN = 2¶
- X_ODD = 1¶
- __init__() None ¶
Use db to load saved configuration
- _change_aspect(part: chr, value: int) tuple ¶
part (chr) – ‘T’urnout, ‘B’lock, ‘T’urnout, ‘X’ing that changed
value (int) – Which element of tbx changed
a tuple of tuples. Each tuple is (pole, top, aspect)
- signal_com(com: str) str ¶
Process DCC++ added commands A|G|K|N|n Validates command and parameters saves results waits for RPi response G|K|n|U ~~ NOT V add saved data.
valid commands use _update_signal() to send A|G|K|N|n commands to RPi
- track_change(track: int, new_state: int) None ¶
module track sends changed status of a block of track
- turnout_change(turnout: int, new_state: int) None ¶
module turnout sends change in turnout status
- xing_change(new_state: int) None ¶
Module Xing sends change in the crossing status
This module contains all aspects and methods related to TrainThing railroad track status
- HW.track.B_CLEAR = 0¶
The BLOCK of track is not occupied. 1-5 occupied at location
- HW.track.B_PARK = 6¶
The BLOCK of track is coded for the Parking Lot.
This module contains all aspects and methods related to TrainThing Crossing status
- HW.xing.X_CLEAR = 0¶
Crossing is not in use
- HW.xing.X_EVEN = 2¶
Crossing in use top-right/bottom-left
- HW.xing.X_ODD = 1¶
Crossing in use top-left/bottom-right
- class HW.xing.Xing¶
Xing aspects and methods
- clear_xing(train: int) bool ¶
if train is the train using the crossing, release crossing and clear stored train
- Return bool
True if xing cleared
- get_xing() int ¶
When requested (by signals) return current status of the Crossing
- set_xing(train: int, state: int) bool ¶
If crossing is available, commit crossing in state to train
- Return bool
True of assigned, False if in use
This module contains all aspects and methods related to TrainThing railroad turnout status
- HW.turnouts.T_CLEAR = 1¶
Turnout in CLEAR state
- HW.turnouts.T_THROWN = 2¶
Turnout in THROWN state
- HW.turnouts.T_UNKN = 0¶
Turnout in unknown state
- class HW.turnouts.Turnouts¶
Turnout aspects and methods based on the state of two sensors.
- all_turnout() dir ¶
When requested (by signals) return pairs of all turnout # and current state
- get_turnout(name: int) int ¶
- Return int
status of named turnout
- turnout_command() None ¶
Process DCC++ commands T|E|e etc, Validates command and parameters saves results waits for Arduino response add saved data.
valid commands use _update_turnout() to send TEe commands onto Arduino