Module: RSMP::TLC::Proxy::IO

Included in:
SupervisorInterface
Defined in:
lib/rsmp/tlc/proxy/io.rb

Overview

Command methods for I/O control of a remote TLC. Covers detector logic, input/output forcing and setting.

Instance Method Summary collapse

Instance Method Details

#force_input(input:, status:, value:, within:) ⇒ Object

M0019 - Force an input to a given value.



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/rsmp/tlc/proxy/io.rb', line 67

def force_input(input:, status:, value:, within:)
  readiness = validate_ready 'force input'
  return readiness if readiness.failure?

  raise 'TLC main component not found' unless main

  command_list = force_input_command_list(input, status, value)
  confirm_status = force_input_confirm_status(input, status, value)
  send_command_and_collect(command_list, within: within).and_then do |exchange|
    wait_for_status("force input #{input}", confirm_status, timeout: within).map { exchange }
  end
end

#force_input!Object



80
81
82
# File 'lib/rsmp/tlc/proxy/io.rb', line 80

def force_input!(...)
  force_input(...).value!
end

#force_output(output:, status:, value:, within:) ⇒ Object

M0020 - Force an output to a given value.



85
86
87
88
89
90
91
92
# File 'lib/rsmp/tlc/proxy/io.rb', line 85

def force_output(output:, status:, value:, within:)
  readiness = validate_ready 'force output'
  return readiness if readiness.failure?

  raise 'TLC main component not found' unless main

  send_command_and_collect(force_output_command_list(output, status, value), within: within)
end

#force_output!Object



94
95
96
# File 'lib/rsmp/tlc/proxy/io.rb', line 94

def force_output!(...)
  force_output(...).value!
end

#set_input(input:, status:, within:) ⇒ Object

M0006 - Set a single input to a given status.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rsmp/tlc/proxy/io.rb', line 8

def set_input(input:, status:, within:)
  readiness = validate_ready 'set input'
  return readiness if readiness.failure?

  raise 'TLC main component not found' unless main

  security_code = security_code_for(2)

  command_list = [{
    'cCI' => 'M0006',
    'cO' => 'setInput',
    'n' => 'status',
    'v' => command_value('M0006', 'status', status)
  }, {
    'cCI' => 'M0006',
    'cO' => 'setInput',
    'n' => 'securityCode',
    'v' => security_code.to_s
  }, {
    'cCI' => 'M0006',
    'cO' => 'setInput',
    'n' => 'input',
    'v' => command_value('M0006', 'input', input)
  }]
  send_command_and_collect(command_list, within: within)
end

#set_input!Object



35
36
37
# File 'lib/rsmp/tlc/proxy/io.rb', line 35

def set_input!(...)
  set_input(...).value!
end

#set_inputs(status, within:) ⇒ Object

M0013 - Set all inputs via a bit-pattern string.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rsmp/tlc/proxy/io.rb', line 40

def set_inputs(status, within:)
  readiness = validate_ready 'set inputs'
  return readiness if readiness.failure?

  raise 'TLC main component not found' unless main

  security_code = security_code_for(2)

  command_list = [{
    'cCI' => 'M0013',
    'cO' => 'setInput',
    'n' => 'status',
    'v' => command_value('M0013', 'status', status)
  }, {
    'cCI' => 'M0013',
    'cO' => 'setInput',
    'n' => 'securityCode',
    'v' => security_code.to_s
  }]
  send_command_and_collect(command_list, within: within)
end

#set_inputs!Object



62
63
64
# File 'lib/rsmp/tlc/proxy/io.rb', line 62

def set_inputs!(...)
  set_inputs(...).value!
end