Architecture · Chapter 5
The data of a print
A deck sends a print to up to three places: the live tile of its project, the share page, and the project record at the end.
5.1 An FDM print on printdeck
- Upload. Cura sends the G-code through the OctoPrint API of the deck. The Printdeck plugin can also pick the project of the next prints.
- Live tile. For a print in a project, the deck looks at the state each 15 seconds. It sends the progress each minute, and at once at the start, at a pause and at the end. The API keeps one record for each printer:
x/<project>/live/<slot>.json. The project page hides a tile with no update for 5 minutes. - Share page. After a tap on Make the link, the deck uploads
status.jsonevery 5 seconds with the newest camera frames. It also uploads each new time lapse frame, the picture of the model (at most each 15 seconds), andplan.jsononce. The page pollsstatus.jsonandready.json. The status files have a cache time of 2 to 5 seconds. - End of the share. At the end of the print, the deck tells the API. The share stays for 24 hours.
- Project record. The deck waits for the time lapse video, for at most 10 minutes. Then it sends the print record, the picture of the model, the plan and the time lapse frames to
x/<project>/prints/<print>/. The print gets the next number in the project. The photos of the share go to the print. - Move. When the share ends, the sweep deletes its files. Its page then sends visitors to the print page
/projects/<slug>/<n>, or to the public page when the project has one.
5.2 A resin print on resindeck
The flow to the cloud is the same. The source of the data is different. The ChiTu board reports the bytes of the file that it read. So the deck reads its own copy of the sliced file for the layers and the pictures. An approved resin plate of a build also goes into these copies, and the deck then sends it to the board.
- Numbers. The header of the file has the exposure, the bottom layers, the lift and the speeds. The share page lists each number, and it plays the cycle of one layer in step with the printer: light, lift, return and rest.
- Live tile. The picture on the tile is the layer that the printer cures now. The deck uploads a new picture when the layer changes.
- 3D view. The deck makes
part.binonce for a share, and the share page draws the part in 3D. - Restart of the deck. A resin print continues through a restart of resindeck, because the board prints the file. The share continues too: the deck saves the share to
share-resume.jsonin its state folder every 30 seconds, and loads it after the start when it has no share. - One tile. When the live tile of a deck names its share, an older open share of the same deck shows no tile on the project page. An open share with no new status for 30 minutes also shows no tile. A deck that lost the share at a restart never ends it.
The cells of part.bin
PDC1: the cell size in mm, the slice height, W, H and D, then for each slice the runs of a value and a count.A cell is 4 × 4 pixels of the screen, and a stack of layers of about the same height. Its value is the share of its pixels in all its layers that are lit, from 0 to 255. The page puts the surface where the share crosses one half. So an edge sits at its true place inside the cell, and the view is as fine as the slices. The file is the mirror of the screen for a printer with projector 1, as the slicer shows the part. A full plate gives about 4 MB. When the upload of part.bin fails, the share continues, and the deck tries again after 10 minutes. part.bin stays with the share only. The project record has no 3D cells.
5.3 The print page: names, notes and delivery
People change some fields of a print on the pages. These fields stay when the deck sends the print again (Title and pageFields of PrintRecord). Each change uses PATCH projects/<id>/prints/<print>. A deck gets 401 on this route.
- Rename. The owner can give a print a title of up to 120 characters. The pages show the title in place of the name from the deck, and the name from the deck under it. A title that is the same as the name clears the title.
- Notes. The owner and the members write notes on a print, and on the project with
PATCH projects/<id>/notes. Notes have at most 4000 characters. The record keeps the name of the last writer and the time. - Test print. The owner marks a print as a test print: a print to try a setting or a fit, and not to give. The API records the time. A test print is not in the card Ready for pickup.
- Ready for pickup. The owner marks a print Ready for pickup on its page, before Delivered, and the API records the time.
- Delivered. The owner marks a print Delivered, and the API records the time. The owner can also clear the mark.
- In use. The owner marks a print In use when the print is in use: after a delivery, or with no delivery for a print that the owner keeps. The API records the time, and a second tap clears it. A print in use is not in the card Ready for pickup.
- Rejected. The owner marks a print Rejected when the print is not used: a failed print, or a good print that is wrong for some reason, such as a part that does not fit. The note of why has up to 500 characters. The API records the time. A second tap clears the mark and the note. A rejected print is not in the card Ready for pickup. The iPhone app can also set the mark. The API fields are
discardedanddiscard_note, from the earlier name of the mark, Discard. - Source. The owner sets a link to the source of the model, for example a file of a commit on GitHub. The link must be an
httporhttpsaddress with a host, of at most 500 characters. - Ready from a share. When the owner of a share marks it Ready, the API copies the time and the note to the print of the share in its project. A clear of Ready also clears the mark on the print. The API also copies the mark when a share joins a project later.
The print page shows "Rejected" with the day and the note, else "In use since" with the day, else "Delivered" with the day. Before the delivery, it shows the Ready mark when the print has one. A tile has the badge Rejected, Test, In use, Delivered with the date, or Ready to pick up. A member can change the notes only. The other fields get 401 for a member.
Photos from a phone. The photos of a project and of a print have Take photos on a phone: the camera opens, and after each photo goes up, Take another photo opens it again. A photo that does not go up does not stop the others.
Move a photo. A photo can move to another print of the project, or to no print, with PUT projects/<id>/photos/<photo>. The owner moves any photo, and a member moves only their own.
5.4 The photo viewer
assets/lightbox.js shows a photo at full size over the page. The app pages, the share page and the public pages use it. A link with data-photo in a photo grid opens the viewer.
- Previous and Next go through the photos of the same grid. The arrow keys do the same, and Escape closes the viewer.
- Each photo has an address: the address of the page with
#photo=<id>. Copy link copies it. An open of that address shows the page with the photo over it. - A tap on a photo adds its address to the history of the browser, so Back closes the viewer. Full size opens the file in a new tab.
The fragment does not go to the server. A person with the address of a photo also needs access to the page: a passkey of the project, the share link, or a public page.
5.5 The project page
The page /projects/<slug> is the home of a project. Its head shows the name, the start of the project, the circles of its people, and links to the repository and the public page. Tabs lead to the other parts. Each tab has its own address. A tap changes the tab with no new load of the project.
| Tab | Address | What it shows |
|---|---|---|
| Overview | /projects/<slug> | What happens now, the numbers, the chart, the newest prints, the feed, and a column of cards (Figure 20). |
| Prints | /projects/<slug>/prints | All the prints, with a chip for each printer, and chips for the prints ready for pickup, the delivered prints (the newest delivery first), the test prints and the rejected prints. |
| Photos | /projects/<slug>/photos | All the photos, and Add photos. Each photo has Move to, which puts it on another print or on no print. |
| Builds | /projects/<slug>/plans | The plans of the pull requests and of the tags (releases), and their builds. The Overview shows the newest plan of main. The tab shows only for a project with a repository. |
| Settings | /projects/<slug>/settings | The repository, the printers, the friends with their GitHub usernames, the public address, and Delete. |
- The line of what happens now names the print that prints, with its share and the time of its end, or the time of the last print. It also counts the plates that wait for the owner and the open pull requests that change parts. Each item is a link.
- The numbers are the prints, the print time, the filament and the share of the prints that finished.
- The chart shows the hours of print of each of the last 7 days: the finished prints, with the stopped prints over them. Each bar has the short name of its day, and the last bar is Today. A bar under it shows the grams of each material, in the color of the filament.
- The feed shows the 12 newest events, with a heading for each day: the end of a print, Ready, Delivered, In use and Rejected, the photos of one person on one day, the plans, the slices, the approvals, the rejections and the notes.
- The GitHub card shows the newest plan of main and each open pull request that changes parts, with its author and the state of its three steps: Plan, Slice and Approve. A pull request that changes no part is only on the Builds tab, and the feed has no line for its plans.
- The printers card shows each printer of the project: printing with its share, paused, or idle with the time of its last print. A deck from before the printers sends its live print with no printer ID. Its row then has the name of the printer from the deck. A printing row shows the percent and the time of the end. A resin printer also shows its layer, for example layer 120 of 800, and a picture of the layer that cures now.
- The card Ready for pickup shows each print that waits, with small pictures of its photos (else of its model), the time of the mark, and Delivered for the owner. It links to the delivered prints.
- The card In the queue shows the files of the project in the queues of the printers: the printer, the place and the estimate of the start (section 7.4). The owner can take a file out with Remove (
DELETE projects/<id>/queue/<printer>/<item>), and the deck does it within a minute. The line of what happens now gives the start of the next file. - The tiles of the prints with photos have small pictures of up to three photos in a corner.
- The People card shows the owner, the members with their GitHub usernames, and the invites that wait. The owner taps Edit to set a GitHub username, remove a member, cancel an invite, or make an invite.
The page reads the project again each minute, or each 30 seconds while a print prints. The first load is one request, GET /names/<slug>?view=1. The reply has the project and its view. pwf.js starts this request before the WebAssembly loads. The API reads the records of the project at the same time, 64 at a time. It draws the line of what happens now and the printers at each read. It draws the other cards again only when the prints, the photos, the plans or the notes change, so the pictures do not load again. The pages have the cache rule no-cache: after a deploy, the next load gets the new page.
The head of the project. The name, the people, the links and the tabs are over each page of a project: the overview, a print, a printer, the plans, a plan and a build. The tab of the page is marked.
5.6 The 3D view of a print
The deck uploads the G-code of an FDM print with gzip, as print.gcode.gz: once for the share (up to 15 MB after gzip), and with the print at its end. The share page and the print page draw it with the G-code viewer of the build page (viewer3d.js, showGcode) in a compact mode with no controls. A print with no G-code shows the picture of the model from the deck. The view of a TAZ print draws the real bed of the TAZ under the part, from the CAD of LulzBot. Another printer has the plain bed with the grid.
- The layers. The layers that printed have the colors of Cura. The later layers are a faint ghost. Each mesh of moves has a twin with the moves in the reverse order, so a step of the print only changes two counts.
- The nozzle. A hot end (the tip, the hex and the heater block) at the move that prints now, drawn over the part with an orange edge.
- The sync with the printer. The status of the share has
pos: the byte of the file that Klipper reads. The viewer keeps the byte of each move, puts the nozzle at the move of that byte, and goes on at the speeds of the G-code until the next status. It starts 1.5 s behind, because Klipper reads ahead of the nozzle. With no byte, the viewer uses the time of the layer. - The camera view. The status can also have
view: a 3 × 4 matrix from the G-code coordinates to the frames of the time lapse. The deck makes it from the calibration of the camera with the bed at the park, the turn of the frames, and the crop to the part (composeView). The view then has the shape of the frames, and Turn freely gives the view that turns. The deck sends the view only with a calibration of the towers (BedY): a calibration of the nozzle on a printer with a bed that moves in Y has no direction of Y. The page also ignores a matrix that makes the edge of the part in Y shorter than a tenth of its other edges.
On a wide screen the numbers of a share are across the full width, and the model and the time lapse are side by side under them, with the same height. On a phone the numbers come first.
The picture of a record. A print record keeps the size and the modification time of its file at the end of the print. A slicer can send another file under the same name later. The deck draws no picture of a record when its file changed.