Skip to content
This repository was archived by the owner on Sep 6, 2024. It is now read-only.

Gestion d'exceptions#23

Open
efondere wants to merge 14 commits into
mainfrom
dev-exception-handling
Open

Gestion d'exceptions#23
efondere wants to merge 14 commits into
mainfrom
dev-exception-handling

Conversation

@efondere

Copy link
Copy Markdown
Collaborator

Cette PR est assez grosse et je pense qu'elle mérite d'être bien discutée. Je pense avoir bien avancé, mais il risque d'y avoir pas mal de choses à changer (soit maintenant, soit dans le futur quand on va l'utiliser / la tester).

Je me suis basé sur cette page du wiki pour l'implémenter, histoire d'avoir une manière stable de communiquer les messages avec l'interface.

J'ai dû changer quelques paramètres dans la configuration pour tout faire fonctionner, donc j'ai uniformisé un peu le code écrit depuis quelque mois en même temps.

Finalement comme demandé par le reste de l'équipe, on a en général trois niveaux d'exceptions pour les températures et la charge:

  1. Warning: on avertit le pilote qu'il devrait penser à rentrer charger la batterie ou que les températures augmentent et qu'il devrait faire attention;
  2. Alert: il faut retourner au dock, les températures sont trop élevées ou le système risque de s'éteindre par manque d'énergie dans les batteries;
  3. Critical: le bateau doit s'éteindre pour éviter une catastrophe.

Closes: #2
Relates to: #10

@efondere efondere added the enhancement New feature or request label Apr 10, 2024
@efondere efondere self-assigned this Apr 10, 2024
"""
Determines if the message is severe enough to trigger the shutdown procedure.
"""
return get_message_severity(message_id) <= CRITICAL_ERROR

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the higher the message id, the more critical it is?
return message_id >= critical

this would make more sense, but you're the one that knows the message id scale meaning

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question

print(data)
if data.is_valid():
check_results = perform_check(name, data.value)
if isinstance(check_results, list):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isinstance does not comply with coding standards, should be named is_instance or isInstance

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isinstance est une fonction native à Python

int: The message id.
"""

if isinstance(device, str):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_instance instead

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est natif à Python ça se change pas

@EtienneLescarbeault EtienneLescarbeault left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

très clean, juste voir la logique pour require_shutdown sinon c'est bon pour moi

"""
Determines if the message is severe enough to trigger the shutdown procedure.
"""
return get_message_severity(message_id) <= CRITICAL_ERROR

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question

print(data)
if data.is_valid():
check_results = perform_check(name, data.value)
if isinstance(check_results, list):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isinstance est une fonction native à Python

int: The message id.
"""

if isinstance(device, str):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est natif à Python ça se change pas

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gestion des erreurs (threads)

3 participants