ruby_astm 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_astm/lab_interface.rb +56 -22
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8929f2849304da9211d8a1bc5dda4f531d86b1efd93c0961c5911fd850b166c
|
4
|
+
data.tar.gz: 2582f498e916278c9795fbe3dd9438223e9c890eb19094c50ea8ca4b8bb38f7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f646e07f6c22da4abc05758095158743b1e19995beff2f90392369e2445141a3afe2ea620bd977cedc0ec79cd6d2158f5b760c527aed13af401d56c7b3a8c30
|
7
|
+
data.tar.gz: da45a2cfd005e8353e5df652e536499876684f9cb7eff7f1d89b5d246f982ed640ea47355b838e4c367df545062cf62a7d74049ad4e73618009e05f2e6895926
|
@@ -20,6 +20,7 @@ module LabInterface
|
|
20
20
|
mattr_accessor :usb_port
|
21
21
|
mattr_accessor :usb_baud
|
22
22
|
mattr_accessor :usb_parity
|
23
|
+
mattr_accessor :mid_frame_end_detected
|
23
24
|
|
24
25
|
|
25
26
|
|
@@ -89,6 +90,18 @@ module LabInterface
|
|
89
90
|
}
|
90
91
|
end
|
91
92
|
|
93
|
+
def is_mid_frame_end?(bytes_array)
|
94
|
+
unless bytes_array.blank?
|
95
|
+
if bytes_array.size >= 6
|
96
|
+
if bytes_array[-6..-1] == [23,65,52,13,10,2]
|
97
|
+
self.mid_frame_end_detected = true
|
98
|
+
return self.mid_frame_end_detected
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
return false
|
103
|
+
end
|
104
|
+
|
92
105
|
def receive_data(data)
|
93
106
|
|
94
107
|
|
@@ -97,13 +110,32 @@ module LabInterface
|
|
97
110
|
|
98
111
|
self.data_buffer ||= ''
|
99
112
|
|
100
|
-
puts "incoming data bytes."
|
113
|
+
#puts "incoming data bytes."
|
101
114
|
|
102
115
|
concat = ""
|
103
116
|
|
104
|
-
puts data.bytes.to_a.to_s
|
117
|
+
#puts data.bytes.to_a.to_s
|
105
118
|
|
106
|
-
|
119
|
+
|
120
|
+
## if the bytes end in 13,10,2
|
121
|
+
## that means frame ends and restarts
|
122
|
+
## ignore those three bytes
|
123
|
+
byte_arr = data.bytes.to_a
|
124
|
+
#puts "byte arr is:"
|
125
|
+
#puts byte_arr
|
126
|
+
|
127
|
+
if is_mid_frame_end?(byte_arr)
|
128
|
+
#puts "mid frame end is true---------------!!!!!!!!!!"
|
129
|
+
byte_arr = byte_arr[0..-7]
|
130
|
+
#puts "byte arr BECOMES mid frame end is true---------------!!!!!!!!!!"
|
131
|
+
#puts byte_arr.pack('c*')
|
132
|
+
elsif self.mid_frame_end_detected == true
|
133
|
+
## we ignore the frame number.
|
134
|
+
byte_arr = byte_arr[1..-1]
|
135
|
+
self.mid_frame_end_detected = false
|
136
|
+
end
|
137
|
+
|
138
|
+
byte_arr.each do |byte|
|
107
139
|
x = [byte].pack('c*').force_encoding('UTF-8')
|
108
140
|
if x == "\r"
|
109
141
|
concat+="\n"
|
@@ -129,23 +161,23 @@ module LabInterface
|
|
129
161
|
|
130
162
|
|
131
163
|
if data.bytes.to_a[-1] == 4
|
132
|
-
puts "GOT EOT --- PROCESSING BUFFER, AND CLEARING."
|
164
|
+
#puts "GOT EOT --- PROCESSING BUFFER, AND CLEARING."
|
133
165
|
process_text(self.data_buffer)
|
134
166
|
self.data_buffer = ''
|
135
167
|
if self.headers[-1].queries.blank?
|
136
|
-
puts "no queries in header so sending ack after getting EOT and processing the buffer"
|
168
|
+
#puts "no queries in header so sending ack after getting EOT and processing the buffer"
|
137
169
|
send_data(ACK)
|
138
170
|
else
|
139
|
-
puts "sending ENQ"
|
171
|
+
#puts "sending ENQ"
|
140
172
|
send_data(ENQ)
|
141
173
|
end
|
142
174
|
elsif data.bytes.to_a[0] == 6
|
143
|
-
puts "GOT ACK --- GENERATING RESPONSE"
|
175
|
+
#puts "GOT ACK --- GENERATING RESPONSE"
|
144
176
|
unless self.headers.blank?
|
145
177
|
header_responses = self.headers[-1].build_one_response({machine_name: self.headers[-1].machine_name})
|
146
178
|
## if no queries then, we have to send ack.
|
147
179
|
if header_responses.blank?
|
148
|
-
puts "sending ACK since there are no queries in the header"
|
180
|
+
#puts "sending ACK since there are no queries in the header"
|
149
181
|
send_data(ACK)
|
150
182
|
end
|
151
183
|
header_responses.each_with_index {|response,key|
|
@@ -154,30 +186,30 @@ module LabInterface
|
|
154
186
|
final_resp_arr = final_resp.bytes.to_a
|
155
187
|
final_resp_arr << 10
|
156
188
|
if (self.headers[-1].response_sent == false)
|
157
|
-
puts "sending the data as follows----------------------------------------------"
|
158
|
-
puts "response sent is:"
|
159
|
-
puts self.headers[-1].response_sent
|
160
|
-
puts final_resp_arr.pack('c*').gsub(/\r/,'\n')
|
189
|
+
#puts "sending the data as follows----------------------------------------------"
|
190
|
+
#puts "response sent is:"
|
191
|
+
#puts self.headers[-1].response_sent
|
192
|
+
#puts final_resp_arr.pack('c*').gsub(/\r/,'\n')
|
161
193
|
send_data(final_resp_arr.pack('c*'))
|
162
194
|
self.headers[-1].response_sent = true if (key == (header_responses.size - 1))
|
163
195
|
else
|
164
|
-
puts "sending EOT"
|
196
|
+
#puts "sending EOT"
|
165
197
|
send_data(EOT)
|
166
198
|
end
|
167
199
|
}
|
168
200
|
else
|
169
|
-
puts "NO HEADERS PRESENT --- "
|
201
|
+
#puts "NO HEADERS PRESENT --- "
|
170
202
|
end
|
171
203
|
elsif data.bytes.to_a[0] == 255
|
172
|
-
puts " ----------- got 255 data -----------, not sending anything back. "
|
204
|
+
#puts " ----------- got 255 data -----------, not sending anything back. "
|
173
205
|
else
|
174
|
-
unless self.data_buffer.blank?
|
175
|
-
|
176
|
-
end
|
206
|
+
#unless self.data_buffer.blank?
|
207
|
+
# puts self.data_buffer.gsub(/\r/,'\n').to_s
|
208
|
+
#end
|
177
209
|
## send the header
|
178
210
|
#puts "--------- SENT ACK -----------"
|
179
211
|
if self.data_buffer =~ /MSH\|/
|
180
|
-
puts " -------------- HEADERS ARE BLANK WITH HL7, sending ack. ------------ "
|
212
|
+
#puts " -------------- HEADERS ARE BLANK WITH HL7, sending ack. ------------ "
|
181
213
|
process_text(self.data_buffer)
|
182
214
|
self.data_buffer = ''
|
183
215
|
if self.headers.size > 0
|
@@ -185,7 +217,7 @@ module LabInterface
|
|
185
217
|
send_data(self.headers[-1].generate_ack_success_response)
|
186
218
|
end
|
187
219
|
else
|
188
|
-
puts " -------------- HEADERS ARE BLANK NOT HL7, sending ack. ------------ "
|
220
|
+
#puts " -------------- HEADERS ARE BLANK NOT HL7, sending ack. ------------ "
|
189
221
|
send_data(ACK)
|
190
222
|
end
|
191
223
|
end
|
@@ -199,12 +231,14 @@ module LabInterface
|
|
199
231
|
end
|
200
232
|
|
201
233
|
def send_enq
|
202
|
-
puts "enq as bytes is:"
|
203
|
-
puts ENQ.unpack('c*')
|
234
|
+
#puts "enq as bytes is:"
|
235
|
+
#puts ENQ.unpack('c*')
|
204
236
|
send_data(ENQ)
|
205
237
|
end
|
206
238
|
|
207
239
|
def process_text(text)
|
240
|
+
puts "text is:"
|
241
|
+
puts text
|
208
242
|
text.split("\n").each do |l|
|
209
243
|
line = Line.new({:text => l})
|
210
244
|
process_type(line)
|