Access and Documentation System for the Fab Lab that logs temperature data of ongoing prints, makes data available through an API and offers the possibility to control prints. It acts as an interface for printers located in the Fab Lab.
The Project is based on Django.
$ python --version
docker-compose run --build
$ python manage.py makemigrations
$ python manage.py migrate
This will make sure the database has all the models to work with
Settings > OCTOPRINT > Pluginmanager
install the MQTT Plugin (by Gina Häußge)Settings > PLUGINS > MQTT > Broker
set:
mqtt
1883
testuser
testpasswd
Settings > PLUGINS > MQTT > Topics
set:
fablab/printers/testprinter/
docker-compose run --build
The Api (http://localhost:8000/api/) should now be available to you. In order to access the "Manage Printers"-tab (http://localhost:8000/manage/) you need to access the database directly and change your just created User to is_staff=true
and is_superuser=true
PyCharm is a very popular and one of the best IDE for developing python application. You can download and install PyCharm by following below steps:
Run tests with the following command:
$ python manage.py test
http://localhost:8000/api/print/
HTTP 201 Create
Example successful response:
{
"done": false,
"files": {
"local": {
"name": "boat_1HhpkoU.gcode",
"origin": "local",
"path": "boat_1HhpkoU.gcode",
"refs": {
"download": "http://octoprint:5000/downloads/files/local/boat_1HhpkoU.gcode",
"resource": "http://octoprint:5000/api/files/local/boat_1HhpkoU.gcode"
}
},
"sdcard": {
"name": "boat_1~1.gco",
"origin": "sdcard",
"path": "boat_1~1.gco",
"refs": {
"resource": "http://octoprint:5000/api/files/sdcard/boat_1~1.gco"
}
}
}
}
http://localhost:8000/api/stopprint/
HTTP 204 No Content
Example successful response:
[]
http://localhost:8000/api/users/
HTTP 200 Ok
Example successful response:
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"url": "http://localhost:8000/api/users/1/",
"username": "superuser",
"email": "",
"groups": []
}
]
}
http://localhost:8000/api/groups/
HTTP 200 Ok
Example successful response:
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"url": "http://localhost:8000/api/groups/1/",
"name": "Testgroup"
}
]
}
http://localhost:8000/api/models/
HTTP 200 Ok
Example successful response (Logged in UserID:1):
[
{
"id": 1,
"Name": "ghost",
"FileName": "ghost.stl",
"Size": "3501284",
"File": "/upload/models/ghost_92lAXd9.stl",
"Uploaded": "2021-10-19T10:57:44.211590+02:00",
"Owner": 1,
"Previous": null,
"SharedWithUser": null
},
{
"id": 2,
"Name": "ghost",
"FileName": "ghost.stl",
"Size": "3501284",
"File": "/upload/models/ghost_lsaRxE9.stl",
"Uploaded": "2021-10-19T10:58:13.225555+02:00",
"Owner": 1,
"Previous": null,
"SharedWithUser": 2
}
]
http://localhost:8000/api/models/?id=MODELID
HTTP 200 Ok
Example successful response (?id=1, Logged in UserID:1):
{
"id": 1,
"Name": "ghost",
"FileName": "ghost.stl",
"Size": "3501284",
"File": "/upload/models/ghost_92lAXd9.stl",
"Uploaded": "2021-10-19T10:57:44.211590+02:00",
"Owner": 1,
"Previous": null,
"SharedWithUser": null
}
http://localhost:8000/api/models/?name=MODELNAME
HTTP 200 Ok
Example successful response (?name=ghost, Logged in UserID:1):
[
{
"id": 1,
"Name": "ghost",
"FileName": "ghost.stl",
"Size": "3501284",
"File": "/upload/models/ghost_92lAXd9.stl",
"Uploaded": "2021-10-19T10:57:44.211590+02:00",
"Owner": 1,
"Previous": null,
"SharedWithUser": null
},
{
"id": 2,
"Name": "ghost",
"FileName": "ghost.stl",
"Size": "3501284",
"File": "/upload/models/ghost_lsaRxE9.stl",
"Uploaded": "2021-10-19T10:58:13.225555+02:00",
"Owner": 1,
"Previous": null,
"SharedWithUser": 2
}
]
http://localhost:8000/api/models/MODELID/
HTTP 200 Ok
Example successful response (MODELID=1):
{
"id": 1,
"Name": "ghost",
"FileName": "ghost.stl",
"Size": "3501284",
"File": "http://localhost:8000/upload/models/ghost_92lAXd9.stl",
"Uploaded": "2021-10-19T10:57:44.211590+02:00",
"Owner": 1,
"Previous": null,
"SharedWithUser": null
}
http://localhost:8000/api/models/
HTTP 201 Created
Example successful response (Logged in UserID:1):
{
"id": 7,
"Name": "ghost",
"FileName": "ghost.stl",
"Size": "3501284",
"File": "/upload/models/ghost.stl",
"Uploaded": "2021-11-16T12:13:06.155228+01:00",
"Owner": 1,
"Previous": 4,
"SharedWithUser": 2
}
http://localhost:8000/api/gcode/
HTTP 200 OK
Example successful response (Logged in UserID:1):
[
{
"id": 8,
"Name": "boat",
"FileName": "boat.gcode",
"Size": "562833",
"File": "/upload/gcode/boat_pWiZ5oi.gcode",
"Uploaded": "2021-11-15T12:21:47.197334+01:00",
"UsedFilamentInG": 0.0,
"Owner": 1,
"UsedFilamentInMm": 0.0,
"SharedWithUser": null,
"EstimatedPrintingTime": "11:21:47.187739",
"ThreeDimensionalModel": null
},
{
"id": 9,
"Name": "boat",
"FileName": "boat.gcode",
"Size": "562833",
"File": "/upload/gcode/boat_1HhpkoU.gcode",
"Uploaded": "2021-11-15T12:26:48.249209+01:00",
"UsedFilamentInG": 123.0,
"Owner": 1,
"UsedFilamentInMm": 2132.0,
"SharedWithUser": 3,
"EstimatedPrintingTime": "12:30:00",
"ThreeDimensionalModel": 1
}
]
http://localhost:8000/api/gcode/?id=GCODEID
HTTP 200 OK
Example successful response (?id=1, Logged in UserID:1):
{
"id": 8,
"Name": "boat",
"FileName": "boat.gcode",
"Size": "562833",
"File": "/upload/gcode/boat_pWiZ5oi.gcode",
"Uploaded": "2021-11-15T12:21:47.197334+01:00",
"UsedFilamentInG": 0.0,
"Owner": 1,
"UsedFilamentInMm": 0.0,
"SharedWithUser": null,
"EstimatedPrintingTime": "11:21:47.187739",
"ThreeDimensionalModel": null
}
http://localhost:8000/api/gcode/?name=GCODENAME
HTTP 200 OK
Example successful response (?name=boat, Logged in UserID:1):
[
{
"id": 8,
"Name": "boat",
"FileName": "boat.gcode",
"Size": "562833",
"File": "/upload/gcode/boat_pWiZ5oi.gcode",
"Uploaded": "2021-11-15T12:21:47.197334+01:00",
"UsedFilamentInG": 0.0,
"Owner": 1,
"UsedFilamentInMm": 0.0,
"SharedWithUser": null,
"EstimatedPrintingTime": "11:21:47.187739",
"ThreeDimensionalModel": null
},
{
"id": 9,
"Name": "boat",
"FileName": "boat.gcode",
"Size": "562833",
"File": "/upload/gcode/boat_1HhpkoU.gcode",
"Uploaded": "2021-11-15T12:26:48.249209+01:00",
"UsedFilamentInG": 123.0,
"Owner": 1,
"UsedFilamentInMm": 2132.0,
"SharedWithUser": 3,
"EstimatedPrintingTime": "12:30:00",
"ThreeDimensionalModel": 1
}
]
http://localhost:8000/api/gcode/MODELID/
HTTP 200 OK
Example successful response (MODELID=8):
{
"id": 8,
"Name": "boat",
"FileName": "boat.gcode",
"Size": "562833",
"File": "http://localhost:8000/upload/gcode/boat_pWiZ5oi.gcode",
"Uploaded": "2021-11-15T12:21:47.197334+01:00",
"UsedFilamentInG": 0.0,
"Owner": 1,
"UsedFilamentInMm": 0.0,
"SharedWithUser": null,
"EstimatedPrintingTime": "11:21:47.187739",
"ThreeDimensionalModel": null
}
http://localhost:8000/api/gcode/
HTTP 201 Created
Example successful response (Logged in UserID:1):
{
"id": 10,
"Name": "boat",
"FileName": "boat.gcode",
"Size": "562833",
"File": "/upload/gcode/boat_H4zM6xZ.gcode",
"Uploaded": "2021-11-16T13:43:18.135579+01:00",
"UsedFilamentInG": 123.0,
"Owner": 1,
"UsedFilamentInMm": 12323.0,
"SharedWithUser": 3,
"EstimatedPrintingTime": "12:33:00",
"ThreeDimensionalModel": 3
}
http://localhost:8000/api/slicingconfig/
HTTP 200 OK
Example successful response:
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"Config": [
{
"dummy0": "1-770-736-8031 x56442",
"dummy1": 1,
"dummy2": "Leanne Graham",
"dummy3": "Bret",
"dummy4": "Sincere@april.biz"
}
],
"GCode": 10
},
{
"Config": [
{
"dummy0": "1-770-736-8031 x56442",
"dummy1": 1,
"dummy2": "Leanne Graham",
"dummy3": "Bret",
"dummy4": "Sincere@april.biz"
}
],
"GCode": 9
}
]
}
http://localhost:8000/api/slicingconfig/GCODEID/
GCODEID
HTTP 200 OK
Example successful response:
[
{
"dummy0": "1-770-736-8031 x56442",
"dummy1": 1,
"dummy2": "Leanne Graham",
"dummy3": "Bret",
"dummy4": "Sincere@april.biz"
}
]
http://localhost:8000/api/slicingconfig/
HTTP 201 Created
Example successful response (returns saved JSON Config):
[
{
"dummy0": "1-770-736-8031 x56442",
"dummy1": 1,
"dummy2": "Leanne Graham",
"dummy3": "Bret",
"dummy4": "Sincere@april.biz"
}
]
http://localhost:8000/api/printjob/
HTTP 200 OK
Example successful response (Logged in UserID:1):
[
{
"id": 1478,
"User": 1,
"Machine": 17,
"GCode": 9,
"Start": "2021-11-15T17:12:42.932473+01:00",
"End": "2021-11-15T17:17:37.710299+01:00",
"State": 0
},
{
"id": 1479,
"User": 1,
"Machine": 17,
"GCode": 9,
"Start": "2021-11-15T17:19:38.623075+01:00",
"End": "2021-11-15T17:24:33.783123+01:00",
"State": 0
}
]
http://localhost:8000/api/printjob/PRINTJOBID
HTTP 200 OK
Example successful response (PRINTJOBID:1476):
{
"id": 1476,
"User": 1,
"Machine": 17,
"GCode": 9,
"Start": "2021-11-15T16:04:04.274812+01:00",
"End": "2021-11-15T16:04:04.274820+01:00",
"State": 0
}
http://localhost:8000/api/printjob/
HTTP 201 Created
Example successful response (Logged in UserID:1):
{
"id": 1494,
"User": 1,
"Machine": 12,
"GCode": 10,
"Start": "2021-11-17T10:51:00+01:00",
"End": "2021-11-17T10:53:00+01:00",
"State": 0
}
http://localhost:8000/api/mediafile/
HTTP 200 OK
Example successful response:
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 5,
"PrintJob": 1478,
"File": "http://localhost:8000/upload/printmedia/New_York_City_High-Quality_Wallpaper_Pack.jpg",
"Owner": 1
}
]
}
http://localhost:8000/api/mediafile/MEDIAFILEID
MEDIAFILEID
HTTP 200 OK
Example successful response:
{
"id": 5,
"PrintJob": 1478,
"File": "http://localhost:8000/upload/printmedia/New_York_City_High-Quality_Wallpaper_Pack.jpg",
"Owner": 1
}
http://localhost:8000/api/mediafiles/PRINTJOBID
PRINTJOBID
HTTP 200 OK
Example successful response:
[
{
"id": 5,
"PrintJob": 1478,
"File": "/upload/printmedia/New_York_City_High-Quality_Wallpaper_Pack.jpg",
"Owner": 1
}
]
http://localhost:8000/api/mediafile/
HTTP 201 Created
Example successful response (Logged in UserID:1):
{
"id": 5,
"PrintJob": 1478,
"File": "http://localhost:8000/upload/printmedia/New_York_City_High-Quality_Wallpaper_Pack.jpg",
"Owner": 1
}
Multithreading
Improvement to the Front-End
Copyright (c) [year] [fullname]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.