Class: SiemensAbgElectrolyteServer

Inherits:
Object
  • Object
show all
Includes:
SiemensAbgElectrolyteModule
Defined in:
lib/ruby_astm/custom/siemens_abg_electrolyte_server.rb

Constant Summary

Constants included from SiemensAbgElectrolyteModule

SiemensAbgElectrolyteModule::ELECTROLYTE_START, SiemensAbgElectrolyteModule::SIEMENS_ELECTROLYTE_END, SiemensAbgElectrolyteModule::SIEMENS_ELEC_ABG_RESULTS_HASH

Constants included from LabInterface

LabInterface::ACK, LabInterface::CR, LabInterface::ENQ, LabInterface::EOT, LabInterface::ETX, LabInterface::LF, LabInterface::STX

Instance Attribute Summary

Attributes included from SiemensAbgElectrolyteModule

#current_text_segment

Attributes included from LabInterface

#data_buffer, #data_bytes, #ethernet_connections, #ethernet_server, #headers, #mapping, #mid_frame_end_detected, #respond_to_queries, #serial_baud, #serial_connections, #serial_parity, #serial_port, #server_ip, #server_port, #test_data_bytes, #usb_baud, #usb_parity, #usb_port

Instance Method Summary collapse

Methods included from SiemensAbgElectrolyteModule

#add_result?, #clear, #get_cl, #get_k, #get_na, #get_patient_id, #get_pco2, #get_ph, #get_po2, included, #process_electrolytes, #process_text_file, #receive_data

Methods included from LabInterface

#checksum, #generate_response, included, #is_mid_frame_end?, #pre_process_bytes, #process_byte_file, #process_text, #process_text_file, #process_type, #receive_data, #root, #send_enq, #terminator, #unbind, #write_bytes_to_file

Constructor Details

#initialize(ethernet_connections, serial_connections, mpg = nil, respond_to_queries = nil) ⇒ SiemensAbgElectrolyteServer

DEFAULT SERIAL PORT : /dev/ttyS0 DEFAULT USB PORT : /dev/ttyUSB0 @param ethernet_connections : each element is expected to be a hash, with keys for :server_ip, :server_port. @param serial_connections : each element is expected to be a hash with port_address, baud_rate, and parity def initialize(server_ip=nil,server_port=nil,mpg=nil,respond_to_queries=false,serial_port=‘/dev/ttyS0’,usb_port=‘/dev/ttyUSB0’,serial_baud=9600,serial_parity=8,usb_baud=19200,usb_parity=8)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ruby_astm/custom/siemens_abg_electrolyte_server.rb', line 10

def initialize(ethernet_connections,serial_connections,mpg=nil,respond_to_queries=nil)
	$redis = Redis.new
	self.class.log("Initializing AstmServer")
	self.ethernet_connections = ethernet_connections
	self.serial_connections = serial_connections
	self.server_ip = server_ip || "127.0.0.1"
	self.server_port = server_port || 3000
	self.respond_to_queries = respond_to_queries
	self.serial_port = serial_port
	self.serial_baud = serial_baud
	self.serial_parity = serial_parity
	self.usb_port = usb_port
	self.usb_baud = usb_baud
	self.usb_parity = usb_parity
	$mappings = JSON.parse(IO.read(mpg || self.class.default_mappings))
end

Instance Method Details

#start_serverObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ruby_astm/custom/siemens_abg_electrolyte_server.rb', line 27

def start_server
	EventMachine.run {
		self.ethernet_connections.each do |econn|
			raise "please provide a valid ethernet configuration with ip address" unless econn[:server_ip]
			raise "please provide a valid ethernet configuration with port" unless econn[:server_port]
			EventMachine::start_server econn[:server_ip], econn[:server_port], SiemensAbgElectrolyteModule
			self.class.log("Running ETHERNET  with configuration #{econn}")
		end
		self.serial_connections.each do |sconn|
			raise "please provide a valid serial configuration with port address" unless sconn[:port_address]
			raise "please provide a valid serial configuration with baud rate" unless sconn[:baud_rate]
			raise "please provide a valid serial configuration with parity" unless sconn[:parity]
			EventMachine.open_serial(sconn[:port_address], sconn[:baud_rate], sconn[:parity],SiemensAbgElectrolyteModule)
			puts "RUNNING SERIAL port with configuration : #{sconn}"
		end

	}
end