# martinawk/heislab2 architecture

> Architecture diagram of the GitHub repository martinawk/heislab2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/martinawk/heislab2
- Repository: https://github.com/martinawk/heislab2

## Overview

This is a coursework repository of elevator-control implementations and process/networking experiments, rather than one integrated product. The principal workflow is elevator inputs → request/FSM decisions → motor, door, and lamp outputs; a separate variant adds master-listening behavior. Other branches demonstrate file-based process failover, UDP master-ID discovery, and a standalone TCP client. The README gives no capability detail, so component links below rely on sampled code; unsampled modules are included only where the tree identifies them, and are not given speculative connections.

Main entry points: [`single_elevator/driver-go-master/main.go`](https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/main.go) (Single-elevator loop), [`single_elevator/driver-go-master/fsm/fsm.go`](https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/fsm/fsm.go) (Elevator FSM), [`Excer4_ProcessPair_correct_kill/main.go`](https://github.com/martinawk/heislab2/blob/master/Excer4_ProcessPair_correct_kill/main.go) (File failover loop), [`single_elevator/driver-go-master/elevio/elevator_io.go`](https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/elevio/elevator_io.go) (Hardware I/O)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_elevator["Elevator control"]
  node_single_main["Single-elevator loop<br/>[main.go]"]
  node_config["Elevator config<br/>[config.go]"]
  node_state["Elevator state<br/>[elevator.go]"]
  node_io["Hardware I/O<br/>[elevator_io.go]"]
  node_fsm["Elevator FSM<br/>[fsm.go]"]
  node_requests["Request policy<br/>[requests.go]"]
  node_timer["Door timer<br/>[timer.go]"]
end

subgraph group_cluster["Master coordination"]
  node_cluster_main["Clustered loop<br/>[main.go]"]
  node_master["Master functions<br/>[masterfunctions.go]"]
end

subgraph group_failover["Process failover"]
  node_file_main["File failover loop<br/>[main.go]"]
  node_data[("Progress file<br/>[data.txt]")]
  node_pid[("Process ID file<br/>[pid.txt]")]
end

subgraph group_network["Network experiments"]
  node_network_main["UDP peer experiment<br/>[main.go]"]
  node_tcp_client["TCP client<br/>[TCP.go]"]
  node_tcp_service(("TCP service"))
  node_udp_receiver["UDP receiver helper<br/>[UDP_rec.go]"]
end

node_operator(("Elevator user"))

node_operator -->|"presses controls"| node_io
node_single_main -->|"initializes and polls"| node_io
node_single_main -->|"initializes state"| node_state
node_single_main -->|"dispatches events"| node_fsm
node_single_main -->|"reads timer channel"| node_timer
node_fsm -->|"evaluates requests"| node_requests
node_fsm -->|"sets hardware outputs"| node_io
node_fsm -->|"starts timer"| node_timer
node_requests -->|"reads and clears"| node_state
node_single_main -->|"uses settings"| node_config
node_cluster_main -->|"listens for master"| node_master
node_cluster_main -->|"dispatches events"| node_fsm
node_file_main -->|"reads and writes"| node_data
node_file_main -->|"reads and writes"| node_pid
node_file_main -->|"restarts process"| node_file_main
node_network_main -->|"broadcasts and receives IDs"| node_network_main
node_tcp_client -->|"exchanges messages"| node_tcp_service

click node_single_main "https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/main.go"
click node_cluster_main "https://github.com/martinawk/heislab2/blob/master/InTheBeninging/gruppe21_mandag/driver-go-master/main.go"
click node_config "https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/config/config.go"
click node_state "https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/elevator/elevator.go"
click node_io "https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/elevio/elevator_io.go"
click node_fsm "https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/fsm/fsm.go"
click node_requests "https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/requests/requests.go"
click node_timer "https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/timer/timer.go"
click node_master "https://github.com/martinawk/heislab2/blob/master/InTheBeninging/gruppe21_mandag/driver-go-master/masterfunctions/masterfunctions.go"
click node_file_main "https://github.com/martinawk/heislab2/blob/master/Excer4_ProcessPair_correct_kill/main.go"
click node_data "https://github.com/martinawk/heislab2/blob/master/Excer4_ProcessPair_correct_kill/data.txt"
click node_pid "https://github.com/martinawk/heislab2/blob/master/Excer4_ProcessPair_correct_kill/pid.txt"
click node_network_main "https://github.com/martinawk/heislab2/blob/master/Excer4/Excer_4_Network/main.go"
click node_tcp_client "https://github.com/martinawk/heislab2/blob/master/TCP.go"
click node_udp_receiver "https://github.com/martinawk/heislab2/blob/master/UDP_rec.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_single_main,node_config,node_state,node_io,node_fsm,node_requests,node_timer,node_operator toneBlue
class node_cluster_main,node_master toneAmber
class node_file_main,node_data,node_pid toneMint
class node_network_main,node_tcp_client,node_tcp_service,node_udp_receiver toneRose
```

## Components

### Elevator control

- [Single-elevator loop](https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/main.go): `single_elevator/driver-go-master/main.go`
- [Elevator config](https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/config/config.go): `single_elevator/driver-go-master/config/config.go`
- [Elevator state](https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/elevator/elevator.go): `single_elevator/driver-go-master/elevator/elevator.go`
- [Hardware I/O](https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/elevio/elevator_io.go): `single_elevator/driver-go-master/elevio/elevator_io.go`
- [Elevator FSM](https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/fsm/fsm.go): `single_elevator/driver-go-master/fsm/fsm.go`
- [Request policy](https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/requests/requests.go): `single_elevator/driver-go-master/requests/requests.go`
- [Door timer](https://github.com/martinawk/heislab2/blob/master/single_elevator/driver-go-master/timer/timer.go): `single_elevator/driver-go-master/timer/timer.go`

### Master coordination

- [Clustered loop](https://github.com/martinawk/heislab2/blob/master/InTheBeninging/gruppe21_mandag/driver-go-master/main.go): `InTheBeninging/gruppe21_mandag/driver-go-master/main.go`
- [Master functions](https://github.com/martinawk/heislab2/blob/master/InTheBeninging/gruppe21_mandag/driver-go-master/masterfunctions/masterfunctions.go): `InTheBeninging/gruppe21_mandag/driver-go-master/masterfunctions/masterfunctions.go`

### Process failover

- [File failover loop](https://github.com/martinawk/heislab2/blob/master/Excer4_ProcessPair_correct_kill/main.go): `Excer4_ProcessPair_correct_kill/main.go`
- [Progress file](https://github.com/martinawk/heislab2/blob/master/Excer4_ProcessPair_correct_kill/data.txt): `Excer4_ProcessPair_correct_kill/data.txt`
- [Process ID file](https://github.com/martinawk/heislab2/blob/master/Excer4_ProcessPair_correct_kill/pid.txt): `Excer4_ProcessPair_correct_kill/pid.txt`

### Network experiments

- [UDP peer experiment](https://github.com/martinawk/heislab2/blob/master/Excer4/Excer_4_Network/main.go): `Excer4/Excer_4_Network/main.go`
- [TCP client](https://github.com/martinawk/heislab2/blob/master/TCP.go): `TCP.go`
- **TCP service**
- [UDP receiver helper](https://github.com/martinawk/heislab2/blob/master/UDP_rec.go): `UDP_rec.go`

### Other components

- **Elevator user**

## Connections

- Elevator user → Hardware I/O: presses controls
- Single-elevator loop → Hardware I/O: initializes and polls (evidence: `single_elevator/driver-go-master/main.go`)
- Single-elevator loop → Elevator state: initializes state (evidence: `single_elevator/driver-go-master/main.go`)
- Single-elevator loop → Elevator FSM: dispatches events (evidence: `single_elevator/driver-go-master/main.go`)
- Single-elevator loop → Door timer: reads timer channel (evidence: `single_elevator/driver-go-master/main.go`)
- Elevator FSM → Request policy: evaluates requests (evidence: `single_elevator/driver-go-master/fsm/fsm.go`)
- Elevator FSM → Hardware I/O: sets hardware outputs (evidence: `single_elevator/driver-go-master/fsm/fsm.go`)
- Elevator FSM → Door timer: starts timer (evidence: `single_elevator/driver-go-master/fsm/fsm.go`)
- Request policy → Elevator state: reads and clears (evidence: `single_elevator/driver-go-master/requests/requests.go`)
- Single-elevator loop → Elevator config: uses settings (evidence: `single_elevator/driver-go-master/main.go`)
- Clustered loop → Master functions: listens for master (evidence: `InTheBeninging/gruppe21_mandag/driver-go-master/main.go`)
- Clustered loop → Elevator FSM: dispatches events (evidence: `InTheBeninging/gruppe21_mandag/driver-go-master/main.go`)
- File failover loop → Progress file: reads and writes (evidence: `Excer4_ProcessPair_correct_kill/main.go`)
- File failover loop → Process ID file: reads and writes (evidence: `Excer4_ProcessPair_correct_kill/main.go`)
- File failover loop → File failover loop: restarts process (evidence: `Excer4_ProcessPair_correct_kill/main.go`)
- UDP peer experiment → UDP peer experiment: broadcasts and receives IDs (evidence: `Excer4/Excer_4_Network/main.go`)
- TCP client → TCP service: exchanges messages (evidence: `TCP.go`)
