mu-zero-HYPERLOOP / canzero

Control Panel of Mu-Zero Hyperloop Season 4
https://mu-zero.de
6 stars 0 forks source link

Establish connection possible. #68

Closed NiklasHeneka closed 8 months ago

NiklasHeneka commented 8 months ago

When the we should be able to press the connect button to connect to the pos "connecting_to_pod_possible" needs to be called by the backend first. It would be nice if it would be called on startup rightnow I just dont get it to work.

kistenklaus commented 8 months ago

8a93db7 should have fixed the issue the backend now contains a ConnectionObject, which emits events whenever the connection state changes!

Here it should be noted that the Connection Status if different than the State of the System (not a state of the FSM).

ConnectionObject emits the event "connection-status", which as a payload contains the ConnectionStatus enum defined in connection.rs and is serialized as a string

NiklasHeneka commented 8 months ago

You don't send any events yet right?

kistenklaus commented 8 months ago

i will check, but i think so gimmi a min

kistenklaus commented 8 months ago

8a93db71 Following the rest of the architecture and to be consistant the connection_status event has to be listent to if you want i can change that and have it be listened to by default maybe a good idea. What do you think.

Wait and there is no listen command yet ? What seems more reasonable to you? I would be fine with both maybe a listen command is overkill i dont now?

@NiklasHeneka

kistenklaus commented 8 months ago

Interesstingly the current implementation should have a bug, where a tauri event is always broadcasted at the start.

tauri event should be: connection-status

with a string as payload

kistenklaus commented 8 months ago

i asked @arrowtip and the conclusion is default is probably simpler so that what iam going for

kistenklaus commented 8 months ago

the current implementation in 7552a64a0109ba6124b941a20a1ae013d8c1c601 will broadcast the state as a tauri event called connection-status see connection.rs in cnl. However this event might be broadcasted before the react application starts and therefor is dropped by react. That's why a command called get_connection_status() -> ConnectionStatus is provided to fetch the current connection status. ConnectionStatus is serialized as a string see connection.rs on what values are allowed!

If the connection_status changes through the livetime of the application the tauri event will be broadcasted containing the ConnectionStatus as payload serialized as a string.

@NiklasHeneka

NiklasHeneka commented 8 months ago

You can take a look inb5797d5 at the EstablishConnection file in the frontend. It seems that everything works now. Regarding listening I think it is best to listen from start as a default.

kistenklaus commented 8 months ago

i think this looks good right ? You can close if you want to =^)