- Rust 100%
| .cargo | ||
| .forgejo/workflows | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE.txt | ||
| README.md | ||
TTK4145 Elevator
This repo contains the code required to fulfill the requirements presented in the TTK4145 project to control an elevator.
This solution to the elevator project uses a peer-to-peer, UDP based system,
with time as the synchronization mechanism between the elevators.
To achieve a relatively-similar time reference the system time is ignored,
and time is fetched from Justervesenet's NTP server.
Prerequisites
The following dependencies are required to build the project:
- Rust
- Probably the
openssl-devpackage
Other dependencies should not be required, but this has not been extensively tested. If any other dependencies are found, feel free to contact the project authors.
Note
The program should work under Windows, but has not been extensively tested on this operating system.
Supported operating systems are:
- Ubuntu 22.04
- Ubuntu 24.04
- OpenSuse Tumbleweed 20260316
Running the Program
To run the program from source run the following command in the project folder:
cargo run --release
The program is optionally able to run with command line flags to override default options.
To see these flags run the program with the -h or --help parameter.
Example:
$ cargo run --release -- -h
A simple peer-to-peer elevator controller program
Usage: elevator [OPTIONS]
Options:
-i, --id <ID>
Optional user specified elevator ID
-e, --elevator-port <ELEVATOR_PORT>
The port used to communicate with the elevatorserver
-b, --broadcast-ports <BROADCAST_PORTS>
The port(s) used for broadcasting network updates
-l, --listen-port <LISTEN_PORT>
The port this elevator uses to listen to messages from the network
-h, --help
Print help
-V, --version
Print version
Developing
Program Architecture
The elevator program consists of several asynchronous tasks running concurrently.
Each task should have a single well-defined purpose, and do nothing other than that purpose.
To see which tasks exist, and their purpose open the documentation
and inspect the tasks module.
Inside the tasks module each file should contain a module level doc-comment explaining its purpose.
Project Structure
The project is split into several parts:
- Tasks, which run the actual elevator
- State, contains structures and methods to mutate the system state
Below is the file hierarchy with explanatory comments
.
├── Cargo.lock
├── Cargo.toml # Project dependency definitions
├── README.md # Project README file, aka this file
└── src
├── main.rs # Main project file
├── state # Directory containing state related structures
├── tasks # Directory containing individual tasks
└── time.rs # File containing time related code
Opening the Documentation
The program documentation is written using the documentation feature in Cargo.
To view the documentation run the following command:
cargo doc --open
Running the Tests
The code contains several unit- and integration-tests. To run these tests perform the following command:
cargo test