Computer-Controlled Railroad Simulator Adrian Anderson

16
Computer-Controlled Railroad Simulator Adrian Anderson http://compsci.snc.edu/cs460/andeaj/

Transcript of Computer-Controlled Railroad Simulator Adrian Anderson

Page 1: Computer-Controlled Railroad Simulator Adrian Anderson

Computer-Controlled Railroad Simulator

Adrian Andersonhttp://compsci.snc.edu/cs460/andeaj/

Page 2: Computer-Controlled Railroad Simulator Adrian Anderson

Project Description Create a model railroad simulator Show graphic representation of trains, turnouts,

and sensors Allow for a custom track design Receive hardware commands from external

programs, and send response commands back Allow the user to recreate certain conditions Simulate hardware failure

Page 3: Computer-Controlled Railroad Simulator Adrian Anderson

Solution Computer-Controlled Railroad Simulator Written in Visual Basic 2005, using .NET

Page 4: Computer-Controlled Railroad Simulator Adrian Anderson

Simulator Internally stores the state of trains, turnouts,

and sensors Moves trains around a virtual track Interface for controlling the track and trains Simulation of ideal, controlled railroad

conditions Check for train collisions “Disasters” – see what happens when things go

wrong

Page 5: Computer-Controlled Railroad Simulator Adrian Anderson

Track Editor Track data stored in an XML file Loaded and stored in an internal database Fully customizable Allows for many different track arrangements

Page 6: Computer-Controlled Railroad Simulator Adrian Anderson

Communications Receives NMRA standard digital railroad

controller packets External programs can interface with the

simulator as if it were a real railroad Change train speed and direction Request state of all sensors Good for testing programs like the Train

Operating System

Page 7: Computer-Controlled Railroad Simulator Adrian Anderson

Methodology Problem: Represent track as computer data Solution:

Junctions Segments, which go from junction to junction Turnouts, which connect two segments at a junction Sensors, which are connected to segments

Page 8: Computer-Controlled Railroad Simulator Adrian Anderson

Methodology Problem: Save and store track data Solutions:

Internal Storage: DataSet Class Visual Basic class, relational database ReadXML command reads and interprets XML files

External Storage: XML Easy to read, interpret, and edit Standard format for miscellaneous data Easy to validate Easy to use in Visual Basic programs

Page 9: Computer-Controlled Railroad Simulator Adrian Anderson

Methodology Problem: Collision detection Solution:

Collision table Train’s movement leaves records in the collision table Compare a train’s potential destination with collision

table records on the same segment/junction If two records overlap, then the trains crash Sensor detection: Trains “collide” with sensors to

activate them

Page 10: Computer-Controlled Railroad Simulator Adrian Anderson

Methodology Problem: Collision detection Solution:

Collision table Train’s movement leaves records in the collision table Compare a train’s potential destination with collision

table records on the same segment/junction If two records overlap, then the trains crash Sensor detection: Trains “collide” with sensors to

activate them

Page 11: Computer-Controlled Railroad Simulator Adrian Anderson

Exceptions Saved state of trains and track Save status log to a file XML validation Preset train types More labels in simulator window

Page 12: Computer-Controlled Railroad Simulator Adrian Anderson

Demonstration

Page 13: Computer-Controlled Railroad Simulator Adrian Anderson

Learning & Development References

MSDN Library Win 32 System Services: The Heart of Windows 95

and Windows NT CS Concepts

Database – track representation, track editor Operating Systems – pipe communication, threading

Page 14: Computer-Controlled Railroad Simulator Adrian Anderson

Extensions Read more types of hardware packets Advanced collision detection More detailed graphical layout More detailed object information

Page 15: Computer-Controlled Railroad Simulator Adrian Anderson

Advice Start early Set concrete goals with deadlines Meet those deadlines Update journal often with small updates

Page 16: Computer-Controlled Railroad Simulator Adrian Anderson

Questions?