Class: Gscomp::Prices

Inherits:
Object
  • Object
show all
Defined in:
lib/gscomp.rb

Instance Method Summary collapse

Instance Method Details

#mainObject



295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/gscomp.rb', line 295

def main
  # uu = Thread.new do
    # Запускаем цикл обработки событий
    loop do
      process_packet()
      sleep @power
   end
  #end


  GLib::Timeout.add(1000) { on_timer }

  Gtk.main
end

#on_timerObject



310
311
312
313
# File 'lib/gscomp.rb', line 310

def on_timer
  @status.tooltip = "Global System\nОбработано: #{@processed.to_s} единц"
  true
end

#process_packetObject



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/gscomp.rb', line 268

def process_packet
  sleep 1 while not (client_id = get_client_id())
  puts client_id

  attempt = 10
  sleep 1 while not (job = get_job(client_id) and attempt -= 1)
  false unless job
  # puts job

  records = process_job(job)
  puts records

  result = {
     :client_id => client_id,
     :records_count => records.length,
     :records => records
  }

  send_result = send_job(result) 
  case send_result
    when Net::HTTPSuccess, Net::HTTPRedirection
      p "Ответ - " + send_result.body
    else
      # p result.error
  end
end