Sha256: bebe1fa09fd75e6b055cf7ad7f1889d0640d83df116a2dab1ed175e1474f7abc

Contents?: true

Size: 1.88 KB

Versions: 37

Compression:

Stored size: 1.88 KB

Contents

# encoding: ascii-8bit

# Copyright 2017 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt

require 'cosmos/interfaces/stream_interface'
require 'cosmos/streams/tcpip_client_stream'

module Cosmos
  # Base class for interfaces that act as a TCP/IP client
  class TcpipClientInterface < StreamInterface

    # @param hostname [String] Machine to connect to
    # @param write_port [Integer] Port to write commands to
    # @param read_port [Integer] Port to read telemetry from
    # @param write_timeout [Integer] Seconds to wait before aborting writes
    # @param read_timeout [Integer] Seconds to wait before aborting reads
    # @param protocol_type [String] Name of the protocol to use
    #   with this interface
    # @param protocol_args [Array<String>] Arguments to pass to the protocol
    def initialize(
      hostname,
      write_port,
      read_port,
      write_timeout,
      read_timeout,
      protocol_type = nil,
      *protocol_args)

      super(protocol_type, protocol_args)

      @hostname = hostname
      @write_port = ConfigParser.handle_nil(write_port)
      @read_port = ConfigParser.handle_nil(read_port)
      @write_timeout = write_timeout
      @read_timeout = read_timeout
      @read_allowed = false unless @read_port
      @write_allowed = false unless @write_port
      @write_raw_allowed = false unless @write_port
    end

    # Connects the {TcpipClientStream} by passing the
    # initialization parameters to the {TcpipClientStream}.
    def connect
      @stream = TcpipClientStream.new(
        @hostname,
        @write_port,
        @read_port,
        @write_timeout,
        @read_timeout
      )
      super()
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
cosmos-4.5.2-java lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.5.2 lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.5.1-java lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.5.1 lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.5.0-java lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.5.0 lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.4.2-java lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.4.2 lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.4.1-java lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.4.1 lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.4.0-java lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.4.0 lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.3.0-java lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.3.0 lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.2.4-java lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.2.4 lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.2.3-java lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.2.3 lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.2.2-java lib/cosmos/interfaces/tcpip_client_interface.rb
cosmos-4.2.2 lib/cosmos/interfaces/tcpip_client_interface.rb