Class: LIS::InterfaceServer

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, http_endpoint) ⇒ InterfaceServer

Returns a new instance of InterfaceServer



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/lis/interface_server.rb', line 13

def initialize(server, http_endpoint)
  @server = server

  protocol = LIS::Transfer::ApplicationProtocol.new(LIS::Transfer::Logging.new(LIS::Transfer::ASTM::E1394.new(server)))
  interface = HTTPInterface.new(http_endpoint)

  protocol.on_request do |device_name, barcode|
    warn "loading requests" if $VERBOSE
    interface.load_requests(device_name, barcode)
  end
  protocol.on_result do |device_name, patient, order, result|
    interface.send_result(device_name, order, result)
  end
  protocol.on_request_sent do |device_name, data|
    interface.set_request_status(device_name, data)
  end
end

Class Method Details

.create(*args) ⇒ Object



8
9
10
# File 'lib/lis/interface_server.rb', line 8

def self.create(*args)
  new(*args)
end

.listen(port, http_endpoint) ⇒ Object



3
4
5
6
# File 'lib/lis/interface_server.rb', line 3

def self.listen(port, http_endpoint)
  interface = PacketIO::IOListener.new(port)
  new(interface, http_endpoint)
end

Instance Method Details

#run!Object



31
32
33
34
# File 'lib/lis/interface_server.rb', line 31

def run!
  warn "listener started" if $VERBOSE
  @server.run!
end