light_handler #24

Merged
Athamantis merged 36 commits from light_handler into main 2026-03-08 19:35:56 +00:00
Owner
No description provided.
make skeleton code for light_handler
All checks were successful
/ build_and_test (push) Successful in 31s
79000575b8
add select to check different recievings
Some checks failed
/ build_and_test (push) Failing after 21s
aa57e0ffc2
Merge branch 'main' into light_handler
All checks were successful
/ build_and_test (push) Successful in 22s
/ Static Release Build (push) Has been skipped
905427ec92
idk
All checks were successful
/ build_and_test (push) Successful in 22s
/ Static Release Build (push) Has been skipped
d1071c017f
adding somtething
Some checks failed
/ build_and_test (push) Failing after 14s
/ Static Release Build (push) Has been skipped
33088fc02f
something
Some checks failed
/ build_and_test (push) Failing after 14s
/ Static Release Build (push) Has been skipped
7fdd4fe5ab
changing how the lighthandler works
All checks were successful
/ build_and_test (push) Successful in 1m27s
/ Static Release Build (push) Has been skipped
f330d18709
something
All checks were successful
/ build_and_test (push) Successful in 22s
/ Static Release Build (push) Has been skipped
c6a8e07c76
jeg hadde en lys ide - Seb
Some checks failed
/ build_and_test (push) Failing after 18s
/ Static Release Build (push) Has been skipped
4924eaa402
eller noe mer saklig
add set light function with elevator light handling
All checks were successful
/ build_and_test (push) Successful in 24s
/ Static Release Build (push) Has been skipped
f6bb3a3d8e
Merge branch 'main' into light_handler
All checks were successful
/ build_and_test (push) Successful in 25s
/ Static Release Build (push) Has been skipped
bf778aac61
door light is lighting
All checks were successful
/ build_and_test (push) Successful in 26s
/ Static Release Build (push) Has been skipped
480140696b
clean up some code
All checks were successful
/ build_and_test (push) Successful in 27s
/ Static Release Build (push) Has been skipped
afc9612ad0
Merge branch 'main' into light_handler
All checks were successful
/ build_and_test (push) Successful in 1m39s
/ Static Release Build (push) Has been skipped
858005b1e0
fix lights
All checks were successful
/ build_and_test (push) Successful in 30s
/ Static Release Build (push) Has been skipped
08af70bdeb
ghgfjhg|
All checks were successful
/ build_and_test (push) Successful in 30s
/ Static Release Build (push) Has been skipped
681b5916bf
onecell does not work propperly
Some checks failed
/ build_and_test (push) Failing after 28s
/ Static Release Build (push) Has been skipped
4174011b69
something works, now floor light indication works, kinda, hope so, do
All checks were successful
/ build_and_test (push) Successful in 28s
/ Static Release Build (push) Has been skipped
d105692aa8
not know why
add comments to light_handler and fix comments on the floor handler
All checks were successful
/ build_and_test (push) Successful in 28s
/ Static Release Build (push) Has been skipped
582905b1e8
uncommented some comments, that were debug and info prints to seb
All checks were successful
/ build_and_test (push) Successful in 28s
/ Static Release Build (push) Has been skipped
dece3bbb74
something
All checks were successful
/ build_and_test (push) Successful in 29s
/ Static Release Build (push) Has been skipped
a89cdcd245
unncoment
All checks were successful
/ build_and_test (push) Successful in 28s
/ Static Release Build (push) Has been skipped
8a11ff72fb
Merge branch 'main' into light_handler
All checks were successful
/ build_and_test (push) Successful in 30s
/ Static Release Build (push) Has been skipped
8a32bb3b3b
remove an error
All checks were successful
/ build_and_test (push) Successful in 30s
/ Static Release Build (push) Has been skipped
326f2f6cbe
Athamantis force-pushed light_handler from 326f2f6cbe
All checks were successful
/ build_and_test (push) Successful in 30s
/ Static Release Build (push) Has been skipped
to 8a11ff72fb
All checks were successful
/ build_and_test (push) Successful in 28s
/ Static Release Build (push) Has been skipped
2026-03-08 12:39:15 +00:00
Compare
Merge branch 'main' into light_handler
All checks were successful
/ build_and_test (push) Successful in 30s
/ Static Release Build (push) Has been skipped
9bce6d0123
some debugs
All checks were successful
/ build_and_test (push) Successful in 31s
/ Static Release Build (push) Has been skipped
3fb68682be
remove hall_lights and cab_ligts from the structs
All checks were successful
/ build_and_test (push) Successful in 30s
/ Static Release Build (push) Has been skipped
a77ca5c53f
add some logs
All checks were successful
/ build_and_test (push) Successful in 29s
/ Static Release Build (push) Has been skipped
40fdba099a
add one info
All checks were successful
/ build_and_test (push) Successful in 30s
/ Static Release Build (push) Has been skipped
70c5238710
added a different time
All checks were successful
/ build_and_test (push) Successful in 30s
/ Static Release Build (push) Has been skipped
a3f274ce1e
implement check who owns the cab call
All checks were successful
/ build_and_test (push) Successful in 30s
/ Static Release Build (push) Has been skipped
0568dab64d
add and remove some comments
All checks were successful
/ build_and_test (push) Successful in 30s
/ Static Release Build (push) Has been skipped
78675eeb4b
change poll rate
All checks were successful
/ build_and_test (push) Successful in 30s
/ Static Release Build (push) Has been skipped
e752ba57b6
add out commented logs and add some doc comments
All checks were successful
/ build_and_test (push) Successful in 30s
/ Static Release Build (push) Has been skipped
632da44a9d
Athamantis changed title from WIP: light_handler to light_handler 2026-03-08 17:08:31 +00:00
Merge branch 'main' into light_handler
All checks were successful
/ build_and_test (push) Successful in 36s
/ Static Release Build (push) Has been skipped
2ecbd63783
sebgab requested changes 2026-03-08 17:37:22 +00:00
Dismissed
sebgab left a comment
Owner

A couple of things. I am sorry.

image
image

A couple of things. I am sorry. ![image](/attachments/c02f4397-d5c1-45bf-ab8b-afeb554cae83) ![image](/attachments/e1091360-ba45-4b90-b37d-22de8a57ad04)
382 KiB
1.2 MiB
@ -9,6 +9,8 @@ use std::time::Duration;
use tokio::net::UdpSocket;
use tokio::sync::mpsc;
pub const MIN_TX_PUBLISHING_RATE: Duration = Duration::from_millis(250);
Owner

Please write doccomment.

Please write doccomment.
Athamantis marked this conversation as resolved
@ -11,3 +11,3 @@
// Waiting for recieved information on the `floor_sensor_rx` from the elevator
let recieved_floor: u8 = floor_rx.recv().unwrap();
trace!("Recieved from floor controller {:?}", recieved_floor);
info!("Recieved from floor controller {:?}", recieved_floor);
Owner

I don't think this should be trace

I don't think this should be trace
Athamantis marked this conversation as resolved
@ -0,0 +8,4 @@
use log::{debug, error, info, trace};
use std::collections::HashMap;
use strum::IntoEnumIterator;
use tokio::sync::Notify; // 0.17.1
Owner

Why the 0.17.1 comment?

Why the 0.17.1 comment?
Athamantis marked this conversation as resolved
@ -0,0 +47,4 @@
for call in &total_calls {
let should_be_on =
{ call.should_light_be_on(system_state.read().unwrap().elevators.clone()) };
if should_be_on {
Owner

This is very nested and a bit hard to follow.
Can I suggest doing some inverted logic?

e.g.

if !should_be_on {
 continue;
}
This is _very_ nested and a bit hard to follow. Can I suggest doing some inverted logic? e.g. ```rust if !should_be_on { continue; } ```
Author
Owner

done this

done this
Author
Owner

not enough brain capacity to do this at the moment

not enough brain capacity to do this at the moment
Owner

Fuck it, we ball

Fuck it, we ball
sebgab marked this conversation as resolved
@ -0,0 +33,4 @@
for floor in Destination::iter() {
lights.insert(Lights::Cab(floor), LightState::Off);
// NOTE: not most modular if one wants 5 floors...
Owner

Can I suggest implementing Destination::MAX and Destination::MIN?

Can I suggest implementing `Destination::MAX` and `Destination::MIN`?
Author
Owner

added

added
Athamantis marked this conversation as resolved
@ -0,0 +34,4 @@
lights.insert(Lights::Cab(floor), LightState::Off);
// NOTE: not most modular if one wants 5 floors...
if floor != Destination::Floor1 {
Owner

Both of these if statements could be one match.

match floor {
  Destination::Floor1 | Destination::Floor4 => {},
  _ => lights.insert(...),
}
Both of these if statements could be _one_ match. ```rust match floor { Destination::Floor1 | Destination::Floor4 => {}, _ => lights.insert(...), } ```
Author
Owner

eh? how?

eh? how?
Owner

Fuck it, we ball

Fuck it, we ball
sebgab marked this conversation as resolved
@ -0,0 +43,4 @@
}
// Check if lights should be on
let total_calls = { system_state.clone().read().unwrap().calls.calls.clone() };
Owner

This is not a total of the calls, this is just a copy of the calls?

This is not a total of the calls, this is just a copy of the calls?
Author
Owner

changed to calls

changed to calls
Athamantis marked this conversation as resolved
@ -0,0 +77,4 @@
}
// Apply it to the console
for (lights, light_state) in lights {
Owner

You get lights from lights? I know what is happening, but the variable name is confusing.

You get `lights` from `lights`? I know what is happening, but the variable name is confusing.
Author
Owner

it was ment to be light

it was ment to be light
Athamantis marked this conversation as resolved
@ -0,0 +78,4 @@
// Apply it to the console
for (lights, light_state) in lights {
let (floor, call_type) = match lights {
Owner

I really struggle to follow this match statement, I am sorry...

I really struggle to follow this match statement, I am sorry...
Author
Owner

its okay
added some comments? maybe helping
recomended: sleep

its okay added some comments? maybe helping recomended: sleep
Owner

Fuck it, we ball

Fuck it, we ball
sebgab marked this conversation as resolved
@ -0,0 +46,4 @@
let total_calls = { system_state.clone().read().unwrap().calls.calls.clone() };
for call in &total_calls {
let should_be_on =
{ call.should_light_be_on(system_state.read().unwrap().elevators.clone()) };
Owner

Why are we cloning so much, can this not take a reference?

Why are we cloning so much, can this not take a reference?
Author
Owner

you showed me one example! there was clone, and now i am forever cloning

you showed me one example! there was clone, and now i am forever cloning
Author
Owner

and as logic is now these get as ref functions does not work. one gets my own elevator, another gets elevator but needs id

and as logic is now these get as ref functions does not work. one gets my own elevator, another gets elevator but needs id
Owner

and as logic is now these get as ref functions does not work

Pain, but we are on desktop, so whatever.

> and as logic is now these get as ref functions does not work Pain, but we are on desktop, so whatever.
sebgab marked this conversation as resolved
@ -0,0 +103,4 @@
};
match floor {
Some(t) => {
// NOTE: Remove this line of code is something does not work.
Owner

Consider removing this note, it should work now, right?

Consider removing this note, it should work now, right?
Author
Owner

considered and done

considered and done
Athamantis marked this conversation as resolved
@ -0,0 +146,4 @@
door_notification: Arc<Notify>,
) {
loop {
let _ = light_controller(
Owner

Why do we have let _ =, this function does not return anything?

Why do we have `let _ =`, this function does not return anything?
Athamantis marked this conversation as resolved
@ -0,0 +162,4 @@
//!
//! ----------------------------------------------------------------------
//! NOTE: Light handler was tested on the actual elevator and therefore has no implemented
//! tests at the moment
Owner

image

![image](/attachments/4efa4926-cf4c-479e-88d2-08526affab96)
807 KiB
Author
Owner

nice!

nice!
Athamantis marked this conversation as resolved
@ -159,7 +194,7 @@ pub struct StateUpdateSource {
}
/// Information about a single elevator and it's state
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
Owner

Please, re-derive these functions if possible.

Please, re-derive these functions if possible.
Author
Owner

removed or added, how you look at it

removed or added, how you look at it
Athamantis marked this conversation as resolved
@ -11,8 +11,9 @@ use std::{
sync::OnceLock,
time::{Duration, SystemTime},
};
use strum_macros::EnumIter; // 0.17.1
Owner

Again, why the version number?

Again, why the version number?
Author
Owner

removed

removed
Athamantis marked this conversation as resolved
implemented min and max
All checks were successful
/ build_and_test (push) Successful in 29s
/ Static Release Build (push) Has been skipped
9377eb626a
fix comments from review
All checks were successful
/ build_and_test (push) Successful in 29s
/ Static Release Build (push) Has been skipped
6a56fd2115
sebgab approved these changes 2026-03-08 19:29:33 +00:00
sebgab left a comment
Owner

Fuck it, we ball

Fuck it, we ball
Merge branch 'main' into light_handler
All checks were successful
/ build_and_test (push) Successful in 29s
/ Static Release Build (push) Has been skipped
80005a132b
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
TTK4145/elevator!24
No description provided.