Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle connection issues while sending prints #25

Open
peteruithoven opened this issue Aug 19, 2016 · 0 comments
Open

Handle connection issues while sending prints #25

peteruithoven opened this issue Aug 19, 2016 · 0 comments

Comments

@peteruithoven
Copy link
Member

In the client that's used on the WiFi-Box we have a lot of checks to handle connection issues, this library should also perform these.
Relevant code: From: https://github.com/Doodle3D/doodle3d-client/blob/master/js/Printer.js

The logic in pseudo code:

Start checking printer status

Send print print
  if print to large:
    overrule state to idle
    start checking status
  enable warning about leaving when still sending.
  send first part (supply seq_number & seq_total)
    when receiving response
      if response.status success:
        if print sending completed
          remove leave warning
        else 
          if state is printing / buffering:
            send next part
          else if state is disconnected:
            retry sending same part after a delay
      else if response.status fail:
        if reason buffer full:
          wait for buffer space...
        else if reason seq_num_mismatch and sequence number is current sequence number:
          // we probably missed a response and the box is one chunk ahead
          send next part
        else:
          if status isn't stopping:
            display error
      start checking status
    when sending times out:
      retry sending same part after a delay

Wait for buffer space
  if WiFi-Box's buffer is above a certain ratio:
    call this function after a delay
  else
    if state is printing / buffering
      send same part

On stop
  clear all delays / timeouts
  remove leave warning
  on response
    start checking status
  on timeout
    retry stop after delay
    start checking status

Check printer status (/info/status)
  on response:
    if response.status succes
      state = data.state
    else
      status = unknown
    try checking status again after delay
  on timeout
    status = disconnected
    try checking status again after longer delay

When state is overridden
  store state
  stop checking status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant