Class TcsIO

Class Documentation

class TcsIO

interface class provides the actual I/O for a TCS device

There are (at least) two TCS “devices”, the real and simulated. For safety, the client must specify which TCS is to be used, which prevents a casual “open” command from accidentally opening the real TCS when the simulated was intended.

This class performs the I/O with the TCS.

Public Functions

inline TcsIO(const std::string &_name, const std::string &_host, int _port, char _term_write, char _term_read)
inline std::string gethost() const
inline std::string getname() const
inline long initialize_sockets()

create and open sockets to TCS

This creates and opens poolsize+1 sockets, 1 for slow-response commands and poolsize for fast-response commands, which are placed into a pool.

Returns:

ERROR | NO_ERROR

inline std::shared_ptr<Network::Interface> get_connection(TCS::ConnectionType conn_type)

return a shared pointer to a socket connection

Parameters:

conn_type[in] TCS::ConnectionType specifies slow or fast response

Returns:

shared_ptr<Network::Interface>

inline long execute_command(const std::string &cmd, std::string &reply, TCS::ConnectionType conn_type)

get a connection and send a command to that connection

This command is overloaded, calls execute_command with a default timeout.

Parameters:
  • cmd[in] command to send to TCS

  • reply[in] reference to string holds reply

  • conn_type[in] TCS::ConnectionType specifies connection type

Returns:

ERROR | NO_ERROR

inline long execute_command(const std::string &cmd, std::string &reply, TCS::ConnectionType conn_type, int timeout)

get a connection and send a command to that connection

This command is overloaded.

Parameters:
  • cmd[in] command to send to TCS

  • reply[in] reference to string holds reply

  • conn_type[in] TCS::ConnectionType specifies connection type

  • timeout[in] timeout for Poll in milliseconds

Returns:

ERROR | NO_ERROR

inline void return_connection(std::shared_ptr<Network::Interface> sock)

return a connection to the pool

Returns a fast-response socket to the pool for use by another thread.

Parameters:

sock[in] shared pointer to socket connection

inline bool isconnected()

returns true if any sockets are connected to the TCS

Returns:

true | false

inline long close()

closes all socket connections

Returns:

ERROR | NO_ERROR

Public Members

std::vector<Connection> pool

pool for fast-response commands

Public Static Attributes

static const size_t poolsize = 3

size of fast-response connection pool