Project in TTK4145 to control a distributed networked elevator system
Find a file
Sebastian Gabrielli 4babb43af9
All checks were successful
/ build_and_test (push) Successful in 40s
/ Static Release Build (push) Has been skipped
Remove unneccesary assert
2026-03-18 21:33:39 +01:00
.cargo Ensure tests are run sequentially 2026-02-18 19:09:13 +01:00
.forgejo/workflows Select functioning artifact version 2026-02-25 15:56:58 +01:00
src Remove unneccesary assert 2026-03-18 21:33:39 +01:00
.gitignore Merge branch 'main' into fix-sync-issue-two 2026-03-17 12:23:50 +01:00
Cargo.lock Add a license & bump project to version 1.0 2026-03-18 20:01:23 +01:00
Cargo.toml Merge branch 'main' into add-network-doccomment 2026-03-18 21:28:20 +01:00
LICENSE.txt Add a license & bump project to version 1.0 2026-03-18 20:01:23 +01:00
README.md Remove fake space character in README 2026-03-18 20:41:12 +01:00

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-dev package

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