Skip to content

29 poprawa logów#30

Open
nG4ZD4 wants to merge 12 commits into
mainfrom
29-poprawa-logów

Hidden character warning

The head ref may contain hidden characters: "29-poprawa-log\u00f3w"
Open

29 poprawa logów#30
nG4ZD4 wants to merge 12 commits into
mainfrom
29-poprawa-logów

Conversation

@nG4ZD4

@nG4ZD4 nG4ZD4 commented Jun 5, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • All log entries across the application now include a timestamp, providing precise timing for each event.
    • The painting process now performs iterative bidirectional moves with platform height adjustments, enhancing operational detail.
  • Style

    • Log displays have been updated to show the time (in HH:MM:SS format) alongside the source and message for improved readability.
    • Log entries are now sorted chronologically in the log display.
  • Chores

    • Minor adjustments to log formatting, such as removing square brackets from source names.

@nG4ZD4 nG4ZD4 linked an issue Jun 5, 2025 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Jun 5, 2025

Copy link
Copy Markdown

Walkthrough

The changes update logging across multiple components by adding ISO 8601 timestamps to each log entry and standardizing the log source field format (removing square brackets). The log display in the panel HTML is also updated to sort entries by time and show the time, source, and message. The malowanie method in MainController was rewritten to perform iterative bidirectional movements with platform height adjustments and detailed logging. No public interfaces were altered.

Changes

File(s) Change Summary
Components/Endstop.py, Components/Motor.py, Components/Ncoder.py, Components/PaintSprayer.py, Components/Platform.py, Components/Robot.py, Components/ScrewMotor.py, Components/Ultrasonic_sensor.py Logging updated: added ISO 8601 timestamp to each log entry and standardized source field (removed brackets).
main.py Logging in MainController updated to include timestamp and standardized source field; malowanie method rewritten for iterative bidirectional moves with platform height stepping and detailed logging.
panel.py Removed redundant status_log initialization; log function now adds timestamp to each log entry.
templates/panel.html Log rendering updated: logs sorted by timestamp, display shows [HH:MM:SS] [source] message.

Poem

In every log, a time now ticks,
With ISO stamps and source that sticks.
No more brackets—just pure delight,
Logs sorted neatly, clear and bright.
The panel gleams with every change,
Rabbits cheer, “Logs rearrange!”
🕒🐇

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8a1888d and eb99e3b.

📒 Files selected for processing (1)
  • main.py (2 hunks)
🔇 Additional comments (2)
main.py (2)

8-8: LGTM!

The datetime import is correctly added to support ISO 8601 timestamps in the logging system.


21-21: Good logging standardization.

The addition of ISO 8601 timestamps and removal of square brackets from the source field aligns well with the PR objectives to improve logging consistency across the system.

Comment thread main.py
Comment on lines +24 to +49
self.log(f"Start malowania: X={x}cm, Z={z}cm", "info")
step = 10 # wysokość kroku w cm
current_z = z
direction = True # True = w prawo, False = w lewo

# Ustaw platformę na wysokość początkową Z
self.robot.platform.move_z_axis(current_z)
self.log(f"Platforma ustawiona na wysokość {current_z} cm", "info")

while current_z > 0:
# Przejedź X w odpowiednim kierunku
self.log(f"Jadę {'w prawo' if direction else 'w lewo'} na odległość {x} cm na wysokości {current_z} cm", "info")
self.robot.move_forward(x if direction else -x, paint_or_not=True)
self.log(f"Przejechano {x} cm na wysokości {current_z} cm", "success")

# Zatrzymaj, opuść o 10 cm
current_z -= step
if current_z <= 0:
self.log("Osiągnięto Z=0, koniec malowania.", "success")
break
self.robot.platform.move_z_axis(-step)
self.log(f"Platforma opuszczona o {step} cm, nowa wysokość: {current_z} cm", "info")

# Zmień kierunek jazdy
direction = not direction

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Fix inconsistent Z-axis positioning and improve robustness.

The rewritten malowanie method implements a good zigzag painting pattern, but there are several issues that need attention:

  1. Inconsistent Z-axis positioning: Line 30 uses absolute positioning while line 44 uses relative movement
  2. Redundant condition check: The if current_z <= 0 check inside the while loop is unnecessary since the while condition already handles this
  3. Missing error handling: No try/catch blocks around robot movements
  4. Missing input validation: No validation for x and z parameters

Apply this diff to fix the positioning inconsistency and remove redundancy:

-        # Ustaw platformę na wysokość początkową Z
-        self.robot.platform.move_z_axis(current_z)
-        self.log(f"Platforma ustawiona na wysokość {current_z} cm", "info")
+        # Ustaw platformę na wysokość początkową Z (absolutna pozycja)
+        self.robot.platform.move_z_axis_absolute(current_z)
+        self.log(f"Platforma ustawiona na wysokość {current_z} cm", "info")

         while current_z > 0:
             # Przejedź X w odpowiednim kierunku
             self.log(f"Jadę {'w prawo' if direction else 'w lewo'} na odległość {x} cm na wysokości {current_z} cm", "info")
             self.robot.move_forward(x if direction else -x, paint_or_not=True)
             self.log(f"Przejechano {x} cm na wysokości {current_z} cm", "success")

             # Zatrzymaj, opuść o 10 cm
             current_z -= step
-            if current_z <= 0:
-                self.log("Osiągnięto Z=0, koniec malowania.", "success")
-                break
+            if current_z > 0:
-            self.robot.platform.move_z_axis(-step)
-            self.log(f"Platforma opuszczona o {step} cm, nowa wysokość: {current_z} cm", "info")
+                self.robot.platform.move_z_axis(-step)
+                self.log(f"Platforma opuszczona o {step} cm, nowa wysokość: {current_z} cm", "info")

             # Zmień kierunek jazdy
             direction = not direction

Consider adding input validation and error handling:

def malowanie(self, x, z):
    # Input validation
    if x <= 0 or z <= 0:
        self.log("Błędne parametry: x i z muszą być większe od 0", "error")
        return
    
    self.log(f"Start malowania: X={x}cm, Z={z}cm", "info")
    
    try:
        # ... existing logic with error handling
    except Exception as e:
        self.log(f"Błąd podczas malowania: {str(e)}", "error")
        return
🤖 Prompt for AI Agents
In main.py around lines 24 to 49, fix the inconsistent Z-axis positioning by
using either absolute or relative movement consistently—replace the relative
move_z_axis(-step) call with an absolute move_z_axis(current_z) call. Remove the
redundant if current_z <= 0 check inside the while loop since the loop condition
already covers it. Add input validation at the start of the malowanie method to
check that x and z are greater than zero, logging an error and returning early
if not. Wrap the main painting logic inside a try/except block to catch
exceptions during robot movements, logging any errors encountered and stopping
execution gracefully.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Poprawa logów

1 participant