Method: OpenC3::InterfaceMicroservice#connect

Defined in:
lib/openc3/microservices/interface_microservice.rb

#connectObject



629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
# File 'lib/openc3/microservices/interface_microservice.rb', line 629

def connect
  @logger.info "#{@interface.name}: Connecting ..."
  begin
    @interface.connect
  rescue Exception => e
    begin
      @interface.disconnect # Ensure disconnect is called at least once on a partial connect
    rescue Exception
      # We want to report any connect errors, not disconnect in this case
    end
    raise e
  end
  @interface.state = 'CONNECTED'
  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
  @logger.info "#{@interface.name}: Connection Success"
end