Doodle3D/Doodle3D-cura-plugin

Handle connection issues while sending prints

peteruithoven opened this issue · 0 comments

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