Class: OpenC3::BridgeConfig

Inherits:
Object show all
Defined in:
lib/openc3/bridge/bridge_config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ BridgeConfig

Returns a new instance of BridgeConfig.



30
31
32
33
34
# File 'lib/openc3/bridge/bridge_config.rb', line 30

def initialize(filename)
  @interfaces = {}
  @routers = {}
  process_file(filename)
end

Instance Attribute Details

#interfacesHash<String, Interface>

Returns Interfaces hash.

Returns:



26
27
28
# File 'lib/openc3/bridge/bridge_config.rb', line 26

def interfaces
  @interfaces
end

#routersHash<String, Interface>

Returns Routers hash.

Returns:



28
29
30
# File 'lib/openc3/bridge/bridge_config.rb', line 28

def routers
  @routers
end

Class Method Details

.generate_default(filename) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/openc3/bridge/bridge_config.rb', line 36

def self.generate_default(filename)
  default_config = "            # Example Host Bridge Configuration for a Serial Port\n            #\n            # INTERFACE <Interface Name> <Interface File> <Interface Params...>\n            # INTERFACE <Interface Name> serial_interface.rb <Write Port> <Read Port> <Baud Rate> <Parity ODD/EVEN/NONE> <Stop Bits> <Write Timeout> <Read Timeout> <Protocol Name> <Protocol Params>\n            # INTERFACE <Interface Name> serial_interface.rb <Write Port> <Read Port> <Baud Rate> <Parity ODD/EVEN/NONE> <Stop Bits> <Write Timeout> <Read Timeout> BURST <Discard Leading Bytes> <Sync Pattern> <Add Sync On Write>\n            # INTERFACE SERIAL_INT serial_interface.rb /dev/ttyS1 /dev/ttyS1 38400 ODD 1 10.0 nil BURST 4 0xDEADBEEF\n            INTERFACE SERIAL_INT serial_interface.rb COM1 COM1 9600 NONE 1 10.0 nil BURST\n    \#{'        '}\n            # ROUTER <Router Name> <Interface File> <Interface Params...>\n            # ROUTER SERIAL_ROUTER tcpip_server_interface.rb <Write Port> <Read Port> <Write Timeout> <Read Timeout> <Protocol Name> <Protocol Params>\n            # ROUTER SERIAL_ROUTER tcpip_server_interface.rb <Write Port> <Read Port> <Write Timeout> <Read Timeout> BURST <Discard Leading Bytes> <Sync Pattern> <Add Sync On Write>\n            ROUTER SERIAL_ROUTER tcpip_server_interface.rb 2950 2950 10.0 nil BURST\n              # ROUTE <Interface Name>\n              ROUTE SERIAL_INT\n    \#{'        '}\n  EOF\n\n  Logger.info \"Writing \#{filename}\"\n  File.open(filename, 'w') do |file|\n    file.write(default_config)\n  end\nend\n"