Method: OpenC3::InterfaceMicroservice#attempting
- Defined in:
- lib/openc3/microservices/interface_microservice.rb
#attempting(*params) ⇒ Object
Called to connect the interface/router. It takes optional parameters to rebuilt the interface/router. Once we set the state to ‘ATTEMPTING’ the run method handles the actual connection.
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
# File 'lib/openc3/microservices/interface_microservice.rb', line 429 def attempting(*params) unless params.empty? @interface.disconnect() # Build New Interface, this can fail if passed bad parameters new_interface = @interface.class.new(*params) @interface.copy_to(new_interface) # Replace interface for targets @interface.target_names.each do |target_name| target = System.targets[target_name] target.interface = new_interface end @interface = new_interface end @interface.state = 'ATTEMPTING' if @interface_or_router == 'INTERFACE' InterfaceStatusModel.set(@interface.as_json(:allow_nan => true), queued: true, scope: @scope) else RouterStatusModel.set(@interface.as_json(:allow_nan => true), queued: true, scope: @scope) end @interface # Return the interface/router since we may have recreated it # Need to rescue Exception so we cover LoadError rescue Exception => e @logger.error("Attempting connection failed with params #{params} due to #{e.message}") if SignalException === e @logger.info "#{@interface.name}: Closing from signal" @cancel_thread = true end @interface # Return the original interface/router in case of error end |