Class: Gscomp::Taras

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

Instance Method Summary collapse

Instance Method Details

#mainObject



286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/gscomp.rb', line 286

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



300
301
302
303
# File 'lib/gscomp.rb', line 300

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

#process_packetObject



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/gscomp.rb', line 259

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 'Good'
    else
      # p result.error
  end
end