Method: OpenC3::InterfaceModel#build
- Defined in:
- lib/openc3/models/interface_model.rb
#build ⇒ Object
Called by InterfaceMicroservice to instantiate the Interface defined by the model configuration. Must be called after get_model which calls from_json to instantiate the class and populate the attributes.
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/openc3/models/interface_model.rb', line 138 def build klass = OpenC3.require_class(@config_params[0]) if @config_params.length > 1 interface_or_router = klass.new(*@config_params[1..-1]) else interface_or_router = klass.new end interface_or_router.secrets.setup(@secrets) interface_or_router.target_names = @target_names.dup interface_or_router.cmd_target_names = @cmd_target_names.dup interface_or_router.tlm_target_names = @tlm_target_names.dup interface_or_router.connect_on_startup = @connect_on_startup interface_or_router.auto_reconnect = @auto_reconnect interface_or_router.reconnect_delay = @reconnect_delay interface_or_router.disable_disconnect = @disable_disconnect @options.each do |option| interface_or_router.set_option(option[0], option[1..-1]) end @secret_options.each do |option| secret_name = option[1] secret_value = interface_or_router.secrets.get(secret_name, scope: @scope) interface_or_router.set_option(option[0], [secret_value]) end @protocols.each do |protocol| klass = OpenC3.require_class(protocol[1]) interface_or_router.add_protocol(klass, protocol[2..-1], protocol[0].upcase.intern) end if @log_stream interface_or_router.stream_log_pair = StreamLogPair.new(interface_or_router.name, @log_stream) interface_or_router.start_raw_logging end interface_or_router end |