#home the collection stage
Log.record "Homing Collection Stage (assuming CS is not pressurized!)"

ss = Thread (:readySampler) do
  Intake.close
  delay 1  #wordaround
  SV.to :out
  delay 1
  Exhaust.open
  SS.home.empty
  Exhaust.close
end

cs = Thread (:readyCollecter) do
  CS.home
  Reagents.to :air
  if CS.status.home #if initially below the home flag, first pull air
    index = CSV.angleIndex CSV.rawAngle
    offset = index.round - index
    CSV.advance (offset + (offset >= 0 ? -.5 : .5))  #nearest closed position
    CS.to :home
    carefully = CS.config.dup.with :acceleration=>4, :maxCurrent=>20
    begin
      CS.to 0, carefully
    rescue Slide::Error  #need to create an overcurrent & position err types
      Log.record "Pushing unknown residue in #{CS.name} to waste"
    end
  end
  CSV.to :waste
  CS.empty
  CSV.advance -.5  #close connection to waste
end

ss.join
cs.join
