kprofile.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. """Pydantic schemas for K-profile (pressure advance) management."""
  2. from pydantic import BaseModel
  3. class KProfile(BaseModel):
  4. """A pressure advance (K) calibration profile stored on the printer."""
  5. slot_id: int # Storage slot on printer (limited capacity ~20 slots)
  6. extruder_id: int = 0 # 0 or 1 for dual nozzle printers
  7. nozzle_id: str # e.g., "HS00-0.4" (hardened steel 0.4mm)
  8. nozzle_diameter: str # e.g., "0.4"
  9. filament_id: str # Bambu filament identifier
  10. name: str # User-defined name for the profile
  11. k_value: str # Pressure advance coefficient as string, e.g., "0.020000"
  12. n_coef: str = "0.000000" # N coefficient (usually 0)
  13. ams_id: int = 0 # AMS unit ID
  14. tray_id: int = -1 # AMS tray ID (-1 if not linked)
  15. setting_id: str | None = None # Unique setting identifier
  16. class KProfileCreate(BaseModel):
  17. """Schema for creating/updating a K-profile."""
  18. slot_id: int = 0 # Storage slot, 0 for new profiles
  19. extruder_id: int = 0
  20. nozzle_id: str
  21. nozzle_diameter: str
  22. filament_id: str
  23. name: str
  24. k_value: str
  25. n_coef: str = "0.000000"
  26. ams_id: int = 0
  27. tray_id: int = -1
  28. setting_id: str | None = None
  29. class KProfilesResponse(BaseModel):
  30. """Response containing K-profiles from a printer."""
  31. profiles: list[KProfile]
  32. nozzle_diameter: str # Current nozzle filter
  33. class KProfileDelete(BaseModel):
  34. """Schema for deleting a K-profile."""
  35. slot_id: int # cali_idx - calibration index to delete
  36. extruder_id: int = 0
  37. nozzle_id: str # e.g., "HH00-0.4"
  38. nozzle_diameter: str # e.g., "0.4"
  39. filament_id: str # Bambu filament identifier
  40. setting_id: str | None = None # Setting ID (for X1C series)
  41. class KProfileNote(BaseModel):
  42. """Schema for K-profile notes (stored locally, not on printer)."""
  43. setting_id: str # Unique identifier for the K-profile
  44. note: str # The note content
  45. class KProfileNoteResponse(BaseModel):
  46. """Response containing notes for K-profiles."""
  47. notes: dict[str, str] # mapping of setting_id -> note