Top Level Namespace

Defined Under Namespace

Modules: Validator

Constant Summary collapse

CLOCK =
Time.new 2020,9,29,17,29,51,'+00:00'

Instance Method Summary collapse

Methods included from Validator::HandshakeHelper

#check_sequence_3_1_1_to_3_1_3, #check_sequence_3_1_4_or_later

Methods included from Validator::StatusHelpers

#convert_status_list, #request_status_and_confirm, #unsubscribe_from_all, #use_sOc?, #verify_status, #wait_for_groups, #wait_for_status

Methods included from Validator::CommandHelpers

#build_command_list, #disable_emergency_route, #enable_emergency_route, #force_detector_logic, #force_input, #force_input_and_confirm, #force_output, #get_dynamic_bands, #prepare, #require_security_codes, #reset_clock, #resume_alarm, #send_command_and_confirm, #set_clock, #set_cycle_time, #set_day_table, #set_dynamic_bands, #set_emergency_route, #set_fixed_time, #set_functional_position, #set_input, #set_offset, #set_plan, #set_security_code, #set_series_of_inputs, #set_signal_start, #set_signal_start_or_stop, #set_signal_stop, #set_timeout_for_dynamic_bands, #set_traffic_situation, #set_trigger_level, #set_week_table, #stop_sending_watchdogs, #suspend_alarm, #switch_dark_mode, #switch_fixed_time, #switch_input, #switch_normal_control, #switch_plan, #switch_traffic_situation, #switch_yellow_flash, #unset_traffic_situation, #verify_startup_sequence, #wait_normal_control, #with_alarm_activated, #with_clock_set, #wrong_security_code

Instance Method Details

#check_sequence(version) ⇒ Object



73
74
75
76
77
78
79
80
81
82
# File 'spec/supervisor/connect_spec.rb', line 73

def check_sequence version
  case version
  when '3.1.1', '3.1.2', '3.1.3'
    check_sequence_3_1_1 version
  when '3.1.4', '3.1.5', '3.2', '3.2.1', '3.2.2'
    check_sequence_3_1_4 version
  else
    raise "Unkown rsmp version #{version}"
  end
end

#check_sequence_3_1_1(core_version) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'spec/supervisor/connect_spec.rb', line 26

def check_sequence_3_1_1 core_version
  # in earlier core version, both sides sends a Version
  # message simulatenously. we therefore cannot expect
  # a specific sequence
  # but we can expect a set of messages

  expected_version_messages = [
    ['out','Version'],
    ['in','MessageAck'],
    ['in','Version'],
    ['out','MessageAck'],
  ]
  expected_watchdog_messages = [
    ['out','Watchdog'],
    ['in','MessageAck'],
    ['in','Watchdog'],
    ['out','MessageAck']
  ]

  length = expected_version_messages.length +
           expected_watchdog_messages.length

  got = get_connection_message core_version, length
  got_version_messages = got[0..3]
  got_watchdog_messages = got[4..7]

  expect(got_version_messages).to include(*expected_version_messages)
  expect(expected_watchdog_messages).to include(*got_watchdog_messages)
end

#check_sequence_3_1_4(version) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'spec/supervisor/connect_spec.rb', line 56

def check_sequence_3_1_4 version
  expected = [
    ['out','Version'],
    ['in','MessageAck'],
    ['in','Version'],
    ['out','MessageAck'],
    ['out','Watchdog'],
    ['in','MessageAck'],
    ['in','Watchdog'],
    ['out','MessageAck'],
    ['out','AggregatedStatus'],
    ['in','MessageAck']
  ]
  got = get_connection_message version, expected.length
  expect(got).to eq(expected)
end

#get_connection_message(core_version, length) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'spec/supervisor/connect_spec.rb', line 4

def get_connection_message core_version, length
  got = nil
  Validator::Supervisor.isolated(
    'rsmp_versions' => [core_version],
    'collect' => {
      timeout: Validator.get_config('timeouts','ready'),
      num: length,
      ingoing: true,
      outgoing: true
    }
  ) do |task,supervisor,site_proxy|
    collector = site_proxy.collector
    collector.use_task task
    collector.wait!
    expect(site_proxy.ready?).to be true
    got = site_proxy.collector.messages.map { |message| [message.direction.to_s, message.type] }
  end
  got
rescue Async::TimeoutError => e
  raise "Did not collect #{length} messages within #{timeout}s"
end