Module: Validator::CommandHelpers
- Included in:
- StatusHelpers::SignalPriorityRequestHelper
- Defined in:
- spec/support/command_helpers.rb
Instance Method Summary collapse
-
#build_command_list(command_code_id, command_name, values) ⇒ Object
Build a RSMP command value list from a hash.
- #disable_emergency_route(route) ⇒ Object
- #enable_emergency_route(route) ⇒ Object
- #force_detector_logic(component, status: 'True', mode: 'True') ⇒ Object
- #force_input(input:, status: 'True', value: 'True', validate: true) ⇒ Object
- #force_input_and_confirm(input:, value:) ⇒ Object
- #force_output(output:, status:, value: 'True', validate: true) ⇒ Object
- #get_dynamic_bands(plan, band) ⇒ Object
- #prepare(task, site) ⇒ Object
- #require_security_codes ⇒ Object
- #reset_clock ⇒ Object
- #resume_alarm(site, task, cId:, aCId:, collect:) ⇒ Object
- #send_command_and_confirm(parent_task, command_list, message, component = Validator.get_config('main_component')) ⇒ Object
- #set_clock(clock) ⇒ Object
- #set_cycle_time(plan, cycle_time, description = "Set cycle time to #{cycle_time} for plan #{plan}") ⇒ Object
- #set_day_table(status) ⇒ Object
- #set_dynamic_bands(plan, status) ⇒ Object
- #set_emergency_route(route, state) ⇒ Object
- #set_fixed_time(status) ⇒ Object
-
#set_functional_position(status, timeout_minutes: 0) ⇒ Object
Set functional position.
- #set_input(status, input) ⇒ Object
- #set_offset(status, plan) ⇒ Object
-
#set_plan(plan) ⇒ Object
Switch signal plan.
- #set_security_code(level) ⇒ Object
- #set_series_of_inputs(status) ⇒ Object
-
#set_signal_start ⇒ Object
Order a signal group to green.
-
#set_signal_stop ⇒ Object
Order a signal group to red.
- #set_timeout_for_dynamic_bands(status) ⇒ Object
-
#set_traffic_situation(ts) ⇒ Object
Set traffic situation.
- #set_trigger_level(status) ⇒ Object
- #set_week_table(status) ⇒ Object
- #stop_sending_watchdogs(site) ⇒ Object
- #suspend_alarm(site, task, cId:, aCId:, collect:) ⇒ Object
- #switch_dark_mode ⇒ Object
- #switch_fixed_time(status) ⇒ Object
- #switch_input(indx) ⇒ Object
- #switch_normal_control ⇒ Object
- #switch_plan(plan) ⇒ Object
- #switch_traffic_situation(ts) ⇒ Object
- #switch_yellow_flash(timeout_minutes: 0) ⇒ Object
-
#unset_traffic_situation ⇒ Object
Unset traffic situation (switch to automatic) The spec does not state what traficsituation to use when unsetting, here we’re using 1.
- #verify_startup_sequence(&block) ⇒ Object
- #wait_normal_control(timeout: Validator.get_config('timeouts','startup_sequence')) ⇒ Object
-
#with_alarm_activated(task, site, alarm_code_id, initial_deactivation: true) ⇒ Object
Run a block with an alarm acticated, then deactive the alarm The device must be programmed to activate an alarm when a specific input is acticated, and the mapping must be configured in the test config.
- #with_clock_set(site, clock, &block) ⇒ Object
- #with_cycle_time_extended(site, extension = 5, &block) ⇒ Object
- #wrong_security_code ⇒ Object
Instance Method Details
#build_command_list(command_code_id, command_name, values) ⇒ Object
Build a RSMP command value list from a hash
11 12 13 14 15 16 17 18 19 20 |
# File 'spec/support/command_helpers.rb', line 11 def build_command_list command_code_id, command_name, values values.compact.to_a.map do |n,v| { 'cCI' => command_code_id.to_s, 'cO' => command_name.to_s, 'n' => n.to_s, 'v' => v.to_s } end end |
#disable_emergency_route(route) ⇒ Object
130 131 132 133 134 135 136 137 138 |
# File 'spec/support/command_helpers.rb', line 130 def disable_emergency_route route require_security_codes command_list = build_command_list :M0005, :setEmergency, { securityCode: Validator.get_config('secrets','security_codes',2), status: 'False', emergencyroute: route } send_command_and_confirm @task, command_list, "Disable emergency route #{route}" end |
#enable_emergency_route(route) ⇒ Object
120 121 122 123 124 125 126 127 128 |
# File 'spec/support/command_helpers.rb', line 120 def enable_emergency_route route require_security_codes command_list = build_command_list :M0005, :setEmergency, { securityCode: Validator.get_config('secrets','security_codes',2), status: 'True', emergencyroute: route } send_command_and_confirm @task, command_list, "Enable emergency route #{route}" end |
#force_detector_logic(component, status: 'True', mode: 'True') ⇒ Object
150 151 152 153 154 155 156 157 158 |
# File 'spec/support/command_helpers.rb', line 150 def force_detector_logic component, status:'True', mode:'True' require_security_codes command_list = build_command_list :M0008, :setForceDetectorLogic, { securityCode: Validator.get_config('secrets','security_codes',2), status: status, mode: mode } send_command_and_confirm @task, command_list, "Force detector logic #{component} to #{mode}", component end |
#force_input(input:, status: 'True', value: 'True', validate: true) ⇒ Object
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'spec/support/command_helpers.rb', line 286 def force_input input:, status:'True', value: 'True', validate:true require_security_codes if status == 'True' str = "Force input #{input} to #{value}" wait_str = "input #{input} to be forced to #{value}" else str = "Release input #{input}" wait_str = "input #{input} to be released" end command_list = build_command_list :M0019, :setInput, { securityCode: Validator.get_config('secrets','security_codes',2), status: status, input: input, inputValue: value } send_command_and_confirm @task, command_list, str if status == 'True' input_status_str = value == 'True' ? '1' : '0' wait_for_status(@task, wait_str, [ {'sCI'=>'S0029','n'=>'status','s'=>/^.{#{input - 1}}1/}, {'sCI'=>'S0003','n'=>'inputstatus','s'=>/^.{#{input - 1}}#{input_status_str}/} ]) else wait_for_status(@task, wait_str, [ {'sCI'=>'S0029','n'=>'status','s'=>/^.{#{input - 1}}0/} ]) end end |
#force_input_and_confirm(input:, value:) ⇒ Object
426 427 428 429 430 431 432 433 |
# File 'spec/support/command_helpers.rb', line 426 def force_input_and_confirm(input:, value:) force_input status: 'True', input: input, value: value digit = (value == 'True' ? '1' : '0') wait_for_status(@task, "input #{input} to be #{value}", [{'sCI'=>'S0003','n'=>'inputstatus','s'=>/^.{#{input-1}}#{digit}/}] # index is 1-based, convert to 0-based fo regex ) end |
#force_output(output:, status:, value: 'True', validate: true) ⇒ Object
317 318 319 320 321 322 323 324 325 326 |
# File 'spec/support/command_helpers.rb', line 317 def force_output output:, status:, value:'True', validate:true require_security_codes command_list = build_command_list :M0020, :setOutput, { securityCode: Validator.get_config('secrets','security_codes',2), status: status, output: output, outputValue: value } send_command_and_confirm @task, command_list, "Force output #{output} to #{value}" end |
#get_dynamic_bands(plan, band) ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'spec/support/command_helpers.rb', line 203 def get_dynamic_bands plan, band Validator.log "Get dynamic bands", level: :test status_list = { S0023: [:status] } result = @site.request_status Validator.get_config('main_component'), convert_status_list(status_list), collect!: { timeout: Validator.get_config('timeouts','status_update', default: 0) } collector = result[:collector] collector.matchers.first.got['s'].split(',').each do |item| some_plan, some_band, value = *item.split('-') return value.to_i if some_plan.to_i == plan.to_i && some_band.to_i == band.to_i end nil end |
#prepare(task, site) ⇒ Object
641 642 643 644 |
# File 'spec/support/command_helpers.rb', line 641 def prepare task, site @task = task @site = site end |
#require_security_codes ⇒ Object
357 358 359 360 361 |
# File 'spec/support/command_helpers.rb', line 357 def require_security_codes unless Validator.config.dig 'secrets', 'security_codes' skip "Security codes are not configured" end end |
#reset_clock ⇒ Object
449 450 451 452 453 454 455 456 457 458 459 460 461 462 |
# File 'spec/support/command_helpers.rb', line 449 def reset_clock require_security_codes now = Time.now.utc command_list = build_command_list :M0104, :setDate, { securityCode: Validator.get_config('secrets','security_codes',1), year: now.year, month: now.month, day: now.day, hour: now.hour, minute: now.min, second: now.sec } send_command_and_confirm @task, command_list, "Reset clock to #{now}" end |
#resume_alarm(site, task, cId:, aCId:, collect:) ⇒ Object
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 |
# File 'spec/support/command_helpers.rb', line 613 def resume_alarm site, task, cId:, aCId:, collect: resume = RSMP::AlarmResume.new( 'mId' => RSMP::Message.make_m_id, # generate a message id, that can be used to listen for responses 'cId' => cId, 'aCId' => aCId ) if collect collect_task = task.async do RSMP::AlarmCollector.new(site, m_id: resume.m_id, num: 1, matcher: { 'cId' => cId, 'aCI'=>aCId, 'aSp'=>'Suspend', 'sS'=>/^notSuspended/i }, timeout: Validator.config['timeouts']['alarm'] ).collect! end site. resume return resume, collect_task.wait.first else site. resume resume end end |
#send_command_and_confirm(parent_task, command_list, message, component = Validator.get_config('main_component')) ⇒ Object
2 3 4 5 6 7 8 |
# File 'spec/support/command_helpers.rb', line 2 def send_command_and_confirm parent_task, command_list, , component=Validator.get_config('main_component') result = nil log @site.send_command component, command_list, collect!: { timeout: Validator.get_config('timeouts','command_response') } end |
#set_clock(clock) ⇒ Object
435 436 437 438 439 440 441 442 443 444 445 446 447 |
# File 'spec/support/command_helpers.rb', line 435 def set_clock clock require_security_codes command_list = build_command_list :M0104, :setDate, { securityCode: Validator.get_config('secrets','security_codes',1), year: clock.year, month: clock.month, day: clock.day, hour: clock.hour, minute: clock.min, second: clock.sec } send_command_and_confirm @task, command_list, "Set clock to #{clock}" end |
#set_cycle_time(plan, cycle_time, description = "Set cycle time to #{cycle_time} for plan #{plan}") ⇒ Object
246 247 248 249 250 251 252 253 254 |
# File 'spec/support/command_helpers.rb', line 246 def set_cycle_time plan, cycle_time, description="Set cycle time to #{cycle_time} for plan #{plan}" require_security_codes command_list = build_command_list :M0018, :setCycleTime, { securityCode: Validator.get_config('secrets','security_codes',2), status: cycle_time, plan: plan } send_command_and_confirm @task, command_list, description end |
#set_day_table(status) ⇒ Object
237 238 239 240 241 242 243 244 |
# File 'spec/support/command_helpers.rb', line 237 def set_day_table status require_security_codes command_list = build_command_list :M0017, :setTimeTable, { securityCode: Validator.get_config('secrets','security_codes',2), status: status } send_command_and_confirm @task, command_list, "Set time table to #{status}" end |
#set_dynamic_bands(plan, status) ⇒ Object
193 194 195 196 197 198 199 200 201 |
# File 'spec/support/command_helpers.rb', line 193 def set_dynamic_bands plan, status require_security_codes command_list = build_command_list :M0014, :setCommands, { securityCode: Validator.get_config('secrets','security_codes',2), status: status, plan: plan } send_command_and_confirm @task, command_list, "Set dynamic bands to #{status} for plan #{plan}" end |
#set_emergency_route(route, state) ⇒ Object
112 113 114 115 116 117 118 |
# File 'spec/support/command_helpers.rb', line 112 def set_emergency_route route, state if state enable_emergency_route route else disable_emergency_route route end end |
#set_fixed_time(status) ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'spec/support/command_helpers.rb', line 103 def set_fixed_time status require_security_codes command_list = build_command_list :M0007, :setFixedTime, { securityCode: Validator.get_config('secrets','security_codes',2), status: status } send_command_and_confirm @task, command_list, "Switch to fixed time #{status}" end |
#set_functional_position(status, timeout_minutes: 0) ⇒ Object
Set functional position
92 93 94 95 96 97 98 99 100 101 |
# File 'spec/support/command_helpers.rb', line 92 def set_functional_position status, timeout_minutes:0 require_security_codes command_list = build_command_list :M0001, :setValue, { securityCode: Validator.get_config('secrets','security_codes',2), status: status, timeout: timeout_minutes, intersection: 0, } send_command_and_confirm @task, command_list, "Switch to functional position #{status}" end |
#set_input(status, input) ⇒ Object
140 141 142 143 144 145 146 147 148 |
# File 'spec/support/command_helpers.rb', line 140 def set_input status, input require_security_codes command_list = build_command_list :M0006, :setInput, { securityCode: Validator.get_config('secrets','security_codes',2), status: status, input: input } send_command_and_confirm @task, command_list, "Set input #{input} to #{status}" end |
#set_offset(status, plan) ⇒ Object
218 219 220 221 222 223 224 225 226 |
# File 'spec/support/command_helpers.rb', line 218 def set_offset status, plan require_security_codes command_list = build_command_list :M0015, :setOffset, { securityCode: Validator.get_config('secrets','security_codes',2), status: status, plan: plan } send_command_and_confirm @task, command_list, "Set offset for plan #{plan} to #{status}" end |
#set_plan(plan) ⇒ Object
Switch signal plan
47 48 49 50 51 52 53 54 55 |
# File 'spec/support/command_helpers.rb', line 47 def set_plan plan require_security_codes command_list = build_command_list :M0002, :setPlan, { securityCode: Validator.get_config('secrets','security_codes',2), status: 'True', # true = use plan nr in commone, false = use time table timeplan: plan } send_command_and_confirm @task, command_list, "Switch to plan #{plan}" end |
#set_security_code(level) ⇒ Object
346 347 348 349 350 351 352 353 354 355 |
# File 'spec/support/command_helpers.rb', line 346 def set_security_code level require_security_codes status = "Level#{level}" command_list = build_command_list :M0103, :setSecurityCode, { oldSecurityCode: Validator.get_config('secrets','security_codes',level), newSecurityCode: Validator.get_config('secrets','security_codes',level), status: status } send_command_and_confirm @task, command_list, "Set security code for level #{level}" end |
#set_series_of_inputs(status) ⇒ Object
184 185 186 187 188 189 190 191 |
# File 'spec/support/command_helpers.rb', line 184 def set_series_of_inputs status require_security_codes command_list = build_command_list :M0013, :setInput, { securityCode: Validator.get_config('secrets','security_codes',2), status: status } send_command_and_confirm @task, command_list, "Set a series of inputs using #{status}" end |
#set_signal_start ⇒ Object
Order a signal group to green
23 24 25 26 27 28 29 30 31 32 |
# File 'spec/support/command_helpers.rb', line 23 def set_signal_start require_security_codes command_list = build_command_list :M0010, :setStart, { securityCode: Validator.get_config('secrets','security_codes',2), status: 'True' } indx = 0 component = Validator.get_config('components','signal_group').keys[indx] send_command_and_confirm @task, command_list, "Order signal group #{indx} to green", component end |
#set_signal_stop ⇒ Object
Order a signal group to red
35 36 37 38 39 40 41 42 43 44 |
# File 'spec/support/command_helpers.rb', line 35 def set_signal_stop require_security_codes command_list = build_command_list :M0011, :setStop, { securityCode: Validator.get_config('secrets','security_codes',2), status: 'True' } indx = 0 component = Validator.get_config('components','signal_group').keys[indx] send_command_and_confirm @task, command_list, "Order signal group #{indx} to red", component end |
#set_timeout_for_dynamic_bands(status) ⇒ Object
337 338 339 340 341 342 343 344 |
# File 'spec/support/command_helpers.rb', line 337 def set_timeout_for_dynamic_bands status require_security_codes command_list = build_command_list :M0023, :setTimeout, { securityCode: Validator.get_config('secrets','security_codes',2), status: status } send_command_and_confirm @task, command_list, "Set timeout for dynamic bands to #{status}" end |
#set_traffic_situation(ts) ⇒ Object
Set traffic situation
66 67 68 69 70 71 72 73 74 75 |
# File 'spec/support/command_helpers.rb', line 66 def set_traffic_situation ts require_security_codes command_list = build_command_list :M0003, :setTrafficSituation, { status: 'True', securityCode: Validator.get_config('secrets','security_codes',2), traficsituation: ts # note: the spec misspells 'traficsituation' } send_command_and_confirm @task, command_list, "Switch to traffic situation #{ts}" end |
#set_trigger_level(status) ⇒ Object
328 329 330 331 332 333 334 335 |
# File 'spec/support/command_helpers.rb', line 328 def set_trigger_level status require_security_codes command_list = build_command_list :M0021, :setLevel, { securityCode: Validator.get_config('secrets','security_codes',2), status: status } send_command_and_confirm @task, command_list, "Set trigger level sensitivity for loop detector to #{status}" end |
#set_week_table(status) ⇒ Object
228 229 230 231 232 233 234 235 |
# File 'spec/support/command_helpers.rb', line 228 def set_week_table status require_security_codes command_list = build_command_list :M0016, :setWeekTable, { securityCode: Validator.get_config('secrets','security_codes',2), status: status } send_command_and_confirm @task, command_list, "Set week table to #{status}" end |
#stop_sending_watchdogs(site) ⇒ Object
464 465 466 467 468 469 |
# File 'spec/support/command_helpers.rb', line 464 def stop_sending_watchdogs(site) # monkey-patch the site object by redefining # the send_watchdog method to do nothing def site.send_watchdog now=nil end end |
#suspend_alarm(site, task, cId:, aCId:, collect:) ⇒ Object
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 |
# File 'spec/support/command_helpers.rb', line 585 def suspend_alarm site, task, cId:, aCId:, collect: suspend = RSMP::AlarmSuspend.new( 'mId' => RSMP::Message.make_m_id, # generate a message id, that can be used to listen for responses 'cId' => cId, 'aCId' => aCId ) if collect collect_task = task.async do RSMP::AlarmCollector.new(site, m_id: suspend.m_id, num: 1, matcher: { 'cId' => cId, 'aCI' => aCId, 'aSp' => 'Suspend', 'sS' => /^Suspended/i }, timeout: Validator.config['timeouts']['alarm'] ).collect! end site. suspend return suspend, collect_task.wait.first else site. suspend suspend end end |
#switch_dark_mode ⇒ Object
176 177 178 179 180 181 182 |
# File 'spec/support/command_helpers.rb', line 176 def switch_dark_mode set_functional_position 'Dark' wait_for_status(@task, "dark mode", [{'sCI'=>'S0007','n'=>'status','s'=>/^False(,False)*$/}] ) end |
#switch_fixed_time(status) ⇒ Object
563 564 565 566 567 568 569 |
# File 'spec/support/command_helpers.rb', line 563 def switch_fixed_time status set_fixed_time status wait_for_status(@task, "fixed time to be #{status}", [{'sCI'=>'S0009','n'=>'status','s'=>/^#{status}(,#{status})*$/}] ) end |
#switch_input(indx) ⇒ Object
571 572 573 574 575 576 577 578 579 580 581 582 583 |
# File 'spec/support/command_helpers.rb', line 571 def switch_input indx set_input 'True',indx.to_s wait_for_status(@task, "input #{indx} to be True", [{'sCI'=>'S0003','n'=>'inputstatus','s'=>/^.{#{indx-1}}1/}] # index is 1-based, convert to 0-based fo regex ) set_input 'False',indx.to_s wait_for_status(@task, "input #{indx} to be False", [{'sCI'=>'S0003','n'=>'inputstatus','s'=>/^.{#{indx-1}}0/}] ) end |
#switch_normal_control ⇒ Object
558 559 560 561 |
# File 'spec/support/command_helpers.rb', line 558 def switch_normal_control set_functional_position 'NormalControl' wait_normal_control end |
#switch_plan(plan) ⇒ Object
160 161 162 163 164 165 166 |
# File 'spec/support/command_helpers.rb', line 160 def switch_plan plan set_plan plan.to_s wait_for_status(@task, "plan #{plan} to be active", [{'sCI'=>'S0014','n'=>'status','s'=>plan.to_s}] ) end |
#switch_traffic_situation(ts) ⇒ Object
57 58 59 60 61 62 63 |
# File 'spec/support/command_helpers.rb', line 57 def switch_traffic_situation ts set_traffic_situation ts wait_for_status(@task, "traffic situation #{ts}", [{'sCI'=>'S0015','n'=>'status','s'=>ts}] ) end |
#switch_yellow_flash(timeout_minutes: 0) ⇒ Object
168 169 170 171 172 173 174 |
# File 'spec/support/command_helpers.rb', line 168 def switch_yellow_flash timeout_minutes: 0 set_functional_position 'YellowFlash', timeout_minutes: timeout_minutes wait_for_status(@task, "yellow flash", [{'sCI'=>'S0011','n'=>'status','s'=>/^True(,True)*$/}] ) end |
#unset_traffic_situation ⇒ Object
Unset traffic situation (switch to automatic) The spec does not state what traficsituation to use when unsetting, here we’re using 1. (Allowed range is 1-255)
80 81 82 83 84 85 86 87 88 89 |
# File 'spec/support/command_helpers.rb', line 80 def unset_traffic_situation require_security_codes command_list = build_command_list :M0003, :setTrafficSituation, { status: 'False', securityCode: Validator.get_config('secrets','security_codes',2), traficsituation: '1' # note: the spec misspells 'traficsituation' } send_command_and_confirm @task, command_list, "Switch to automaatic traffic situation" end |
#verify_startup_sequence(&block) ⇒ Object
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
# File 'spec/support/command_helpers.rb', line 505 def verify_startup_sequence &block status_list = [{'sCI'=>'S0001','n'=>'signalgroupstatus'}] subscribe_list = convert_status_list(status_list).map { |item| item.merge 'uRt'=>0.to_s } subscribe_list.map! { |item| item.merge!('sOc' => true) } if use_sOc?(@site) unsubscribe_list = convert_status_list(status_list) component = Validator.get_config('main_component') timeout = Validator.get_config('timeouts','startup_sequence') collector = RSMP::StatusCollector.new @site, status_list, timeout: timeout sequencer = Validator::StatusHelpers::SignalGroupSequenceHelper.new Validator.get_config('startup_sequence') states = nil collector_task = @task.async do log "Verifying startup sequence" collector.collect do |,item| # listen for status messages next unless item states = item['s'] #p states status = sequencer.check states # check sequences if status == :ok log "Startup sequence #{states}: OK" if sequencer.done? # if all groups reached end? collector.complete # then end collection else false # reject item, ie. continue collecting end else log "Startup sequence #{states}: Fail" collector.cancel status # if sequence was incorrect then cancel collection end end end # let block take other actions, like activating yellow flash, change control mode, etc. yield # subscribe, so we start getting status udates @site.subscribe_to_status component, subscribe_list case collector_task.wait # wait for the collector to complete when :ok log "Startup sequence verified" when :timeout raise "Startup sequence '#{sequencer.sequence}' didn't complete in #{timeout}s, reached #{sequencer.latest}, #{sequencer.num_started} started, #{sequencer.num_done} done" when :cancelled raise "Startup sequence '#{sequencer.sequence}' not followed: #{collector.error}" end wait_for_status(@task,"control mode to be startup", [{'sCI'=>'S0020','n'=>'controlmode','s'=>'control'}]) ensure @site.unsubscribe_to_status component, unsubscribe_list # unsubscribe end |
#wait_normal_control(timeout: Validator.get_config('timeouts','startup_sequence')) ⇒ Object
493 494 495 496 497 498 499 500 501 502 503 |
# File 'spec/support/command_helpers.rb', line 493 def wait_normal_control timeout: Validator.get_config('timeouts','startup_sequence') wait_for_status(@task, "normal control on, yellow flash off, startup mode off", [ {'sCI'=>'S0007','n'=>'status','s'=>/^True(,True)*$/}, # normal control on (=dark mode off) {'sCI'=>'S0011','n'=>'status','s'=>/^False(,False)*$/}, # yellow flash off {'sCI'=>'S0005','n'=>'status','s'=>'False'} # startup mode off ], timeout: timeout ) end |
#with_alarm_activated(task, site, alarm_code_id, initial_deactivation: true) ⇒ Object
Run a block with an alarm acticated, then deactive the alarm The device must be programmed to activate an alarm when a specific input is acticated, and the mapping must be configured in the test config.
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'spec/support/command_helpers.rb', line 366 def with_alarm_activated task, site, alarm_code_id, initial_deactivation: true input_nr, component_id = find_alarm_programming(alarm_code_id) component_id ||= Validator.get_config('main_component') if initial_deactivation force_input_and_confirm input: input_nr, value: 'False' end state = false begin if RSMP::Proxy.version_meets_requirement? site.core_version, '>=3.2' # from core 3.2 all enum matching must be match exactly alarm_specialization = /Issue/ alarm_active = /Active/ alarm_inactive = /inActive/ else # before 3.2 match is done case-insensitively alarm_specialization = /issue/i alarm_active = /active/i alarm_inactive = /inactive/i end collect_task = task.async do # run the collector in an async task collector = RSMP::AlarmCollector.new( site, num: 1, matcher: { 'cId' => component_id, 'aCId' => alarm_code_id, 'aSp' => alarm_specialization, 'aS' => alarm_active }, timeout: Validator.get_config('timeouts','alarm') ) collector.collect! collector..first end force_input_and_confirm input: input_nr, value: 'True' state = true yield collect_task.wait, component_id collect_task = task.async do # run the collector in an async task collector = RSMP::AlarmCollector.new( site, num: 1, matcher: { 'cId' => component_id, 'aCId' => alarm_code_id, 'aSp' => /Issue/i, 'aS' => alarm_inactive }, timeout: Validator.get_config('timeouts','alarm') ) collector.collect! collector..first end force_input_and_confirm input: input_nr, value: 'False' state = false return collect_task.wait, component_id ensure force_input_and_confirm input: input_nr, value: 'False' if state == true end end |
#with_clock_set(site, clock, &block) ⇒ Object
471 472 473 474 475 476 477 |
# File 'spec/support/command_helpers.rb', line 471 def with_clock_set site, clock, &block result = set_clock clock site. yield result ensure reset_clock end |
#with_cycle_time_extended(site, extension = 5, &block) ⇒ Object
256 257 258 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 |
# File 'spec/support/command_helpers.rb', line 256 def with_cycle_time_extended site, extension=5, &block # read current plan plan = read_current_plan(site) # read initial cycle times times = read_cycle_times(site) time = times[plan] expect(time).to_not be_nil, "Site returned empty cycle times list" # change cycle tme time_extended = time + extension need_to_reset = true set_cycle_time plan, time_extended, "Extend cycle time to #{time_extended} for plan #{plan}" # read updated cycle times increase = 5 times = read_cycle_times(site, "updated cycle times") time_extended_actual = times[plan] expect(time_extended_actual).to eq(time_extended) block.yield ensure if need_to_reset log "Reset cycle time" set_cycle_time plan, time end end |
#wrong_security_code ⇒ Object
480 481 482 483 484 485 486 487 488 489 490 491 |
# File 'spec/support/command_helpers.rb', line 480 def wrong_security_code log "Try to force detector logic with wrong security code" command_list = build_command_list :M0008, :setForceDetectorLogic, { securityCode: '1111', status: 'True', mode: 'True' } component = Validator.get_config('components','detector_logic').keys[0] result = @site.send_command component, command_list, collect!: { timeout: Validator.get_config('timeouts','command_response') } end |