Class: CancelJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/cancel_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(model_name, id, printer_id) ⇒ Object

Legenda errori: TIMEOUT: indirizzo della stampante non raggiungibile durante la stampa UNREACHABLE: indirizzo della stampante non raggiungibile durante il controllo dello stato della stampante HEAD UP: coperchio aperto RIBBON OUT: ribbon terminato PAPER OUT: carta terminata PAUSE: stampante in pausa OK: nessun errore



15
16
17
18
19
# File 'app/jobs/cancel_job.rb', line 15

def perform model_name, id, printer_id
  # Do something later
  printer = Printer.find(printer_id.to_i)
  send_to_printer printer.ip, "~ja"
end

#send_to_printer(printer, text) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/jobs/cancel_job.rb', line 21

def send_to_printer printer, text
  begin
    s = TCPSocket.new(printer, 9100)
    # Rails.logger.debug "TEMPERATURE: #{text}"
    s.puts(text)
    s.close
    @printed += 1
    return true
  rescue
    return false
  end
end