基本界面达成

This commit is contained in:
2026-05-11 00:21:16 +08:00
parent 649677f564
commit 65f221a5d8
13 changed files with 1818 additions and 347 deletions

View File

@@ -15,63 +15,60 @@ class AIOPrrintSystemAPI:
except:
return None
def print(self, *args, **kwargs):
pass
def get_status(self):
test_data = {
'job': {
'job': {
'estimatedPrintTime': 1234,
'filament': {'length': 765, 'volume': 24356},
'file': {'display_name': 'Test File','date': None, 'name': '20260414135441_42bff5215c6148b8b5f4d8c4f15d5ddc.gcode', 'origin': 'local', 'path': None, 'size': 1468987},
'lastPrintTime': None,
'user': None
},
'progress': {
'completion': 74.8,
'filepos': 1234,
'printTime': 1235,
'printTimeLeft': 6353,
'printTimeLeftOrigin': 5366
},
'state': 'Operational'
},
'status': {
'sd': {'ready': False},
'state': {
'error': '',
'flags': {
'cancelling': False,
'closedOrError': False,
'error': False,
'finishing': False,
'operational': True,
'paused': False,
'pausing': False,
'printing': False,
'ready': True,
'resuming': False,
'sdReady': False
},
'text': 'Operational test'
},
'temperature': {
'bed': {'actual': 85, 'offset': 0, 'target': 56},
'tool0': {'actual': 0.0, 'offset': 0, 'target': 340}
}
}
}
return test_data
# test_data = {
# 'job': {
# 'job': {
# 'estimatedPrintTime': 1234,
# 'filament': {'length': 765, 'volume': 24356},
# 'file': {'display_name': 'Test File','date': None, 'name': '20260414135441_42bff5215c6148b8b5f4d8c4f15d5ddc.gcode', 'origin': 'local', 'path': None, 'size': 1468987},
# 'lastPrintTime': None,
# 'user': None
# },
# 'progress': {
# 'completion': 74.8,
# 'filepos': 1234,
# 'printTime': 1235,
# 'printTimeLeft': 6353,
# 'printTimeLeftOrigin': 5366
# },
# 'state': 'Operational'
# },
# 'status': {
# 'sd': {'ready': False},
# 'state': {
# 'error': '',
# 'flags': {
# 'cancelling': False,
# 'closedOrError': False,
# 'error': False,
# 'finishing': False,
# 'operational': True,
# 'paused': False,
# 'pausing': False,
# 'printing': False,
# 'ready': True,
# 'resuming': False,
# 'sdReady': False
# },
# 'text': 'Operational test'
# },
# 'temperature': {
# 'bed': {'actual': 85, 'offset': 0, 'target': 56},
# 'tool0': {'actual': 0.0, 'offset': 0, 'target': 340}
# }
# }
# }
# return test_data
# url = f"{self.api_url}/status"
# try:
# r = requests.get(url, headers=self.headers, timeout=5)
# r.raise_for_status()
# return r.json()
# except:
# return {"status": {}, "job": {}}
url = f"{self.api_url}/status"
try:
r = requests.get(url, headers=self.headers, timeout=5)
r.raise_for_status()
return r.json()
except:
return {"status": {}, "job": {}}
def pause_print(self):
return self._post_action("pause_print", action="pause")
@@ -79,4 +76,16 @@ class AIOPrrintSystemAPI:
def stop_print(self):
return self._post_action("cancel_print")
def home_axes(self, axes=["x", "y", "z"]):
return self._post_action("home_axes", axes=axes)
def auto_leveling(self):
return self._post_action("auto_leveling")
def send_gcode(self, gcode):
return self._post_action("send_gcode", gcode=gcode)
def off_motors(self):
return self.send_gcode("M84")