farmbot-serial 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,31 @@
1
+ ## SERIAL PORT SIMULATION
2
+ ## **********************
3
+
4
+ # Used for unit tests
5
+
6
+ module Fb
7
+ class SerialPortSim
8
+ attr_accessor :rts, :read_timeout, :test_serial_read, :test_serial_write
9
+
10
+ def initialize(comm_port, parameters)
11
+ @test_serial_read = ""
12
+ @test_serial_write = ""
13
+ end
14
+
15
+ def write(text)
16
+ @test_serial_write = text
17
+ end
18
+
19
+ def read(characters)
20
+ i = nil
21
+ @test_serial_read = nil if @test_serial_read == ""
22
+
23
+ if @test_serial_read != nil
24
+ i = @test_serial_read[0]
25
+ @test_serial_read = @test_serial_read[1..-1]
26
+ end
27
+ i
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,52 @@
1
+ module Fb
2
+ class Status
3
+ attr_accessor :command_refresh, :device_version, :emergency_stop,
4
+ :info_command_last, :info_command_next, :info_current_x,
5
+ :info_current_x_steps, :info_current_y, :info_current_y_steps,
6
+ :info_current_z, :info_current_z_steps, :info_end_stop_x_a,
7
+ :info_end_stop_x_b, :info_end_stop_y_a, :info_end_stop_y_b,
8
+ :info_end_stop_z_a, :info_end_stop_z_b, :info_movement,
9
+ :info_nr_of_commands, :info_status, :info_target_x, :info_target_y,
10
+ :info_target_z, :info_pin_8, :info_pin_9, :info_pin_10, :info_pin_13
11
+
12
+ def initialize
13
+
14
+ @emergency_stop = false;
15
+
16
+ @info_command_next = nil
17
+ @info_command_last = nil
18
+ @info_nr_of_commands = 0
19
+ @info_status = 'initializing'
20
+ @info_movement = 'idle'
21
+
22
+ @info_current_x_steps = 0
23
+ @info_current_y_steps = 0
24
+ @info_current_z_steps = 0
25
+
26
+ @info_current_x = 0
27
+ @info_current_y = 0
28
+ @info_current_z = 0
29
+
30
+ @info_target_x = 0
31
+ @info_target_y = 0
32
+ @info_target_z = 0
33
+
34
+ @info_end_stop_x_a = 0
35
+ @info_end_stop_x_b = 0
36
+ @info_end_stop_y_a = 0
37
+ @info_end_stop_y_b = 0
38
+ @info_end_stop_z_a = 0
39
+ @info_end_stop_z_b = 0
40
+
41
+ @info_pin_8 = 0
42
+ @info_pin_9 = 0
43
+ @info_pin_10 = 0
44
+ @info_pin_13 = 0
45
+
46
+ @command_refresh = 0
47
+ @device_version = 'UNKNOWN'
48
+
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,672 @@
1
+ require 'spec_helper'
2
+ describe Fb::HardwareInterfaceArduino do
3
+
4
+ before do
5
+ Fb::HardwareInterface.current.status = Fb::Status.new
6
+
7
+ @ramps = Fb::HardwareInterfaceArduino.new(true)
8
+
9
+ @ramps_param = Fb::HardwareInterfaceParam.new
10
+ @ramps.ramps_param = @ramps_param
11
+ end
12
+
13
+ it "read status" do
14
+ @ramps.connect_board
15
+ expect(1).to eq(1)
16
+ end
17
+
18
+ it "execute_command" do
19
+ command = "TEST"
20
+
21
+ @ramps.serial_port.test_serial_read = "R01\nR02\n"
22
+ @ramps.execute_command(command, false, false)
23
+
24
+ expect(@ramps.serial_port.test_serial_write).to eq("#{command}\n")
25
+
26
+ end
27
+
28
+ it "execute_command with causing an error" do
29
+
30
+ Fb::HardwareInterface.current.status = nil
31
+
32
+ @ramps.serial_port.rts = 0
33
+ @ramps.execute_command(nil,nil,nil)
34
+
35
+ Fb::HardwareInterface.current.status = Fb::Status.new
36
+
37
+ expect { @ramps }.to_not raise_error
38
+
39
+ end
40
+
41
+ it "create write status" do
42
+
43
+ text = rand(9999999).to_s
44
+ log = rand(9999999).to_s
45
+ onscreen = true
46
+
47
+ write_status = @ramps.create_write_status(text, log, onscreen)
48
+
49
+ expect(write_status.text ).to eq(text )
50
+ expect(write_status.log ).to eq(log )
51
+ expect(write_status.onscreen ).to eq(onscreen )
52
+ end
53
+
54
+ it "handle execution exception" do
55
+ e = Exception.new
56
+ @ramps.handle_execution_exception(e)
57
+ expect(1).to eq(1)
58
+ end
59
+
60
+ it "log result of execution" do
61
+
62
+ text = rand(9999999).to_s
63
+ log = rand(9999999).to_s
64
+ onscreen = true
65
+
66
+ write_status = @ramps.create_write_status(text, log, onscreen)
67
+
68
+ @ramps.log_result_of_execution(write_status)
69
+
70
+ expect(1).to eq(1)
71
+ end
72
+
73
+ it "process feedback" do
74
+
75
+ text = rand(9999999).to_s
76
+ log = rand(9999999).to_s
77
+ onscreen = false
78
+
79
+ @ramps.serial_port.test_serial_read = "R02\n"
80
+
81
+ write_status = @ramps.create_write_status(text, log, onscreen)
82
+
83
+ @ramps.process_feedback(write_status)
84
+ @ramps.process_feedback(write_status)
85
+ @ramps.process_feedback(write_status)
86
+ @ramps.process_feedback(write_status)
87
+ @ramps.process_feedback(write_status)
88
+
89
+ expect(write_status.done).to eq(1)
90
+
91
+ end
92
+
93
+ it "and and process characters" do
94
+
95
+ text = rand(9999999).to_s
96
+ log = rand(9999999).to_s
97
+ onscreen = false
98
+
99
+ write_status = @ramps.create_write_status(text, log, onscreen)
100
+
101
+ @ramps.add_and_process_characters(write_status, 'R')
102
+ @ramps.add_and_process_characters(write_status, '0')
103
+ @ramps.add_and_process_characters(write_status, '2')
104
+ @ramps.add_and_process_characters(write_status, "\n")
105
+
106
+ expect(write_status.done).to eq(1)
107
+
108
+ end
109
+
110
+ it "process codes and parameters R01" do
111
+
112
+ text = rand(9999999).to_s
113
+ log = rand(9999999).to_s
114
+ onscreen = false
115
+
116
+ write_status = @ramps.create_write_status(text, log, onscreen)
117
+ write_status.code = "R01"
118
+ timeout = write_status.timeout
119
+
120
+ @ramps.process_code_and_params(write_status)
121
+
122
+ expect(write_status.timeout).to be > timeout
123
+
124
+ end
125
+
126
+ it "process codes and parameters R02" do
127
+
128
+ text = rand(9999999).to_s
129
+ log = rand(9999999).to_s
130
+ onscreen = false
131
+
132
+ write_status = @ramps.create_write_status(text, log, onscreen)
133
+ write_status.code = "R02"
134
+
135
+ @ramps.process_code_and_params(write_status)
136
+
137
+ expect(write_status.done).to eq(1)
138
+
139
+ end
140
+
141
+ it "process codes and parameters R03" do
142
+
143
+ text = rand(9999999).to_s
144
+ log = rand(9999999).to_s
145
+ onscreen = false
146
+
147
+ write_status = @ramps.create_write_status(text, log, onscreen)
148
+ write_status.code = "R03"
149
+
150
+ @ramps.process_code_and_params(write_status)
151
+
152
+ expect(write_status.done).to eq(1)
153
+ end
154
+
155
+ it "process codes and parameters R04" do
156
+
157
+ text = rand(9999999).to_s
158
+ log = rand(9999999).to_s
159
+ onscreen = false
160
+
161
+ write_status = @ramps.create_write_status(text, log, onscreen)
162
+ write_status.code = "R04"
163
+ timeout = write_status.timeout
164
+ time = Time.now
165
+
166
+ @ramps.process_code_and_params(write_status)
167
+
168
+ expect(write_status.timeout).to be > timeout
169
+ expect(write_status.start).to be > time
170
+
171
+ end
172
+
173
+ it "process codes and parameters other" do
174
+
175
+ text = rand(9999999).to_s
176
+ log = rand(9999999).to_s
177
+ onscreen = false
178
+ par = rand(9999999).to_s
179
+
180
+ write_status = @ramps.create_write_status(text, log, onscreen)
181
+ write_status.code = "R83"
182
+ write_status.params = par
183
+
184
+ @ramps.process_code_and_params(write_status)
185
+
186
+ expect(Fb::HardwareInterface.current.status.device_version).to eq(write_status.params)
187
+
188
+ end
189
+
190
+
191
+ it "prepare serial port" do
192
+ text = rand(9999999).to_s
193
+ log = rand(9999999).to_s
194
+ onscreen = false
195
+
196
+ write_status = @ramps.create_write_status(text, log, onscreen)
197
+
198
+ @ramps.prepare_serial_port(write_status)
199
+ expect(1).to eq(1)
200
+ end
201
+
202
+ it "clean serial buffer" do
203
+ @ramps.serial_port.test_serial_read = rand(9999999).to_s
204
+ @ramps.clean_serial_buffer
205
+ expect(@ramps.serial_port.test_serial_read).to eq(nil)
206
+
207
+ end
208
+
209
+ it "serial port write" do
210
+ text = rand(9999999).to_s
211
+ @ramps.serial_port_write(text)
212
+ expect(@ramps.serial_port.test_serial_write).to eq(text)
213
+ end
214
+
215
+ it "emergency stop off" do
216
+ @ramps.serial_port.test_serial_write = ""
217
+ Fb::HardwareInterface.current.status.emergency_stop = false
218
+ @ramps.check_emergency_stop
219
+ expect(@ramps.serial_port.test_serial_write).to eq("")
220
+ end
221
+
222
+ it "emergency stop on" do
223
+ @ramps.serial_port.test_serial_write = ""
224
+ Fb::HardwareInterface.current.status.emergency_stop = true
225
+ @ramps.check_emergency_stop
226
+ expect(@ramps.serial_port.test_serial_write).to eq("E\n")
227
+ end
228
+
229
+ it "log incoming text" do
230
+ text = rand(9999999).to_s
231
+ log = rand(9999999).to_s
232
+ onscreen = false
233
+
234
+ write_status = @ramps.create_write_status(text, log, onscreen)
235
+
236
+ @ramps.log_incoming_text(write_status)
237
+ expect(1).to eq(1)
238
+ end
239
+
240
+ it "process value split two letters" do
241
+
242
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
243
+ code = "R81"
244
+ text = "ZA1 ZB2 XA3 XB4 YA5 YB6"
245
+ @ramps.process_value_split(code, params, text)
246
+
247
+ expect(params.za).to eq(1)
248
+ expect(params.zb).to eq(2)
249
+ expect(params.xa).to eq(3)
250
+ expect(params.xb).to eq(4)
251
+ expect(params.ya).to eq(5)
252
+ expect(params.yb).to eq(6)
253
+ end
254
+
255
+ it "process value split one letters" do
256
+
257
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
258
+ code = "R99"
259
+ text = "P1 V2 X3 Y4 Z5"
260
+ @ramps.process_value_split(code, params, text)
261
+
262
+ expect(params.p).to eq(1)
263
+ expect(params.v).to eq(2)
264
+ expect(params.x).to eq(3)
265
+ expect(params.y).to eq(4)
266
+ expect(params.z).to eq(5)
267
+
268
+ end
269
+
270
+ it "process value R21" do
271
+
272
+ param = 1
273
+ value = rand(999).to_i
274
+
275
+ code = "R21"
276
+ text = "P#{param} V#{value}"
277
+
278
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
279
+ @ramps.process_value_split(code, params, text)
280
+ @ramps.process_value_R21(params,code)
281
+
282
+ par_obj = @ramps_param.get_param_by_id(param)
283
+
284
+ expect(par_obj['value_ar']).to eq(value)
285
+
286
+ end
287
+
288
+ it "process value R23" do
289
+
290
+ param = 1
291
+ value = rand(999).to_i
292
+
293
+ code = "R23"
294
+ text = "P#{param} V#{value}"
295
+
296
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
297
+ @ramps.process_value_split(code, params, text)
298
+ @ramps.process_value_R23(params,code)
299
+
300
+ par_obj = @ramps_param.get_param_by_id(param)
301
+
302
+ expect(par_obj['value_db']).to eq(value)
303
+
304
+ end
305
+
306
+ it "process value R41" do
307
+
308
+ pinnr = rand(9999999).to_i
309
+ value = rand(9999999).to_i
310
+ exinf = rand(9999999).to_i
311
+
312
+ code = "R41"
313
+ text = "P#{pinnr} V#{value}"
314
+
315
+ @ramps.external_info = exinf
316
+
317
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
318
+ @ramps.process_value_split(code, params, text)
319
+ @ramps.process_value_R41(params,code)
320
+
321
+ pin_value = 0
322
+
323
+
324
+ list.each do |meas|
325
+ if meas['ext_info'].to_s == exinf.to_s
326
+ pin_value = meas['value']
327
+ end
328
+ end
329
+
330
+ expect(pin_value.to_i).to eq(value.to_i)
331
+
332
+ end
333
+
334
+ it "process value R81 XA" do
335
+
336
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
337
+ code = "R81"
338
+ text = " XA1 XB0 YA0 YB0 ZA0 ZB0 "
339
+ @ramps.process_value_split(code, params, text)
340
+ @ramps.process_value_R81(params,code)
341
+
342
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_a).to eq(true)
343
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_b).to eq(false)
344
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_a).to eq(false)
345
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_b).to eq(false)
346
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_a).to eq(false)
347
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_b).to eq(false)
348
+
349
+ end
350
+
351
+ it "process value R81 XB" do
352
+
353
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
354
+ code = "R81"
355
+ text = " XA0 XB1 YA0 YB0 ZA0 ZB0 "
356
+ @ramps.process_value_split(code, params, text)
357
+ @ramps.process_value_R81(params,code)
358
+
359
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_a).to eq(false)
360
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_b).to eq(true)
361
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_a).to eq(false)
362
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_b).to eq(false)
363
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_a).to eq(false)
364
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_b).to eq(false)
365
+
366
+ end
367
+
368
+ it "process value R81 YA" do
369
+
370
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
371
+ code = "R81"
372
+ text = " XA0 XB0 YA1 YB0 ZA0 ZB0 "
373
+ @ramps.process_value_split(code, params, text)
374
+ @ramps.process_value_R81(params,code)
375
+
376
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_a).to eq(false)
377
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_b).to eq(false)
378
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_a).to eq(true)
379
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_b).to eq(false)
380
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_a).to eq(false)
381
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_b).to eq(false)
382
+
383
+ end
384
+
385
+ it "process value R81 YB" do
386
+
387
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
388
+ code = "R81"
389
+ text = " XA0 XB0 YA0 YB1 ZA0 ZB0 "
390
+ @ramps.process_value_split(code, params, text)
391
+ @ramps.process_value_R81(params,code)
392
+
393
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_a).to eq(false)
394
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_b).to eq(false)
395
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_a).to eq(false)
396
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_b).to eq(true)
397
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_a).to eq(false)
398
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_b).to eq(false)
399
+
400
+ end
401
+
402
+ it "process value R81 ZA" do
403
+
404
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
405
+ code = "R81"
406
+ text = " XA0 XB0 YA0 YB0 ZA1 ZB0 "
407
+ @ramps.process_value_split(code, params, text)
408
+ @ramps.process_value_R81(params,code)
409
+
410
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_a).to eq(false)
411
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_b).to eq(false)
412
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_a).to eq(false)
413
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_b).to eq(false)
414
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_a).to eq(true)
415
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_b).to eq(false)
416
+
417
+ end
418
+
419
+ it "process value R81 ZB" do
420
+
421
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
422
+ code = "R81"
423
+ text = " XA0 XB0 YA0 YB0 ZA0 ZB1 "
424
+ @ramps.process_value_split(code, params, text)
425
+ @ramps.process_value_R81(params,code)
426
+
427
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_a).to eq(false)
428
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_b).to eq(false)
429
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_a).to eq(false)
430
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_b).to eq(false)
431
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_a).to eq(false)
432
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_b).to eq(true)
433
+
434
+ end
435
+
436
+ it "process value R82" do
437
+
438
+ x = rand(9999999).to_i
439
+ y = rand(9999999).to_i
440
+ z = rand(9999999).to_i
441
+
442
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
443
+ code = "R82"
444
+ text = "X#{x} Y#{y} Z#{z}"
445
+ @ramps.process_value_split(code, params, text)
446
+ @ramps.process_value_R82(params,code)
447
+
448
+ expect(Fb::HardwareInterface.current.status.info_current_x_steps).to eq(x)
449
+ expect(Fb::HardwareInterface.current.status.info_current_y_steps).to eq(y)
450
+ expect(Fb::HardwareInterface.current.status.info_current_z_steps).to eq(z)
451
+
452
+ expect(Fb::HardwareInterface.current.status.info_current_x ).to eq(x / @ramps_param.axis_x_steps_per_unit)
453
+ expect(Fb::HardwareInterface.current.status.info_current_y ).to eq(y / @ramps_param.axis_y_steps_per_unit)
454
+ expect(Fb::HardwareInterface.current.status.info_current_z ).to eq(z / @ramps_param.axis_z_steps_per_unit)
455
+
456
+ end
457
+
458
+ it "process value R83" do
459
+ code = "R83"
460
+ text = rand(9999999).to_s
461
+
462
+ @ramps.process_value_process_R83(code, text)
463
+
464
+ expect(Fb::HardwareInterface.current.status.device_version).to eq(text)
465
+ end
466
+
467
+
468
+ it "process value R99" do
469
+
470
+ code = "R99"
471
+ text = rand(9999999).to_s
472
+
473
+ @ramps.process_value_process_R99(code, text)
474
+ end
475
+
476
+ it "save pin value" do
477
+
478
+ pinnr = rand(9999999).to_i
479
+ value = rand(9999999).to_i
480
+ exinf = rand(9999999).to_i
481
+
482
+ @ramps.external_info = exinf
483
+ pin_value = 0
484
+
485
+
486
+ list.each do |meas|
487
+ if meas['ext_info'].to_s == exinf.to_s
488
+ pin_value = meas['value']
489
+ end
490
+ end
491
+
492
+ expect(pin_value.to_i).to eq(value.to_i)
493
+ end
494
+
495
+ it "process value process param list 1" do
496
+
497
+ # "process value R21"
498
+
499
+ param = 1
500
+ value = rand(999).to_i
501
+
502
+ code = "R21"
503
+ text = "P#{param} V#{value}"
504
+
505
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
506
+ @ramps.process_value_split(code, params, text)
507
+ @ramps.process_value_process_param_list(params,code)
508
+
509
+ par_obj = @ramps_param.get_param_by_id(param)
510
+
511
+ expect(par_obj['value_ar']).to eq(value)
512
+ end
513
+
514
+ it "process value process param list 2" do
515
+
516
+ # "process value R23"
517
+
518
+ param = 1
519
+ value = rand(999).to_i
520
+
521
+ code = "R23"
522
+ text = "P#{param} V#{value}"
523
+
524
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
525
+ @ramps.process_value_split(code, params, text)
526
+ @ramps.process_value_process_param_list(params,code)
527
+
528
+ par_obj = @ramps_param.get_param_by_id(param)
529
+
530
+ expect(par_obj['value_db']).to eq(value)
531
+
532
+ end
533
+
534
+ it "process value process param list 3" do
535
+
536
+ # "process value R41"
537
+
538
+ pinnr = rand(9999999).to_i
539
+ value = rand(9999999).to_i
540
+ exinf = rand(9999999).to_i
541
+
542
+ code = "R41"
543
+ text = "P#{pinnr} V#{value}"
544
+
545
+ @ramps.external_info = exinf
546
+
547
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
548
+ @ramps.process_value_split(code, params, text)
549
+ @ramps.process_value_process_param_list(params,code)
550
+
551
+ pin_value = 0
552
+
553
+
554
+ list.each do |meas|
555
+ if meas['ext_info'].to_s == exinf.to_s
556
+ pin_value = meas['value']
557
+ end
558
+ end
559
+
560
+ end
561
+
562
+ it "process value process text 1" do
563
+
564
+ # process_value_process_R83
565
+
566
+ code = "R83"
567
+ text = rand(9999999).to_s
568
+
569
+ @ramps.process_value_process_R83(code, text)
570
+
571
+ expect(Fb::HardwareInterface.current.status.device_version).to eq(text)
572
+
573
+ end
574
+
575
+ it "process value process text 2" do
576
+
577
+ # process_value_process_R99
578
+
579
+ code = "R99"
580
+ text = rand(9999999).to_s
581
+
582
+ @ramps.process_value_process_R99(code, text)
583
+
584
+ end
585
+
586
+ it "process value 1" do
587
+
588
+ # "process value R21"
589
+
590
+ param = 1
591
+ value = rand(999).to_i
592
+
593
+ code = "R21"
594
+ text = "P#{param} V#{value}"
595
+
596
+ @ramps.process_value(code,text)
597
+
598
+ par_obj = @ramps_param.get_param_by_id(param)
599
+
600
+ expect(par_obj['value_ar']).to eq(value)
601
+
602
+ end
603
+
604
+ it "process value 2" do
605
+
606
+
607
+ # process_value_process_R99
608
+
609
+ code = "R99"
610
+ text = rand(9999999).to_s
611
+
612
+ @ramps.process_value(code,text)
613
+
614
+ end
615
+
616
+ it "process value 3" do
617
+
618
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
619
+ code = "R81"
620
+ text = " XA0 XB0 YA0 YB0 ZA0 ZB1 "
621
+ @ramps.process_value(code,text)
622
+
623
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_a).to eq(false)
624
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_b).to eq(false)
625
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_a).to eq(false)
626
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_b).to eq(false)
627
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_a).to eq(false)
628
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_b).to eq(true)
629
+
630
+ end
631
+
632
+ it "process value named parameters 1" do
633
+
634
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
635
+ code = "R81"
636
+ text = " XA0 XB0 YA0 YB0 ZA0 ZB1 "
637
+ @ramps.process_value_split(code, params, text)
638
+ @ramps.process_value_process_named_params(params,code)
639
+
640
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_a).to eq(false)
641
+ expect(Fb::HardwareInterface.current.status.info_end_stop_x_b).to eq(false)
642
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_a).to eq(false)
643
+ expect(Fb::HardwareInterface.current.status.info_end_stop_y_b).to eq(false)
644
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_a).to eq(false)
645
+ expect(Fb::HardwareInterface.current.status.info_end_stop_z_b).to eq(true)
646
+
647
+ end
648
+
649
+ it "process value named parameters 2" do
650
+
651
+ x = rand(9999999).to_i
652
+ y = rand(9999999).to_i
653
+ z = rand(9999999).to_i
654
+
655
+ params = Fb::HardwareInterfaceArduinoValuesReceived.new
656
+ code = "R82"
657
+ text = "X#{x} Y#{y} Z#{z}"
658
+ @ramps.process_value_split(code, params, text)
659
+ @ramps.process_value_process_named_params(params,code)
660
+
661
+ expect(Fb::HardwareInterface.current.status.info_current_x_steps).to eq(x)
662
+ expect(Fb::HardwareInterface.current.status.info_current_y_steps).to eq(y)
663
+ expect(Fb::HardwareInterface.current.status.info_current_z_steps).to eq(z)
664
+
665
+ expect(Fb::HardwareInterface.current.status.info_current_x ).to eq(x / @ramps_param.axis_x_steps_per_unit)
666
+ expect(Fb::HardwareInterface.current.status.info_current_y ).to eq(y / @ramps_param.axis_y_steps_per_unit)
667
+ expect(Fb::HardwareInterface.current.status.info_current_z ).to eq(z / @ramps_param.axis_z_steps_per_unit)
668
+
669
+ end
670
+
671
+ end
672
+