Skip to main content

Module listing

Module listing 

Source
Expand description

Every print this system holds, and the one the printer is running now.

A print is otherwise known here only once a provider reports on it, and an identifier nothing lists is one nobody can act with. So reading the listing also adopts the job the printer reports: when that job is in one of ACTIVE_STATES and no open print records it, one is opened for it, and the listing names it active. An alert about the same job later attaches its provider’s identifier to that print rather than opening a second, which is Supervisor::handle_event’s own rule.

§Which open print a running job is

The printer names a job by its file and by nothing else, so a file name alone cannot tell one job from a later one of the same file. What can is how long each has been printing. OctoPrint reports a job’s running time as the time since it started less every pause it has resumed from: a pause counts while it lasts, and comes back out at the resume. So the running time a read finds a job printing at is the time it has spent printing, and that only grows; the one a read finds it paused at is at least that.

A print records the longest running time any read found its job printing at (PrintRecord::job_print_time_s) and, from the latest read that found its job printing or paused, when that read put the job’s start (PrintRecord::job_started_at — the read’s instant less the running time it reported, which a resume moves later, so a read putting it further than the tolerance from the one recorded resets it). An open print of the running job’s file is that job unless the job reports a running time more than JOB_IDENTITY_TOLERANCE_S short of the longest the print recorded: a job cannot have printed for less than it had already printed, so that one is a later job, and the print is closed with REPLACED_REASON before the running job is given a print of its own. The tolerance is printing time, and a pause, observed or not, shortens no job’s printing time, so no pause splits a print.

Where either side reports no running time — a print recorded before these were, one an alert or a start opened before any read saw its job, one only ever seen paused, or a job whose printer reports none — the file name is the whole of what is known, and it decides as it did before.

What this cannot tell apart, and so keeps as one print: a later job that, when it is first read, has printed for as long as the earlier job was last seen printing, less the tolerance, or longer. An earlier job paused between two reads and resumed reports exactly that, because the pause is taken back out of its running time at the resume; nothing a read returns tells the two apart.

§A read that finds the job over closes its print

A print ends when the printer is seen not to be running it, whoever was looking. A supervision turn that reads a terminal state closes its print, and so does every read this module makes and the status and context reads make: a job no longer in one of ACTIVE_STATES closes the open prints it could be, through the same close-out a turn takes. A printer that cannot be read closes nothing, and neither does a state this vocabulary does not name, because neither is a finding that the job is over.

A close-out from a read never waits on a supervision turn: the read may be the agent’s own, made from inside that turn. So a print whose turn is running is left for that turn, and the next read after it, to close, and a turn that finds its print ended by the time it holds the print runs nothing.

§What it asks of the printer

One read of the job, which is a read rather than an action: nothing here reaches an action method of the printer port, so adopting a job commands nothing at the machine. Closing a print is the one exception, and it is the close-out’s rather than this module’s: the close-out expires the print’s active interventions, and an expiry may put an adjusted value back through the same decided path any action takes.

§What an adopted print records

The store records a print’s state when it opens it and when it ends it, and at no point between. An adopted print is opened exactly as an alert opens one, so it records printing whether or not the machine is paused at that moment: what the machine is doing now is the status read’s answer, and never the record’s.

Structs§

ObservedJob
The printer’s job, as one read observed it.
PrintListing
Every print, and the one the printer is running now.
Settled
What one observation of the printer’s job settled among the open prints.

Constants§

ACTIVE_STATES
The job states a printer’s job is adoptable in: a job it is running, and a job it has paused part-way through.
JOB_IDENTITY_TOLERANCE_S
How far, in seconds of printing, a job’s reported running time may fall short of the longest a print recorded for its job and still be that job — and how much later than a print’s recorded start an alert may put its job’s start and still be that print’s.
REPLACED_REASON
Why a print is ended when a later job of its file is found running.

Functions§

is_over
Whether a job in this state is over: a state the printer’s vocabulary names, and not one of ACTIVE_STATES.
may_be_same_job
Whether a running job of a print’s file may be the job that print records.
may_have_started_it
Whether a job a provider says began at started_at may be the job a print of its file records.